Changeset 2a72f38548208044dc3aa62681419d006c35732d in libusb
- Timestamp:
- 02/15/10 21:07:44 (7 months ago)
- Children:
- 161893cfbefefe315f657677705abe090fc526f2
- Parents:
- a4186794d87124503db2f5f51f51ce90bb95daa7
- git-author:
- Nathan Hjelm <hjelmn@mac.com> / 2010-02-15T14:07:44Z-0600
- git-committer:
- Daniel Drake <dan@reactivated.net> / 2010-02-15T14:07:44Z-0600
- File:
-
- 1 edited
-
libusb/os/darwin_usb.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
libusb/os/darwin_usb.c
r9cc6bf r2a72f3 45 45 static mach_port_t libusb_darwin_mp = 0; /* master port */ 46 46 static CFRunLoopRef libusb_darwin_acfl = NULL; /* async cf loop */ 47 static int initCount = 0; 47 48 48 49 /* async event thread */ … … 310 311 IOReturn kresult; 311 312 312 /* Create the master port for talking to IOKit */ 313 if (!libusb_darwin_mp) { 314 kresult = IOMasterPort (MACH_PORT_NULL, &libusb_darwin_mp); 315 316 if (kresult != kIOReturnSuccess || !libusb_darwin_mp) 317 return darwin_to_libusb (kresult); 318 } 319 320 pthread_create (&libusb_darwin_at, NULL, event_thread_main, (void *)ctx); 321 322 while (!libusb_darwin_acfl) 323 usleep (10); 313 if (!(initCount++)) { 314 /* Create the master port for talking to IOKit */ 315 if (!libusb_darwin_mp) { 316 kresult = IOMasterPort (MACH_PORT_NULL, &libusb_darwin_mp); 317 318 if (kresult != kIOReturnSuccess || !libusb_darwin_mp) 319 return darwin_to_libusb (kresult); 320 } 321 322 pthread_create (&libusb_darwin_at, NULL, event_thread_main, (void *)ctx); 323 324 while (!libusb_darwin_acfl) 325 usleep (10); 326 } 324 327 325 328 return 0; … … 327 330 328 331 static void darwin_exit (void) { 329 void *ret; 330 331 /* stop the async runloop */ 332 CFRunLoopStop (libusb_darwin_acfl); 333 pthread_join (libusb_darwin_at, &ret); 334 335 if (libusb_darwin_mp) 336 mach_port_deallocate(mach_task_self(), libusb_darwin_mp); 337 338 libusb_darwin_mp = 0; 332 if (!(--initCount)) { 333 void *ret; 334 335 /* stop the async runloop */ 336 CFRunLoopStop (libusb_darwin_acfl); 337 pthread_join (libusb_darwin_at, &ret); 338 339 if (libusb_darwin_mp) 340 mach_port_deallocate(mach_task_self(), libusb_darwin_mp); 341 342 libusb_darwin_mp = 0; 343 } 339 344 } 340 345
Note: See TracChangeset
for help on using the changeset viewer.