hidapi: Stop current run loop in removal callback instead of fetching from context
This commit is contained in:
parent
942545b7fc
commit
b24599cf5b
|
@ -562,11 +562,10 @@ hid_device * HID_API_EXPORT hid_open(unsigned short vendor_id, unsigned short pr
|
||||||
static void hid_device_removal_callback(void *context, IOReturn result,
|
static void hid_device_removal_callback(void *context, IOReturn result,
|
||||||
void *sender)
|
void *sender)
|
||||||
{
|
{
|
||||||
/* Stop the Run Loop for this device. */
|
/* Stop the Run Loop for this device. This callback will always
|
||||||
hid_device *d = context;
|
be called on the device's registered run loop, so we can just
|
||||||
|
get the current loop. */
|
||||||
d->disconnected = 1;
|
CFRunLoopStop(CFRunLoopGetCurrent());
|
||||||
CFRunLoopStop(d->run_loop);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* The Run Loop calls this function for each input report received.
|
/* The Run Loop calls this function for each input report received.
|
||||||
|
@ -658,7 +657,7 @@ static void *read_thread(void *param)
|
||||||
while (!dev->shutdown_thread && !dev->disconnected) {
|
while (!dev->shutdown_thread && !dev->disconnected) {
|
||||||
code = CFRunLoopRunInMode(dev->run_loop_mode, 1000/*sec*/, FALSE);
|
code = CFRunLoopRunInMode(dev->run_loop_mode, 1000/*sec*/, FALSE);
|
||||||
/* Return if the device has been disconnected */
|
/* Return if the device has been disconnected */
|
||||||
if (code == kCFRunLoopRunFinished) {
|
if (code == kCFRunLoopRunFinished || code == kCFRunLoopRunStopped) {
|
||||||
dev->disconnected = 1;
|
dev->disconnected = 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue