From acfa0e9045c052535447b7bd4403d87178171e6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Thu, 10 Nov 2016 15:17:50 +0200 Subject: [PATCH] nlecomposition: Fix small remaining race in previous commit The seek action might currently be handled (in which case it is not in the actions list and the action lock is not locked), but not actually handled completely yet (the seqnum is not stored yet). To prevent this, we remember what the current action is that is being handled, and also compare to that. https://bugzilla.gnome.org/show_bug.cgi?id=774149 --- plugins/nle/nlecomposition.c | 32 ++++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/plugins/nle/nlecomposition.c b/plugins/nle/nlecomposition.c index b817876a03..67027b9582 100644 --- a/plugins/nle/nlecomposition.c +++ b/plugins/nle/nlecomposition.c @@ -105,6 +105,12 @@ typedef struct NleUpdateStackReason reason; } UpdateCompositionData; +typedef struct _Action +{ + GCClosure closure; + gint priority; +} Action; + struct _NleCompositionPrivate { gboolean dispose_has_run; @@ -161,6 +167,7 @@ struct _NleCompositionPrivate GMutex actions_lock; GCond actions_cond; GList *actions; + Action *current_action; gboolean running; gboolean initialized; @@ -181,12 +188,6 @@ struct _NleCompositionPrivate NleUpdateStackReason updating_reason; }; -typedef struct _Action -{ - GCClosure closure; - gint priority; -} Action; - #define ACTION_CALLBACK(__action) (((GCClosure*) (__action))->callback) static guint _signals[LAST_SIGNAL] = { 0 }; @@ -379,14 +380,19 @@ _execute_actions (NleComposition * comp) lact = g_list_first (priv->actions); priv->actions = g_list_remove_link (priv->actions, lact); + priv->current_action = lact->data; ACTIONS_UNLOCK (comp); GST_INFO_OBJECT (comp, "Invoking %p:%s", lact->data, GST_DEBUG_FUNCPTR_NAME ((ACTION_CALLBACK (lact->data)))); g_closure_invoke (lact->data, NULL, 1, params, NULL); g_value_unset (¶ms[0]); + + ACTIONS_LOCK (comp); g_closure_unref (lact->data); g_list_free (lact); + priv->current_action = NULL; + ACTIONS_UNLOCK (comp); GST_LOG_OBJECT (comp, "remaining actions [%d]", g_list_length (priv->actions)); @@ -852,6 +858,20 @@ _add_seek_action (NleComposition * comp, GstEvent * event) } } + /* Check if this seqnum is currently being handled */ + if (comp->priv->current_action) { + Action *act = comp->priv->current_action; + if (ACTION_CALLBACK (act) == G_CALLBACK (_seek_pipeline_func)) { + SeekData *tmp_data = ((GClosure *) act)->data; + + if (gst_event_get_seqnum (tmp_data->event) == seqnum) { + GST_DEBUG_OBJECT (comp, + "Not adding Action, same seqnum as previous seek"); + ACTIONS_UNLOCK (comp); + return; + } + } + } GST_DEBUG_OBJECT (comp, "Adding Action");