From 55a4129947738f9381a11266cff4fc57ff68ea93 Mon Sep 17 00:00:00 2001 From: Edward Hervey Date: Fri, 11 Dec 2020 10:13:59 +0100 Subject: [PATCH] decodebin3: Release selection lock when pushing EOS We can't keep the lock otherwise this would lock other actions. In order to keep it safe, we grab a list of peer pads to send EOS to with the lock taken, then send to the peer pads with the lock released. Also make sure the selection lock is taken for another call to this function Fixes https://gitlab.freedesktop.org/gstreamer/gst-plugins-base/-/issues/847 Change-Id: I8c811ff53b77ed62b79a3e90f1f4dab616f02e36 Part-of: --- gst/playback/gstdecodebin3-parse.c | 33 +++++++++++++++++++++++++++++++++ packaging/gst-plugins-base.spec | 1 + 2 files changed, 34 insertions(+) diff --git a/gst/playback/gstdecodebin3-parse.c b/gst/playback/gstdecodebin3-parse.c index aea0f66..edd11f2 100644 --- a/gst/playback/gstdecodebin3-parse.c +++ b/gst/playback/gstdecodebin3-parse.c @@ -120,15 +120,41 @@ static void check_all_streams_for_eos (GstDecodebin3 * dbin) { GList *tmp; +#ifdef TIZEN_FEATURE_UPSTREAM + GList *outputpads = NULL; +#endif if (!all_inputs_are_eos (dbin)) return; /* We know all streams are EOS, properly clean up everything */ + + /* We grab all peer pads *while* the selection lock is taken and then we will + push EOS downstream with the selection lock released */ for (tmp = dbin->input_streams; tmp; tmp = tmp->next) { DecodebinInputStream *input = (DecodebinInputStream *) tmp->data; GstPad *peer = gst_pad_get_peer (input->srcpad); +#ifdef TIZEN_FEATURE_UPSTREAM + /* Keep a reference to the peer pad */ + if (peer) + outputpads = g_list_append (outputpads, peer); + } + + SELECTION_UNLOCK (dbin); + /* */ + for (tmp = outputpads; tmp; tmp = tmp->next) { + GstPad *peer = (GstPad *) tmp->data; + + /* Send EOS and then remove elements */ + gst_pad_send_event (peer, gst_event_new_eos ()); + GST_FIXME_OBJECT (peer, "Remove input stream"); + gst_object_unref (peer); + } + SELECTION_LOCK (dbin); + + g_list_free (outputpads); +#else /* Send EOS and then remove elements */ if (peer) { gst_pad_send_event (peer, gst_event_new_eos ()); @@ -136,6 +162,7 @@ check_all_streams_for_eos (GstDecodebin3 * dbin) } GST_FIXME_OBJECT (input->srcpad, "Remove input stream"); } +#endif } /* Get the intersection of parser caps and available (sorted) decoders */ @@ -527,7 +554,13 @@ parsebin_pending_event_probe (GstPad * pad, GstPadProbeInfo * info, gst_pad_remove_probe (ppad->pad, ppad->event_probe); g_free (ppad); +#ifdef TIZEN_FEATURE_UPSTREAM + SELECTION_LOCK (dbin); +#endif check_all_streams_for_eos (dbin); +#ifdef TIZEN_FEATURE_UPSTREAM + SELECTION_UNLOCK (dbin); +#endif } break; default: diff --git a/packaging/gst-plugins-base.spec b/packaging/gst-plugins-base.spec index 85a0a61..2042a68 100644 --- a/packaging/gst-plugins-base.spec +++ b/packaging/gst-plugins-base.spec @@ -102,6 +102,7 @@ export CFLAGS="%{optflags} -fno-strict-aliasing\ %else -DTIZEN_FEATURE_RESOURCE_MANAGER\ %endif + -DTIZEN_FEATURE_UPSTREAM\ -fstack-protector-strong\ -Wl,-z,relro\ -D_FORTIFY_SOURCE=2\ -- 2.7.4