winks: work around shutdown deadlock

GetOverlappedResult() might never return with some drivers. Time out
after 1000 ms. We cannot really fix this without either:
1) Controlling the streaming thread so we can do CancelIo() from that
   thread.
2) Switch to using IO completion ports.
This commit is contained in:
Ole André Vadla Ravnås 2010-07-01 15:07:41 +02:00
parent a7a04fe601
commit cc1c6ee9e3

View File

@ -254,15 +254,16 @@ gst_ks_video_device_clear_buffers (GstKsVideoDevice * self)
if (priv->requests == NULL) if (priv->requests == NULL)
return; return;
/* Cancel pending requests */ /* Join any pending requests */
CancelIo (priv->pin_handle);
for (i = 0; i < priv->num_requests; i++) { for (i = 0; i < priv->num_requests; i++) {
ReadRequest *req = &g_array_index (priv->requests, ReadRequest, i); ReadRequest *req = &g_array_index (priv->requests, ReadRequest, i);
DWORD bytes_returned; HANDLE ev = g_array_index (priv->request_events, HANDLE, i);
DWORD n;
GetOverlappedResult (priv->pin_handle, &req->overlapped, &bytes_returned, if (!GetOverlappedResult (priv->pin_handle, &req->overlapped, &n, FALSE)) {
TRUE); if (WaitForSingleObject (ev, 1000) == WAIT_OBJECT_0)
GetOverlappedResult (priv->pin_handle, &req->overlapped, &n, FALSE);
}
} }
/* Clean up */ /* Clean up */