Replies: 1 comment 1 reply
-
Being hidden means is will not show up in that list. You need to get the AudioObjectID via https://developer.apple.com/documentation/coreaudio/kaudiohardwarepropertytranslateuidtodevice
Devin
…On Nov 19, 2023 at 9:11 PM -1000, dttlgotv ***@***.***>, wrote:
I just used the newest blackhole release to test. The device 2 is hided, but I want to used the device 2 input. It is not luck that it can not be found in the code below.
GetNumberDevices(AudioDeviceID scopedDeviceIds[], const uint32_t deviceListLength)
{
UInt32 size = 0;
OSStatus err = noErr;
AudioObjectPropertyAddress propertyAddress = {kAudioHardwarePropertyDevices, kAudioObjectPropertyScopeGlobal, kAudioObjectPropertyElementMaster };
err = AudioObjectGetPropertyDataSize(kAudioObjectSystemObject, &propertyAddress, 0, NULL, &size);
if (noErr != err){
return 0;
}
if (size == 0)
{
return 0;
}
AudioDeviceID* deviceIds = (AudioDeviceID*)malloc(size);
UInt32 numberDevices = size / sizeof(AudioDeviceID);
AudioBufferList* bufferList = NULL;
UInt32 numberScopedDevices = 0;
// Then list the rest of the devices
bool listOK = true;
err = AudioObjectGetPropertyData(kAudioObjectSystemObject, &propertyAddress, 0, NULL, &size, deviceIds);
if (err != noErr){
listOK = false;
}
else
{
propertyAddress.mSelector = kAudioDevicePropertyStreamConfiguration;
propertyAddress.mScope = kAudioDevicePropertyScopeInput;
propertyAddress.mElement = 0;
for (UInt32 i = 0; i < numberDevices; i++)
{
// Check for input channels
err = AudioObjectGetPropertyDataSize(deviceIds[i], &propertyAddress, 0, NULL, &size);
if (err == kAudioHardwareBadDeviceError)
{
// This device doesn't actually exist; continue iterating.
qInfo() << "audio:err kAudioHardwareBadDeviceError";
continue;
}
else if (err != noErr)
{
qInfo() << "audio:err GetNumberDevices failed, err is" << err;
listOK = false;
break;
}
bufferList = (AudioBufferList*)malloc(size);
err = AudioObjectGetPropertyData(deviceIds[i], &propertyAddress, 0, NULL, &size, bufferList);
if (err != noErr)
{
qInfo() << "audio:err GetNumberDevices AudioObjectGetPropertyData failed, err is" << err;
listOK = false;
break;
}
if (bufferList->mNumberBuffers > 0)
{
if (numberScopedDevices >= deviceListLength)
{
qWarning("audio:cap Device list is not long enough");
listOK = false;
break;
}
scopedDeviceIds[numberScopedDevices] = deviceIds[i];
numberScopedDevices++;
}
free(bufferList);
bufferList = NULL;
} // for
}
if (!listOK){
if (deviceIds){
free(deviceIds);
deviceIds = NULL;
}
if (bufferList) {
free(bufferList);
bufferList = NULL;
}
return 0;
}
// Happy ending
if (deviceIds){
free(deviceIds);
deviceIds = NULL;
}
return numberScopedDevices;
}
After calling the funcion, the hided input device 2 is not be got.
Please help me to know How I can use the hided input device. Thanks a lot.
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I just used the newest blackhole release to test. The device 2 is hided, but I want to used the device 2 input. It is not luck that it can not be found in the code below.
GetNumberDevices(AudioDeviceID scopedDeviceIds[], const uint32_t deviceListLength)
{
UInt32 size = 0;
OSStatus err = noErr;
AudioObjectPropertyAddress propertyAddress = {kAudioHardwarePropertyDevices, kAudioObjectPropertyScopeGlobal, kAudioObjectPropertyElementMaster };
err = AudioObjectGetPropertyDataSize(kAudioObjectSystemObject, &propertyAddress, 0, NULL, &size);
if (noErr != err){
return 0;
}
}
After calling the funcion, the hided input device 2 is not be got.
Please help me to know How I can use the hided input device. Thanks a lot.
Beta Was this translation helpful? Give feedback.
All reactions