From 49489d35aea931cea5e20a9afddfad4d4276931c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Brzezi=C5=84ski?= Date: Fri, 8 Nov 2024 11:57:49 +0100 Subject: [PATCH] osxaudio: Fix AudioOutputUnitStart() deadlock on iOS >=17 At some point in iOS 17, this call started waiting for the first render callback (io_proc) to finish. In our case, that callback also takes the ringbuf object lock by calling gst_audio_ring_buffer_set_timestamp(), which results in a deadlock. Part-of: --- .../gst-plugins-good/sys/osxaudio/gstosxcoreaudiocommon.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/subprojects/gst-plugins-good/sys/osxaudio/gstosxcoreaudiocommon.c b/subprojects/gst-plugins-good/sys/osxaudio/gstosxcoreaudiocommon.c index bec30f23c5..d520e514ef 100644 --- a/subprojects/gst-plugins-good/sys/osxaudio/gstosxcoreaudiocommon.c +++ b/subprojects/gst-plugins-good/sys/osxaudio/gstosxcoreaudiocommon.c @@ -122,7 +122,11 @@ gst_core_audio_io_proc_start (GstCoreAudio * core_audio) core_audio->io_proc_needs_deactivation = FALSE; + // AudioOutputUnitStart on iOS can wait for the render callback to finish, + // where in our case we set the ringbuffer timestamp, which also needs the ringbuf lock. + GST_OBJECT_UNLOCK (core_audio->osxbuf); status = AudioOutputUnitStart (core_audio->audiounit); + GST_OBJECT_LOCK (core_audio->osxbuf); if (status) { GST_ERROR_OBJECT (core_audio->osxbuf, "AudioOutputUnitStart failed: %d", (int) status);