nlecomposition: Add stack initialization action after setting our state
authorThibault Saunier <tsaunier@igalia.com>
Thu, 14 May 2020 04:56:40 +0000 (00:56 -0400)
committerGStreamer Merge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Tue, 19 May 2020 13:27:13 +0000 (13:27 +0000)
Otherwise there is a pretty rare race where we get the
_initialize_stack_func executed leading to the stack set up and
the source pushing buffers before the composition source pad is
activated, and a STREAM_ERROR is reported as we end up pushing a
buffer to a flushing pad.

Thanks rr chaos mode for showing that improbable race

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-editing-services/-/merge_requests/175>

plugins/nle/nlecomposition.c

index a136a99..000acf1 100644 (file)
@@ -2637,14 +2637,6 @@ nle_composition_change_state (GstElement * element, GstStateChange transition)
       _set_all_children_state (comp, GST_STATE_READY);
       _start_task (comp);
       break;
-    case GST_STATE_CHANGE_READY_TO_PAUSED:
-      /* state-lock all elements */
-      GST_DEBUG_OBJECT (comp,
-          "Setting all children to READY and locking their state");
-
-      _add_update_compo_action (comp, G_CALLBACK (_initialize_stack_func),
-          COMP_UPDATE_STACK_INITIALIZE);
-      break;
     case GST_STATE_CHANGE_PAUSED_TO_READY:
       _stop_task (comp);
 
@@ -2682,6 +2674,14 @@ nle_composition_change_state (GstElement * element, GstStateChange transition)
   }
 
   switch (transition) {
+    case GST_STATE_CHANGE_READY_TO_PAUSED:
+      /* state-lock all elements */
+      GST_DEBUG_OBJECT (comp,
+          "Setting all children to READY and locking their state");
+
+      _add_update_compo_action (comp, G_CALLBACK (_initialize_stack_func),
+          COMP_UPDATE_STACK_INITIALIZE);
+      break;
     case GST_STATE_CHANGE_PAUSED_TO_READY:
       comp->priv->tearing_down_stack = FALSE;
       nle_composition_reset (comp);