osxaudiosrc/osaudiosink uses non-unique identifiers as device ID
Submitted by Marcin Lewandowski
Link to original bug (#759558)
Description
It seems that current version of osxaudiosrc/osxaudiosink handles "device" parameter in a way that may be ambiguous in some setups.
It expects that device ID that is passed is a numeric ID, such as obtained by running "say -a ?". This is however, inaccurate, as such device ID is not Core Audio UNIQUE identifier.
In some setups that's fine, for instance my setup is like that
$ say -a ?
50 Built-in Output
60 Z-10 USB Speaker
However, depending to which USB port I plug my USB Speaker I get this UID from CoreAudio:
AppleUSBAudioEngine:Logitech:Z-10 USB Speaker:fd120000:1
or this
AppleUSBAudioEngine:Logitech:Z-10 USB Speaker:fa130000:1
(this is the code used to query)
CFStringRef uid;
propertySize = sizeof(uid);
deviceAddress.mSelector = kAudioDevicePropertyDeviceUID;
deviceAddress.mScope = kAudioObjectPropertyScopeGlobal;
deviceAddress.mElement = kAudioObjectPropertyElementMaster;
if(AudioObjectGetPropertyData(deviceIDs[idx], &deviceAddress, 0, NULL, &propertySize, &uid) == noErr) {
...
}
In some setups, especially in pro audio/broadcasting environments it may be necessary to use very precise reference to avoid issues if two devices of the same type are plugged in.
To avoid API break, I suggest adding a boolean parameter "device-is-uid" that will indicate whether interpret "device" like now or with exact uid, or another string parameter "uid" that can be used in exchange of "device".
Version: 1.6.1