nlecomposition: Add stack initialization action after setting our state

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>
This commit is contained in:
Thibault Saunier 2020-05-14 00:56:40 -04:00 committed by GStreamer Merge Bot
parent 56544604bc
commit b79e5e3508

View 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);