From fd10d69bc5890ccd87d4533c40c8cad95d6a6585 Mon Sep 17 00:00:00 2001 From: Seungha Yang Date: Wed, 9 Jan 2019 16:23:54 +0900 Subject: [PATCH] nlecomposition: Handle state change failure Whatever the reason for failure, try cleanup child elements and internal thread. --- plugins/nle/nlecomposition.c | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/plugins/nle/nlecomposition.c b/plugins/nle/nlecomposition.c index 9cb5540..75d9151 100644 --- a/plugins/nle/nlecomposition.c +++ b/plugins/nle/nlecomposition.c @@ -2455,6 +2455,20 @@ nle_composition_change_state (GstElement * element, GstStateChange transition) res = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition); + if (res == GST_STATE_CHANGE_FAILURE) { + GST_ERROR_OBJECT (comp, "state change failure %s => %s", + gst_element_state_get_name (GST_STATE_TRANSITION_CURRENT (transition)), + gst_element_state_get_name (GST_STATE_TRANSITION_NEXT (transition))); + + comp->priv->tearing_down_stack = TRUE; + _stop_task (comp); + nle_composition_reset (comp); + gst_element_set_state (comp->priv->current_bin, GST_STATE_NULL); + comp->priv->tearing_down_stack = FALSE; + + return res; + } + switch (transition) { case GST_STATE_CHANGE_PAUSED_TO_READY: comp->priv->tearing_down_stack = FALSE; @@ -2877,9 +2891,17 @@ _activate_new_stack (NleComposition * comp) GST_DEBUG_OBJECT (comp, "New stack activated!"); resync_state: - gst_element_set_locked_state (priv->current_bin, FALSE); + if (!gst_element_set_locked_state (priv->current_bin, FALSE)) { + GST_ERROR_OBJECT (comp, "set locked state failure"); + return FALSE; + } + GST_DEBUG ("going back to parent state"); - gst_element_sync_state_with_parent (priv->current_bin); + if (!gst_element_sync_state_with_parent (priv->current_bin)) { + GST_ERROR_OBJECT (comp, "Cannot sync current stack's state"); + return FALSE; + } + GST_DEBUG ("gone back to parent state"); return TRUE; -- 2.7.4