1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-01-18 03:52:11 +01:00

OSX USB: Close more handles properly

This commit is contained in:
James Cotton 2012-09-08 19:48:33 -05:00
parent 3f11c398db
commit cf1c986550

View File

@ -436,8 +436,12 @@ static void free_all_hid(void)
static void hid_close(hid_t *hid)
{
if (!hid || !hid->open || !hid->ref) return;
IOHIDManagerRef hid_manager = IOHIDManagerCreate(kCFAllocatorDefault, kIOHIDOptionsTypeNone);
IOHIDManagerRegisterDeviceMatchingCallback(hid_manager, NULL, NULL);
IOHIDManagerRegisterDeviceRemovalCallback(hid_manager, NULL, NULL);
IOHIDDeviceUnscheduleFromRunLoop(hid->ref, CFRunLoopGetCurrent( ), kCFRunLoopDefaultMode);
IOHIDDeviceClose(hid->ref, kIOHIDOptionsTypeNone);
IOHIDManagerClose(hid_manager, 0);
hid->ref = NULL;
}