From caa5972abdee9bde2dc6dfe205aa83a8c8c66324 Mon Sep 17 00:00:00 2001 From: Ignacio Casal Quinteiro Date: Wed, 30 Mar 2022 12:59:46 +0200 Subject: [PATCH] osxaudio: support hidden devices macOS features hidden devices. These are devices that will not be shown in the macOS UIs and that cannot be retrieved without having the specific UID of the hidden device. There are cases when you might want to have a hidden device, for example when having a virtual speaker that forwards the data to a virtual hidden input device from which you can then grab the audio. The blackhole project supports these hidden devices and this patch provides a way that if the device id is a hidden device it will use it instead of check the hardware list of devices to understand if the device is valid. Part-of: --- .../sys/osxaudio/gstosxcoreaudiohal.c | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/subprojects/gst-plugins-good/sys/osxaudio/gstosxcoreaudiohal.c b/subprojects/gst-plugins-good/sys/osxaudio/gstosxcoreaudiohal.c index 3ce2fff8c1..b7f50a49c6 100644 --- a/subprojects/gst-plugins-good/sys/osxaudio/gstosxcoreaudiohal.c +++ b/subprojects/gst-plugins-good/sys/osxaudio/gstosxcoreaudiohal.c @@ -138,6 +138,25 @@ _audio_device_is_alive (AudioDeviceID device_id, gboolean output) return alive; } +static inline gboolean +_audio_device_is_hidden (AudioDeviceID device_id) +{ + OSStatus status = noErr; + UInt32 hidden = FALSE; + UInt32 property_size = sizeof (hidden); + AudioObjectPropertyAddress property_address; + + property_address.mSelector = kAudioDevicePropertyIsHidden; + + status = AudioObjectGetPropertyData (device_id, + &property_address, 0, NULL, &property_size, &hidden); + if (status != noErr) { + return FALSE; + } + + return hidden; +} + static inline guint _audio_device_get_latency (AudioDeviceID device_id) { @@ -1202,6 +1221,13 @@ gst_core_audio_select_device_impl (GstCoreAudio * core_audio) GST_ERROR ("No device of required type available"); res = FALSE; } + } else if (_audio_device_is_hidden (device_id)) { + if (_audio_device_is_alive (device_id, output)) { + res = TRUE; + } else { + GST_ERROR ("Requested hidden device not usable"); + res = FALSE; + } } else { AudioDeviceID *devices = NULL; gint i, ndevices = 0;