From 77e5a71a1538e747b30c40b8b83cb2be42b02161 Mon Sep 17 00:00:00 2001 From: Edward Hervey Date: Tue, 14 Nov 2017 13:34:48 +0100 Subject: [PATCH] decodebin2: Don't take locks when deactivating pads When deactivating pads, we need to ensure that the streaming threads going through the pads we wish to deactivate can cleanly return. Failure to do that would result in the streaming locks of those pads never being released. The end result would be a deadlock when stopping decodebin2. In order to avoid that situation, release the "dyn" lock around the deactivation code. And refactor the code to cope with the list of blocked pads having potentially changed when re-acquiring the lock. --- gst/playback/gstdecodebin2.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/gst/playback/gstdecodebin2.c b/gst/playback/gstdecodebin2.c index 6e4a167..2ac51f8 100644 --- a/gst/playback/gstdecodebin2.c +++ b/gst/playback/gstdecodebin2.c @@ -5211,14 +5211,14 @@ find_sink_pad (GstElement * element) static void unblock_pads (GstDecodeBin * dbin) { - GList *tmp; - GST_LOG_OBJECT (dbin, "unblocking pads"); - for (tmp = dbin->blocked_pads; tmp; tmp = tmp->next) { + while (dbin->blocked_pads) { + GList *tmp = dbin->blocked_pads; GstDecodePad *dpad = (GstDecodePad *) tmp->data; GstPad *opad; + dbin->blocked_pads = g_list_delete_link (dbin->blocked_pads, tmp); opad = gst_ghost_pad_get_target (GST_GHOST_PAD_CAST (dpad)); if (opad) { @@ -5231,15 +5231,17 @@ unblock_pads (GstDecodeBin * dbin) } dpad->blocked = FALSE; + + /* We release the dyn lock since we want to allow the streaming threads + * to properly stop and not be blocked in our various probes */ + DYN_UNLOCK (dbin); /* make flushing, prevent NOT_LINKED */ gst_pad_set_active (GST_PAD_CAST (dpad), FALSE); - gst_object_unref (dpad); + DYN_LOCK (dbin); + GST_DEBUG_OBJECT (dpad, "unblocked"); + gst_object_unref (dpad); } - - /* clear, no more blocked pads */ - g_list_free (dbin->blocked_pads); - dbin->blocked_pads = NULL; } static void -- 2.7.4