ges: Implement our own idle_add which uses the thread local maincontext
authorThibault Saunier <tsaunier@igalia.com>
Tue, 9 Jul 2019 05:03:56 +0000 (01:03 -0400)
committerThibault Saunier <tsaunier@igalia.com>
Fri, 26 Jul 2019 17:48:51 +0000 (13:48 -0400)
ges/ges-base-xml-formatter.c
ges/ges-internal.h
ges/ges-project.c
ges/ges-timeline-element.c
ges/ges-utils.c

index 7e5e126..971cd77 100644 (file)
@@ -283,7 +283,7 @@ _load_from_uri (GESFormatter * self, GESTimeline * timeline, const gchar * uri,
     return FALSE;
 
   if (priv->pending_assets == NULL)
-    g_idle_add ((GSourceFunc) _loading_done_cb, g_object_ref (self));
+    ges_idle_add ((GSourceFunc) _loading_done_cb, g_object_ref (self), NULL);
 
   return TRUE;
 }
index a0c3e65..9b3d260 100644 (file)
@@ -351,6 +351,9 @@ G_GNUC_INTERNAL gint element_end_compare                  (GESTimelineElement *
 G_GNUC_INTERNAL GstElementFactory *
 ges_get_compositor_factory                                (void);
 
+G_GNUC_INTERNAL void
+ges_idle_add (GSourceFunc func, gpointer udata, GDestroyNotify notify);
+
 
 /****************************************************
  *              GESContainer                        *
index 8ff82a2..b0fd379 100644 (file)
@@ -224,7 +224,7 @@ _load_project (GESProject * project, GESTimeline * timeline, GError ** error)
       data->project = gst_object_ref (project);
 
       /* Make sure the signal is emitted after the functions ends */
-      g_idle_add ((GSourceFunc) _emit_loaded_in_idle, data);
+      ges_idle_add ((GSourceFunc) _emit_loaded_in_idle, data, NULL);
       return TRUE;
     }
   }
index 36cf2fe..ffa00f3 100644 (file)
@@ -1417,7 +1417,7 @@ child_prop_changed_cb (GObject * child, GParamSpec * arg
   data->arg = g_param_spec_ref (arg);
   data->self = gst_object_ref (self);
 
-  g_idle_add ((GSourceFunc) emit_deep_notify_in_idle, data);
+  ges_idle_add ((GSourceFunc) emit_deep_notify_in_idle, data, NULL);
 }
 
 gboolean
index adb0d0c..654039b 100644 (file)
@@ -166,6 +166,19 @@ ges_get_compositor_factory (void)
   return compositor_factory;
 }
 
+void
+ges_idle_add (GSourceFunc func, gpointer udata, GDestroyNotify notify)
+{
+  GMainContext *context = g_main_context_get_thread_default ();
+  GSource *source = g_idle_source_new ();
+  if (!context)
+    context = g_main_context_default ();
+
+  g_source_set_callback (source, func, udata, notify);
+  g_source_attach (source, context);
+
+}
+
 gboolean
 ges_nle_composition_add_object (GstElement * comp, GstElement * object)
 {