GNOME Bugzilla – Bug 759558
osxaudiosrc/osaudiosink uses non-unique identifiers as device ID
Last modified: 2018-11-03 15:06:47 UTC
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".
Moreover, this can be more dangerous. If I unplug my Z-10 USB Speakers and plug something else, the same ID gets allocated by totally another device. $ say -a ? 50 Built-in Output 60 Sennheiser USB Headset So I you build let's say, a DAW that should remember it's audio interface routing setup (it's painful to rebuild it every time) and be smart enough that if user plugs a device during runtime it is capable of recognizing it, now you can a) store IDs in the routing configuration but you can never be sure if they mean the same soundcard as was used before b) rely on device names both options are unreliable. Moreover if I plug two of these three devices, then unplug one of them, ID of them can change in the runtime! (plug Sennheiser USB) $ say -a ? 50 Built-in Output 60 Sennheiser USB Headset (plug Z-10 USB Speaker) $ say -a ? 50 Built-in Output 68 Z-10 USB Speaker 60 Sennheiser USB Headset (unplug Sennheiser USB) $ say -a ? 50 Built-in Output 60 Z-10 USB Speaker
My idea would be to just add a device-uid property additionally (that is of type string). And whenever that is set to non-NULL it would be used instead of the (integer typed!) device property. We can't really change the type of the existing property at this point, but we could deprecate the old property to make people aware of it being a bit suboptimal.
Sounds perfect!
Created attachment 330871 [details] [review] WIP: Add device-uid property This is work in progress but comments are already welcome.
-- GitLab Migration Automatic Message -- This bug has been migrated to freedesktop.org's GitLab instance and has been closed from further activity. You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/issues/247.