From 48872dbc56455498012432ef00679dbcb3482e55 Mon Sep 17 00:00:00 2001 From: Arun Raghavan Date: Mon, 1 Dec 2014 19:29:57 +0530 Subject: [PATCH] osxaudio: Bind audio device to audio unit early We want to bind the device during open so that subsequent format queries on the audio unit are as specific as possible from that point onwards. https://bugzilla.gnome.org/show_bug.cgi?id=740987 --- sys/osxaudio/gstosxcoreaudiohal.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/sys/osxaudio/gstosxcoreaudiohal.c b/sys/osxaudio/gstosxcoreaudiohal.c index 4c2eb490f3..925355ac51 100644 --- a/sys/osxaudio/gstosxcoreaudiohal.c +++ b/sys/osxaudio/gstosxcoreaudiohal.c @@ -1007,6 +1007,8 @@ _io_proc_spdif_stop (GstCoreAudio * core_audio) static gboolean gst_core_audio_open_impl (GstCoreAudio * core_audio) { + gboolean ret; + /* The following is needed to instruct HAL to create their own * thread to handle the notifications. */ _audio_system_set_runloop (NULL); @@ -1021,8 +1023,21 @@ gst_core_audio_open_impl (GstCoreAudio * core_audio) * we will do input with it. * http://developer.apple.com/technotes/tn2002/tn2091.html */ - return gst_core_audio_open_device (core_audio, kAudioUnitSubType_HALOutput, + ret = gst_core_audio_open_device (core_audio, kAudioUnitSubType_HALOutput, "HALOutput"); + if (!ret) { + GST_DEBUG ("Could not open device"); + goto done; + } + + ret = gst_core_audio_bind_device (core_audio); + if (!ret) { + GST_DEBUG ("Could not bind device"); + goto done; + } + +done: + return ret; } static gboolean @@ -1124,9 +1139,6 @@ gst_core_audio_initialize_impl (GstCoreAudio * core_audio, format.mChannelsPerFrame, caps)) goto done; - if (!gst_core_audio_bind_device (core_audio)) - goto done; - if (core_audio->is_src) { propertySize = sizeof (*frame_size); status = AudioUnitGetProperty (core_audio->audiounit, kAudioDevicePropertyBufferFrameSize, kAudioUnitScope_Global, 0, /* N/A for global */