mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-18 20:25:25 +00:00
composition: Keep our GSources in a list making their thread safe
Co-Authored by: Thibault Saunier <tsaunier@gnome.org>
This commit is contained in:
parent
c022765529
commit
c256fd1486
1 changed files with 39 additions and 34 deletions
|
@ -160,6 +160,7 @@ struct _GnlCompositionPrivate
|
||||||
* we can not add any source, avoiding:
|
* we can not add any source, avoiding:
|
||||||
* "g_source_attach: assertion '!SOURCE_DESTROYED (source)' failed" */
|
* "g_source_attach: assertion '!SOURCE_DESTROYED (source)' failed" */
|
||||||
GMutex mcontext_lock;
|
GMutex mcontext_lock;
|
||||||
|
GList *gsources;
|
||||||
|
|
||||||
gboolean reset_time;
|
gboolean reset_time;
|
||||||
|
|
||||||
|
@ -427,6 +428,13 @@ join_failed:
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_free_seek_data (SeekData * seekd)
|
||||||
|
{
|
||||||
|
gst_event_unref (seekd->event);
|
||||||
|
g_slice_free (SeekData, seekd);
|
||||||
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
_seek_pipeline_func (SeekData * seekd)
|
_seek_pipeline_func (SeekData * seekd)
|
||||||
{
|
{
|
||||||
|
@ -480,23 +488,32 @@ _seek_pipeline_func (SeekData * seekd)
|
||||||
priv->reset_time = FALSE;
|
priv->reset_time = FALSE;
|
||||||
|
|
||||||
beach:
|
beach:
|
||||||
gst_event_unref (seekd->event);
|
|
||||||
g_slice_free (SeekData, seekd);
|
|
||||||
|
|
||||||
return G_SOURCE_REMOVE;
|
return G_SOURCE_REMOVE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_add_gsource (GnlComposition * comp, GSourceFunc func,
|
||||||
|
gpointer data, GDestroyNotify destroy, gint priority)
|
||||||
|
{
|
||||||
|
GSource *source;
|
||||||
|
GnlCompositionPrivate *priv = comp->priv;
|
||||||
|
|
||||||
|
MAIN_CONTEXT_LOCK (comp);
|
||||||
|
source = g_idle_source_new ();
|
||||||
|
g_source_set_callback (source, func, data, destroy);
|
||||||
|
g_source_set_priority (source, priority);
|
||||||
|
priv->gsources = g_list_prepend (priv->gsources, source);
|
||||||
|
g_source_attach (source, priv->mcontext);
|
||||||
|
MAIN_CONTEXT_UNLOCK (comp);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_add_update_gsource (GnlComposition * comp)
|
_add_update_gsource (GnlComposition * comp)
|
||||||
{
|
{
|
||||||
GST_DEBUG_OBJECT (comp, "Adding GSource");
|
GST_DEBUG_OBJECT (comp, "Adding GSource");
|
||||||
|
|
||||||
MAIN_CONTEXT_LOCK (comp);
|
_add_gsource (comp, (GSourceFunc) update_pipeline_func, comp,
|
||||||
g_main_context_invoke (comp->priv->mcontext,
|
NULL, G_PRIORITY_DEFAULT);
|
||||||
(GSourceFunc) update_pipeline_func, comp);
|
|
||||||
MAIN_CONTEXT_UNLOCK (comp);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -504,10 +521,8 @@ _add_commit_gsource (GnlComposition * comp)
|
||||||
{
|
{
|
||||||
GST_DEBUG_OBJECT (comp, "Adding GSource");
|
GST_DEBUG_OBJECT (comp, "Adding GSource");
|
||||||
|
|
||||||
MAIN_CONTEXT_LOCK (comp);
|
_add_gsource (comp, (GSourceFunc) _commit_func, comp, NULL,
|
||||||
g_main_context_invoke (comp->priv->mcontext,
|
G_PRIORITY_DEFAULT);
|
||||||
(GSourceFunc) _commit_func, comp);
|
|
||||||
MAIN_CONTEXT_UNLOCK (comp);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -520,10 +535,8 @@ _add_seek_gsource (GnlComposition * comp, GstEvent * event)
|
||||||
seekd->comp = comp;
|
seekd->comp = comp;
|
||||||
seekd->event = event;
|
seekd->event = event;
|
||||||
|
|
||||||
MAIN_CONTEXT_LOCK (comp);
|
_add_gsource (comp, (GSourceFunc) _seek_pipeline_func, seekd,
|
||||||
g_main_context_invoke (comp->priv->mcontext,
|
(GDestroyNotify) _free_seek_data, G_PRIORITY_DEFAULT);
|
||||||
(GSourceFunc) _seek_pipeline_func, seekd);
|
|
||||||
MAIN_CONTEXT_UNLOCK (comp);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -552,10 +565,8 @@ _add_initialize_stack_gsource (GnlComposition * comp)
|
||||||
{
|
{
|
||||||
GST_DEBUG_OBJECT (comp, "Adding GSource");
|
GST_DEBUG_OBJECT (comp, "Adding GSource");
|
||||||
|
|
||||||
MAIN_CONTEXT_LOCK (comp);
|
_add_gsource (comp, (GSourceFunc) _initialize_stack_func, comp,
|
||||||
g_main_context_invoke (comp->priv->mcontext,
|
NULL, G_PRIORITY_DEFAULT);
|
||||||
(GSourceFunc) _initialize_stack_func, comp);
|
|
||||||
MAIN_CONTEXT_UNLOCK (comp);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -620,10 +631,8 @@ _add_remove_object_gsource (GnlComposition * comp, GnlObject * object)
|
||||||
childio->comp = comp;
|
childio->comp = comp;
|
||||||
childio->object = object;
|
childio->object = object;
|
||||||
|
|
||||||
MAIN_CONTEXT_LOCK (comp);
|
_add_gsource (comp, (GSourceFunc) _remove_object_func,
|
||||||
g_main_context_invoke_full (comp->priv->mcontext, G_PRIORITY_DEFAULT,
|
childio, _free_child_io_data, G_PRIORITY_DEFAULT);
|
||||||
(GSourceFunc) _remove_object_func, childio, _free_child_io_data);
|
|
||||||
MAIN_CONTEXT_UNLOCK (comp);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
|
@ -682,10 +691,8 @@ _add_add_object_gsource (GnlComposition * comp, GnlObject * object)
|
||||||
childio->comp = comp;
|
childio->comp = comp;
|
||||||
childio->object = object;
|
childio->object = object;
|
||||||
|
|
||||||
MAIN_CONTEXT_LOCK (comp);
|
_add_gsource (comp, (GSourceFunc) _add_object_func, childio,
|
||||||
g_main_context_invoke_full (comp->priv->mcontext, G_PRIORITY_DEFAULT,
|
_free_child_io_data, G_PRIORITY_DEFAULT);
|
||||||
(GSourceFunc) _add_object_func, childio, _free_child_io_data);
|
|
||||||
MAIN_CONTEXT_UNLOCK (comp);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
|
@ -2195,10 +2202,8 @@ _add_emit_commited_and_restart_task (GnlComposition * comp)
|
||||||
{
|
{
|
||||||
GST_INFO_OBJECT (comp, "Setting up commited source and restarting task!");
|
GST_INFO_OBJECT (comp, "Setting up commited source and restarting task!");
|
||||||
|
|
||||||
MAIN_CONTEXT_LOCK (comp);
|
_add_gsource (comp, (GSourceFunc) _emit_commited_signal_func, comp, NULL,
|
||||||
g_main_context_invoke_full (comp->priv->mcontext, G_PRIORITY_HIGH,
|
G_PRIORITY_HIGH);
|
||||||
(GSourceFunc) _emit_commited_signal_func, comp, NULL);
|
|
||||||
MAIN_CONTEXT_UNLOCK (comp);
|
|
||||||
|
|
||||||
|
|
||||||
comp->priv->awaited_segment_seqnum = 0;
|
comp->priv->awaited_segment_seqnum = 0;
|
||||||
|
|
Loading…
Reference in a new issue