From 0a17bfc2bed9c61e53dfa8c90f0bf91fe5b05d27 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Olivier=20Cr=C3=AAte?= Date: Fri, 24 Jul 2015 16:19:46 -0400 Subject: [PATCH] scenario: Only modify the actions from the main thread The action's content is not protected by a mutex, so only modify it from the main thread. --- validate/gst/validate/gst-validate-scenario.c | 52 +++++++++++++-------------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/validate/gst/validate/gst-validate-scenario.c b/validate/gst/validate/gst-validate-scenario.c index 35ac71c..513cae9 100644 --- a/validate/gst/validate/gst-validate-scenario.c +++ b/validate/gst/validate/gst-validate-scenario.c @@ -2896,6 +2896,21 @@ done: return res; } +static gboolean +_action_set_done (GstValidateAction * action) +{ + if (action->scenario == NULL) + return G_SOURCE_REMOVE; + + action->priv->state = _execute_sub_action_action (action); + if (action->priv->state != GST_VALIDATE_EXECUTE_ACTION_ASYNC) { + GST_DEBUG_OBJECT (action->scenario, "Sub action executed ASYNC"); + + execute_next_action (action->scenario); + } + return G_SOURCE_REMOVE; +} + void gst_validate_action_set_done (GstValidateAction * action) { @@ -2903,38 +2918,23 @@ gst_validate_action_set_done (GstValidateAction * action) if (action->priv->state == GST_VALIDATE_EXECUTE_ACTION_INTERLACED) { - if (action->scenario) { - SCENARIO_LOCK (action->scenario); - action->scenario->priv->interlaced_actions = - g_list_remove (action->scenario->priv->interlaced_actions, action); - SCENARIO_UNLOCK (action->scenario); + if (scenario) { + SCENARIO_LOCK (scenario); + scenario->priv->interlaced_actions = + g_list_remove (scenario->priv->interlaced_actions, action); + SCENARIO_UNLOCK (scenario); } gst_validate_action_unref (action); } - action->priv->state = _execute_sub_action_action (action); - if (action->priv->state == GST_VALIDATE_EXECUTE_ACTION_ASYNC) { - GST_DEBUG_OBJECT (scenario, "Sub action executed ASYNC"); - - return; - } - - if (scenario) { - if (GPOINTER_TO_INT (g_private_get (&main_thread_priv))) { - if (!scenario->priv->execute_on_idle) { - GST_DEBUG_OBJECT (scenario, "Right thread, executing next?"); - execute_next_action (scenario); - - return; - } else - GST_DEBUG_OBJECT (scenario, "Right thread, but executing only on idle"); - } else - GST_DEBUG_OBJECT (action->scenario, "Not doing anything outside the" - " 'main' thread"); + if (GPOINTER_TO_INT (g_private_get (&main_thread_priv))) { + _action_set_done (action); + } else { + g_idle_add_full (G_PRIORITY_DEFAULT_IDLE, (GSourceFunc) _action_set_done, + gst_mini_object_ref (GST_MINI_OBJECT (action)), + (GDestroyNotify) gst_validate_action_unref); } - - _add_execute_actions_gsource (scenario); } /** -- 2.7.4