User`s guide
Opening and Closing Connection with a Device
5-13
private:
// Declaration of acquisition thread function
static DWORD WINAPI acquireThread(void* param);
// Thread variable
HANDLE _acquireThread;
// Thread ID returned by Windows.
DWORD _acquireThreadID;
4
Compile and link your adaptor. You should be able to create a video input object.
When you call the start function, verify that your adaptor successfully created the
acquisition thread.
Suggested Algorithm for closeDevice()
The closeDevice() function typically performs the following tasks.
1
Test whether the device is already closed. If it is, exit.
2
Post a message to the acquisition thread to quit and wait until it returns before
exiting, for adaptors with thread-based designs. For more information about posting
a message to the thread, see “Sending a Message to the Acquisition Thread” on page
5-15.
3
Close the handle associated with the acquisition thread and reset the thread handle
variable to NULL.
Example: Closing the Connection with a Device
The example shows a skeletal implementation of the closeDevice() function.
bool MyDeviceAdaptor::closeDevice(){
// If the device is not open, return.
if (!isOpen())
return true;
// Terminate and close the acquisition thread.
if (_acquireThread) {
// Send WM_QUIT message to thread.
PostThreadMessage(_acquireThreadID, WM_QUIT, 0, 0);
// Give the thread a chance to finish.