| 615 | } |
| 616 | |
| 617 | RtAudio::DeviceInfo RtApiCore ::getDeviceInfo(unsigned int device) |
| 618 | { |
| 619 | RtAudio::DeviceInfo info; |
| 620 | info.probed = false; |
| 621 | |
| 622 | // Get device ID |
| 623 | unsigned int nDevices = getDeviceCount(); |
| 624 | if (nDevices == 0) |
| 625 | { |
| 626 | errorText_ = "RtApiCore::getDeviceInfo: no devices found!"; |
| 627 | error(RtAudioError::INVALID_USE); |
| 628 | return info; |
| 629 | } |
| 630 | |
| 631 | if (device >= nDevices) |
| 632 | { |
| 633 | errorText_ = "RtApiCore::getDeviceInfo: device ID is invalid!"; |
| 634 | error(RtAudioError::INVALID_USE); |
| 635 | return info; |
| 636 | } |
| 637 | |
| 638 | AudioDeviceID deviceList[nDevices]; |
| 639 | UInt32 dataSize = sizeof(AudioDeviceID) * nDevices; |
| 640 | AudioObjectPropertyAddress property = {kAudioHardwarePropertyDevices, |
| 641 | kAudioObjectPropertyScopeGlobal, |
| 642 | kAudioObjectPropertyElementMaster}; |
| 643 | OSStatus result = AudioObjectGetPropertyData(kAudioObjectSystemObject, &property, |
| 644 | 0, NULL, &dataSize, (void *)&deviceList); |
| 645 | if (result != noErr) |
| 646 | { |
| 647 | errorText_ = "RtApiCore::getDeviceInfo: OS-X system error getting device IDs."; |
| 648 | error(RtAudioError::WARNING); |
| 649 | return info; |
| 650 | } |
| 651 | |
| 652 | AudioDeviceID id = deviceList[device]; |
| 653 | |
| 654 | // Get the device name. |
| 655 | info.name.erase(); |
| 656 | CFStringRef cfname; |
| 657 | dataSize = sizeof(CFStringRef); |
| 658 | property.mSelector = kAudioObjectPropertyManufacturer; |
| 659 | result = AudioObjectGetPropertyData(id, &property, 0, NULL, &dataSize, &cfname); |
| 660 | if (result != noErr) |
| 661 | { |
| 662 | errorStream_ << "RtApiCore::probeDeviceInfo: system error (" << getErrorCode(result) << ") getting device manufacturer."; |
| 663 | errorText_ = errorStream_.str(); |
| 664 | error(RtAudioError::WARNING); |
| 665 | return info; |
| 666 | } |
| 667 | |
| 668 | //const char *mname = CFStringGetCStringPtr( cfname, CFStringGetSystemEncoding() ); |
| 669 | int length = CFStringGetLength(cfname); |
| 670 | char *mname = (char *)malloc(length * 3 + 1); |
| 671 | #if defined(UNICODE) || defined(_UNICODE) |
| 672 | CFStringGetCString(cfname, mname, length * 3 + 1, kCFStringEncodingUTF8); |
| 673 | #else |
| 674 | CFStringGetCString(cfname, mname, length * 3 + 1, CFStringGetSystemEncoding()); |
nothing calls this directly
no test coverage detected