Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Behave sanely when the Kinect is unplugged.
libusb_handle_events is thread-safe, but not reentrant. Which means that we can't call fnusb_stop_iso which calls libusb_handle_events from inside the isochronous callback function. Instead, we add a member to fnusb_dev that tracks if the device is permanently dead, and set it to true when we get a LIBUSB_TRANSFER_NO_DEVICE (or on resubmission, LIBUSB_ERROR_NO_DEVICE). Then, in freenect_process_events, after calling libusb_handle_events internally, we check to see if any of the devices in the context have this flag set. If they do, then we should return some nonzero error value, which is currently -1. In the future, we intend to provide callbacks so that clients can receive explicit notifications when a device has disappeared, so the code can robustly handle that situation. Future work. Fixes #229 (I think) Signed-off-by: Drew Fisher <drew.m.fisher@gmail.com>
- Loading branch information
Showing
3 changed files
with
53 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters