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
This commit is contained in:
Sebastian Dröge 2016-11-10 15:17:50 +02:00
parent d88cee856e
commit acfa0e9045

View file

@ -105,6 +105,12 @@ typedef struct
NleUpdateStackReason reason; NleUpdateStackReason reason;
} UpdateCompositionData; } UpdateCompositionData;
typedef struct _Action
{
GCClosure closure;
gint priority;
} Action;
struct _NleCompositionPrivate struct _NleCompositionPrivate
{ {
gboolean dispose_has_run; gboolean dispose_has_run;
@ -161,6 +167,7 @@ struct _NleCompositionPrivate
GMutex actions_lock; GMutex actions_lock;
GCond actions_cond; GCond actions_cond;
GList *actions; GList *actions;
Action *current_action;
gboolean running; gboolean running;
gboolean initialized; gboolean initialized;
@ -181,12 +188,6 @@ struct _NleCompositionPrivate
NleUpdateStackReason updating_reason; NleUpdateStackReason updating_reason;
}; };
typedef struct _Action
{
GCClosure closure;
gint priority;
} Action;
#define ACTION_CALLBACK(__action) (((GCClosure*) (__action))->callback) #define ACTION_CALLBACK(__action) (((GCClosure*) (__action))->callback)
static guint _signals[LAST_SIGNAL] = { 0 }; static guint _signals[LAST_SIGNAL] = { 0 };
@ -379,14 +380,19 @@ _execute_actions (NleComposition * comp)
lact = g_list_first (priv->actions); lact = g_list_first (priv->actions);
priv->actions = g_list_remove_link (priv->actions, lact); priv->actions = g_list_remove_link (priv->actions, lact);
priv->current_action = lact->data;
ACTIONS_UNLOCK (comp); ACTIONS_UNLOCK (comp);
GST_INFO_OBJECT (comp, "Invoking %p:%s", GST_INFO_OBJECT (comp, "Invoking %p:%s",
lact->data, GST_DEBUG_FUNCPTR_NAME ((ACTION_CALLBACK (lact->data)))); lact->data, GST_DEBUG_FUNCPTR_NAME ((ACTION_CALLBACK (lact->data))));
g_closure_invoke (lact->data, NULL, 1, params, NULL); g_closure_invoke (lact->data, NULL, 1, params, NULL);
g_value_unset (&params[0]); g_value_unset (&params[0]);
ACTIONS_LOCK (comp);
g_closure_unref (lact->data); g_closure_unref (lact->data);
g_list_free (lact); g_list_free (lact);
priv->current_action = NULL;
ACTIONS_UNLOCK (comp);
GST_LOG_OBJECT (comp, "remaining actions [%d]", GST_LOG_OBJECT (comp, "remaining actions [%d]",
g_list_length (priv->actions)); 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"); GST_DEBUG_OBJECT (comp, "Adding Action");