1

Background of the issue:

I get AudioDeviceID for default input mic this way:

OSStatus error = noErr;
AudioObjectPropertyAddress propertyAddress = {};
UInt32 propertySize;

/* get default device ID */
    AudioDeviceID deviceID = 0;
    propertyAddress.mSelector = kAudioHardwarePropertyDevices;
    propertyAddress.mScope = kAudioObjectPropertyScopeGlobal;
    propertyAddress.mElement = kAudioObjectPropertyElementMaster;
    propertySize = sizeof(AudioDeviceID);
    error = AudioHardwareServiceGetPropertyData(kAudioObjectSystemObject,
                                                &propertyAddress, 0,
                                                NULL, &propertySize, &deviceID);
    if(!error)
        ... // we get some AudioDeviceID, let it be ID_1

And get AudioDeviceID for UID is:

CFStringRef micUID = ... //my UID for the mic
CFStringRef *inDeviceUID = &micUID;
AudioObjectPropertyAddress proprtyAddress = {};
proprtyAddress.mSelector = kAudioHardwarePropertyDeviceForUID;
proprtyAddress.mScope = kAudioObjectPropertyScopeGlobal;
proprtyAddress.mElement = kAudioObjectPropertyElementMaster;
AudioValueTranslation translation = {};
translation.mInputData = inDeviceUID;
translation.mInputDataSize = sizeof(CFStringRef);
translation.mOutputData = outDeviceID;
translation.mOutputDataSize = sizeof(AudioDeviceID);
UInt32 inSize = sizeof(translation);
OSStatus result = AudioObjectGetPropertyData(kAudioObjectSystemObject,
                                             &proprtyAddress,
                                             0,
                                             nullptr,
                                             &inSize,
                                             &translation);

// if no error - we have another AudioDeviceID, let it be ID_2

The question is:

Why is ID_1 != ID_2?

It happens only when I connect two identical web-cameras to Mac. What's weird about it is that these mics have different UID.

And when I try to change some parameters, sampleRate for example, it doesn't work (I get kAudioHardwareUnknownPropertyError error).

For Built-in line input it work ok.

Mateusz Piotrowski
  • 8,029
  • 10
  • 53
  • 79

0 Answers0