Logo Search packages:      
Sourcecode: pwlib version File versions  Download package

BOOL PVideoInputDevice_VideoForWindows::Close (  ) [virtual]

Close the device.

Reimplemented from PVideoInputDevice.

Definition at line 648 of file vfw.cxx.

References PThread::GetThreadId(), IsOpen(), Stop(), PThread::Terminate(), and PThread::WaitForTermination().

Referenced by PVideoOutputDevice_Window::Open(), Open(), ~PVideoInputDevice_VideoForWindows(), and PVideoOutputDevice_Window::~PVideoOutputDevice_Window().

{
  if (!IsOpen())
    return FALSE;
 
  Stop();

  ::PostThreadMessage(captureThread->GetThreadId(), WM_QUIT, 0, 0L);

  // Some brain dead drivers may hang so we provide a timeout.
  if (!captureThread->WaitForTermination(5000))
  {
      // Two things may happen if we are forced to terminate the capture thread:
      // 1. As the VIDCAP window is associated to that thread the OS itself will 
      //    close the window and release the driver
      // 2. the driver will not be released and we will not have video until we 
      //    terminate the process
      // Any of the two ios better than just hanging
      captureThread->Terminate();
      hCaptureWindow = NULL;
      PTRACE(1, "PVidInp\tCapture thread failed to stop. Terminated");
  }

  delete captureThread;
  captureThread = NULL;

  return TRUE;
}

Here is the call graph for this function:

Here is the caller graph for this function:


Generated by  Doxygen 1.6.0   Back to index