Rockbox open source high quality audio player as a Music Player Daemon
mpris rockbox mpd libadwaita audio rust zig deno
2
fork

Configure Feed

Select the types of activity you want to include in your feed.

Implement USB VID / PID retrieval using IOKit on OS X.

Instead of using libusb as wrapper query the USB IDs via IOKit. Since libusb is
only used for that this means that it's no longer necessary on OS X.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@28001 a1c6a512-1295-4272-9138-f99709370657

+84 -4
+81 -1
rbutil/rbutilqt/base/system.cpp
··· 64 64 #include <CoreFoundation/CoreFoundation.h> 65 65 #include <SystemConfiguration/SystemConfiguration.h> 66 66 #include <CoreServices/CoreServices.h> 67 + #include <IOKit/IOKitLib.h> 68 + #include <IOKit/usb/IOUSBLib.h> 67 69 #endif 68 70 69 71 #include "utils.h" ··· 227 229 QMap<uint32_t, QString> usbids; 228 230 // usb pid detection 229 231 qDebug() << "[System] Searching for USB devices"; 230 - #if defined(Q_OS_LINUX) || defined(Q_OS_MACX) 232 + #if defined(Q_OS_LINUX) 231 233 #if defined(LIBUSB1) 232 234 libusb_device **devs; 233 235 int res; ··· 311 313 b = b->next; 312 314 } 313 315 #endif 316 + #endif 317 + 318 + #if defined(Q_OS_MACX) 319 + kern_return_t result = KERN_FAILURE; 320 + CFMutableDictionaryRef usb_matching_dictionary; 321 + io_iterator_t usb_iterator = IO_OBJECT_NULL; 322 + usb_matching_dictionary = IOServiceMatching(kIOUSBDeviceClassName); 323 + result = IOServiceGetMatchingServices(kIOMasterPortDefault, usb_matching_dictionary, 324 + &usb_iterator); 325 + if(result) { 326 + qDebug() << "[System] USB: IOKit: Could not get matching services."; 327 + return usbids; 328 + } 329 + 330 + io_object_t usbCurrentObj; 331 + while((usbCurrentObj = IOIteratorNext(usb_iterator))) { 332 + uint32_t id; 333 + QString name; 334 + /* get vendor ID */ 335 + CFTypeRef vidref = NULL; 336 + int vid = 0; 337 + vidref = IORegistryEntryCreateCFProperty(usbCurrentObj, CFSTR("idVendor"), 338 + kCFAllocatorDefault, 0); 339 + CFNumberGetValue((CFNumberRef)vidref, kCFNumberIntType, &vid); 340 + CFRelease(vidref); 341 + 342 + /* get product ID */ 343 + CFTypeRef pidref = NULL; 344 + int pid = 0; 345 + pidref = IORegistryEntryCreateCFProperty(usbCurrentObj, CFSTR("idProduct"), 346 + kCFAllocatorDefault, 0); 347 + CFNumberGetValue((CFNumberRef)pidref, kCFNumberIntType, &pid); 348 + CFRelease(pidref); 349 + id = vid << 16 | pid; 350 + 351 + /* get product vendor */ 352 + char vendor_buf[256]; 353 + CFIndex vendor_buflen = 256; 354 + CFTypeRef vendor_name_ref = NULL; 355 + 356 + vendor_name_ref = IORegistryEntrySearchCFProperty(usbCurrentObj, 357 + kIOServicePlane, CFSTR("USB Vendor Name"), 358 + kCFAllocatorDefault, 0); 359 + if(vendor_name_ref != NULL) { 360 + CFStringGetCString((CFStringRef)vendor_name_ref, vendor_buf, vendor_buflen, 361 + kCFStringEncodingUTF8); 362 + name += QString::fromUtf8(vendor_buf) + " "; 363 + CFRelease(vendor_name_ref); 364 + } 365 + else { 366 + name += QObject::tr("(unknown vendor name) "); 367 + } 368 + 369 + /* get product name */ 370 + char product_buf[256]; 371 + CFIndex product_buflen = 256; 372 + CFTypeRef product_name_ref = NULL; 373 + 374 + product_name_ref = IORegistryEntrySearchCFProperty(usbCurrentObj, 375 + kIOServicePlane, CFSTR("USB Product Name"), 376 + kCFAllocatorDefault, 0); 377 + if(product_name_ref != NULL) { 378 + CFStringGetCString((CFStringRef)product_name_ref, product_buf, product_buflen, 379 + kCFStringEncodingUTF8); 380 + name += QString::fromUtf8(product_buf); 381 + CFRelease(product_name_ref); 382 + } 383 + else { 384 + name += QObject::tr("(unknown product name)"); 385 + } 386 + 387 + if(id) { 388 + usbids.insert(id, name); 389 + qDebug() << "[System] USB:" << QString("0x%1").arg(id, 8, 16) << name; 390 + } 391 + 392 + } 393 + IOObjectRelease(usb_iterator); 314 394 #endif 315 395 316 396 #if defined(Q_OS_WIN32)
+3 -3
rbutil/rbutilqt/rbutilqt.pro
··· 132 132 win32 { 133 133 LIBS += -lsetupapi -lnetapi32 134 134 } 135 - unix:!static:!libusb1 { 135 + unix:!static:!libusb1:!macx { 136 136 LIBS += -lusb 137 137 } 138 - unix:!static:libusb1 { 138 + unix:!static:libusb1:!macx { 139 139 DEFINES += LIBUSB1 140 140 LIBS += -lusb-1.0 141 141 } ··· 144 144 LIBS += -lz 145 145 } 146 146 147 - unix:static { 147 + unix:!macx:static { 148 148 # force statically linking of libusb. Libraries that are appended 149 149 # later will get linked dynamically again. 150 150 LIBS += -Wl,-Bstatic -lusb -Wl,-Bdynamic