decodebin3: Release selection lock when pushing EOS 36/255836/3 accepted/tizen/unified/20210407.100555 submit/tizen/20210324.231443 submit/tizen/20210405.012807
authorEdward Hervey <edward@centricular.com>
Fri, 11 Dec 2020 09:13:59 +0000 (10:13 +0100)
committerGilbok Lee <gilbok.lee@samsung.com>
Wed, 24 Mar 2021 07:19:52 +0000 (16:19 +0900)
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: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-base/-/merge_requests/971>

gst/playback/gstdecodebin3-parse.c
packaging/gst-plugins-base.spec

index aea0f66..edd11f2 100644 (file)
@@ -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:
index 85a0a61..2042a68 100644 (file)
@@ -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\