Commit 3f7e959
committed
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>1 parent 75a3eb2 commit 3f7e959
3 files changed
+53
-9
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
69 | 69 | | |
70 | 70 | | |
71 | 71 | | |
72 | | - | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
73 | 76 | | |
74 | 77 | | |
75 | 78 | | |
76 | 79 | | |
77 | | - | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
78 | 100 | | |
79 | 101 | | |
80 | 102 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
442 | 442 | | |
443 | 443 | | |
444 | 444 | | |
445 | | - | |
446 | | - | |
| 445 | + | |
| 446 | + | |
447 | 447 | | |
448 | 448 | | |
449 | 449 | | |
| |||
453 | 453 | | |
454 | 454 | | |
455 | 455 | | |
456 | | - | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
457 | 459 | | |
458 | | - | |
| 460 | + | |
459 | 461 | | |
460 | 462 | | |
461 | 463 | | |
462 | 464 | | |
463 | | - | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
464 | 478 | | |
465 | 479 | | |
466 | 480 | | |
| |||
476 | 490 | | |
477 | 491 | | |
478 | 492 | | |
479 | | - | |
480 | | - | |
| 493 | + | |
| 494 | + | |
481 | 495 | | |
482 | 496 | | |
483 | 497 | | |
| |||
528 | 542 | | |
529 | 543 | | |
530 | 544 | | |
| 545 | + | |
| 546 | + | |
531 | 547 | | |
532 | 548 | | |
533 | 549 | | |
534 | 550 | | |
| 551 | + | |
535 | 552 | | |
536 | 553 | | |
| 554 | + | |
537 | 555 | | |
538 | 556 | | |
539 | 557 | | |
540 | 558 | | |
541 | 559 | | |
| 560 | + | |
542 | 561 | | |
543 | 562 | | |
544 | 563 | | |
545 | 564 | | |
| 565 | + | |
546 | 566 | | |
| 567 | + | |
547 | 568 | | |
548 | 569 | | |
549 | 570 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
69 | 69 | | |
70 | 70 | | |
71 | 71 | | |
| 72 | + | |
72 | 73 | | |
73 | 74 | | |
74 | 75 | | |
| |||
0 commit comments