| 691 | } |
| 692 | |
| 693 | RtAudio::DeviceInfo RtApiCore ::getDeviceInfo(unsigned int device) |
| 694 | { |
| 695 | RtAudio::DeviceInfo info; |
| 696 | info.probed = false; |
| 697 | |
| 698 | // Get device ID |
| 699 | unsigned int nDevices = getDeviceCount(); |
| 700 | if (nDevices == 0) |
| 701 | { |
| 702 | errorText_ = "RtApiCore::getDeviceInfo: no devices found!"; |
| 703 | error(RtAudioError::INVALID_USE); |
| 704 | return info; |
| 705 | } |
| 706 | |
| 707 | if (device >= nDevices) |
| 708 | { |
| 709 | errorText_ = "RtApiCore::getDeviceInfo: device ID is invalid!"; |
| 710 | error(RtAudioError::INVALID_USE); |
| 711 | return info; |
| 712 | } |
| 713 | |
| 714 | AudioDeviceID deviceList[nDevices]; |
| 715 | UInt32 dataSize = sizeof(AudioDeviceID) * nDevices; |
| 716 | AudioObjectPropertyAddress property = {kAudioHardwarePropertyDevices, |
| 717 | kAudioObjectPropertyScopeGlobal, |
| 718 | kAudioObjectPropertyElementMaster}; |
| 719 | OSStatus result = AudioObjectGetPropertyData(kAudioObjectSystemObject, &property, |
| 720 | 0, NULL, &dataSize, (void *) &deviceList); |
| 721 | if (result != noErr) |
| 722 | { |
| 723 | errorText_ = "RtApiCore::getDeviceInfo: OS-X system error getting device IDs."; |
| 724 | error(RtAudioError::WARNING); |
| 725 | return info; |
| 726 | } |
| 727 | |
| 728 | AudioDeviceID id = deviceList[device]; |
| 729 | |
| 730 | // Get the device name. |
| 731 | info.name.erase(); |
| 732 | CFStringRef cfname; |
| 733 | dataSize = sizeof(CFStringRef); |
| 734 | property.mSelector = kAudioObjectPropertyManufacturer; |
| 735 | result = AudioObjectGetPropertyData(id, &property, 0, NULL, &dataSize, &cfname); |
| 736 | if (result != noErr) |
| 737 | { |
| 738 | errorStream_ << "RtApiCore::probeDeviceInfo: system error (" << getErrorCode(result) << ") getting device manufacturer."; |
| 739 | errorText_ = errorStream_.str(); |
| 740 | error(RtAudioError::WARNING); |
| 741 | return info; |
| 742 | } |
| 743 | |
| 744 | //const char *mname = CFStringGetCStringPtr( cfname, CFStringGetSystemEncoding() ); |
| 745 | int length = CFStringGetLength(cfname); |
| 746 | char * mname = (char *) malloc(length * 3 + 1); |
| 747 | #if defined(UNICODE) || defined(_UNICODE) |
| 748 | CFStringGetCString(cfname, mname, length * 3 + 1, kCFStringEncodingUTF8); |
| 749 | #else |
| 750 | CFStringGetCString(cfname, mname, length * 3 + 1, CFStringGetSystemEncoding()); |
nothing calls this directly
no test coverage detected