darwin: use detach kernel APIs for capture
authorosy <50960678+osy@users.noreply.github.com>
Wed, 12 May 2021 03:56:27 +0000 (20:56 -0700)
committerNathan Hjelm <hjelmn@google.com>
Sun, 16 May 2021 21:14:49 +0000 (15:14 -0600)
When libusb_detach_kernel_driver() is called on the first interface, we use
the capture re-enumerate APIs to force kernel drivers to detach. On
subsequent calls, a counter is incremented to keep track of the number of
detach calls. When libusb_attach_kernel_driver() is called for the same
number of times, then we re-enumerate (reset) and let kernel drivers
re-attach.

darwin_kernel_driver_active() is changed to attempt to claim an interface
and return 1 only if a kIOReturnExclusiveAccess status is returned. The old
implementation which looks for a CFBundleID in the IORegistryEntry does not
seem to work in all cases.

darwin_reset_device() is aware of the capture status and will re-set twice
if capture mode is enabled: once to do a USB reset and again to re-capture.

Signed-off-by: Nathan Hjelm <hjelmn@google.com>

No differences found