MCPcopy Create free account
hub / github.com/bulletphysics/bullet3 / getDeviceInfo

Method getDeviceInfo

examples/TinyAudio/RtAudio.cpp:617–876  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

615}
616
617RtAudio::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());

Callers

nothing calls this directly

Calls 15

errorFunction · 0.85
getAsioErrorStringFunction · 0.85
getErrorStringFunction · 0.85
strMethod · 0.80
c_strMethod · 0.80
GetValueMethod · 0.80
sortFunction · 0.50
eraseMethod · 0.45
appendMethod · 0.45
clearMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected