[pitivi] Disable GstObject::deep-notify feature



commit f80edd7b62be0e35137457efdeb83a2bf62d8587
Author: Thibault Saunier <tsaunier gnome org>
Date:   Fri Apr 22 20:13:26 2016 -0300

    Disable GstObject::deep-notify feature
    
    This feature is not needed for Pitivi and causes many
    issues, we have already avoided several deadlocks related
    to it, but the root cause of the issue is not simple to
    fix. Instead of properly fixing the issue,
    this commit is a work to avoid deadlocks like:
    
    - In main thread, we have the GIL and we commit and then for
      move a clip in the timeline, moving the clip leads to the
      timeline duration to change. The duration change leads to
      `deep-notify` to be emited which leads to try to get the
      timeline GST_OBJECT_LOCK
    
    - In the nlecomposition children handling thread
      the commit actually happens, which means we update the
      nlecomposition duration, we try to `deep-notify` from there,
      and for that we try to get the timeline parent, which eventually
      leads to adding a new ref on the timeline, which makes PyGObject
      to try to get GIL (needed to handle PyObject refcounting),
      but the GIL is already taken in the main thread.
    
    So we have the GIL in the main thread, trying to get the timeline
    GST_OBJECT_LOCK and in the composition thread, we have the timeline
    GST_OBJECT_LOCK and are trying to get the GIL.
    
    Workaround https://phabricator.freedesktop.org/T3350
    
    Reviewed-by: Alex Băluț <alexandru balut gmail com>
    Differential Revision: https://phabricator.freedesktop.org/D951

 pitivi/coptimizations/Makefile.am |    4 ++--
 pitivi/coptimizations/renderer.c  |   36 +++++++++++++++++++++++++++++++++++-
 2 files changed, 37 insertions(+), 3 deletions(-)
---
diff --git a/pitivi/coptimizations/Makefile.am b/pitivi/coptimizations/Makefile.am
index e11a801..11496bf 100644
--- a/pitivi/coptimizations/Makefile.am
+++ b/pitivi/coptimizations/Makefile.am
@@ -2,7 +2,7 @@ pyexec_LTLIBRARIES = renderer.la
 
 renderer_la_SOURCES = renderer.c
 pyexecdir = $(libdir)/pitivi/python/pitivi/timeline/
-AM_CFLAGS = $(cairo_CFLAGS) $(py3cairo_CFLAGS)
-LIBS = $(cairo_LIBS) $(py3cairo_LIBS)
+AM_CFLAGS = $(cairo_CFLAGS) $(py3cairo_CFLAGS) $(GST_ALL_CFLAGS) $(GSTREAMER_CFLAGS)
+LIBS = $(cairo_LIBS) $(py3cairo_LIBS)$(GST_ALL_LIBS) $(GSTREAMER_LIBS)
 renderer_la_CFLAGS = $(PYTHON_CFLAGS) $(AM_CFLAGS)
 renderer_la_LDFLAGS = -module -avoid-version $(LIBS)
diff --git a/pitivi/coptimizations/renderer.c b/pitivi/coptimizations/renderer.c
index b122000..a120f59 100644
--- a/pitivi/coptimizations/renderer.c
+++ b/pitivi/coptimizations/renderer.c
@@ -2,8 +2,10 @@
 #include <stdio.h>
 #include <cairo.h>
 #include <py3cairo.h>
+#include <gst/gst.h>
 
 static Pycairo_CAPI_t *Pycairo_CAPI;
+static GObjectClass * gobject_class;
 
 /*
  * This function must be called with a range of samples, and a desired
@@ -94,14 +96,46 @@ static PyModuleDef module = {
   renderer_methods, NULL, NULL, NULL, NULL
 };
 
+static void
+pitivi_disable_gst_object_dispatch_properties_changed (GObject * object,
+    guint n_pspecs, GParamSpec ** pspecs)
+{
+    GST_DEBUG_OBJECT (object, "Disabling `deep-notify`");
+
+    gobject_class->dispatch_properties_changed (object, n_pspecs, pspecs);
+}
+
+static void
+_disable_gst_object_deep_notify_recurse (GType type)
+{
+  gint i;
+  GType *types;
+  GObjectClass *klass = g_type_class_ref (type);
+
+  klass->dispatch_properties_changed =
+      pitivi_disable_gst_object_dispatch_properties_changed;
+  g_type_class_unref (klass);
+
+  types = g_type_children (type, NULL);
+  for (i=0; types[i]; i++)
+   _disable_gst_object_deep_notify_recurse (types[i]);
+
+}
+
 PyMODINIT_FUNC
 PyInit_renderer (void)
 {
+  PyObject *m;
+
+  gobject_class = g_type_class_peek (G_TYPE_OBJECT);
+
+  /* Workaround https://phabricator.freedesktop.org/T3350 */
+  _disable_gst_object_deep_notify_recurse (GST_TYPE_OBJECT);
+
   if (import_cairo () < 0) {
     g_print ("Cairo import failed.");
   }
 
-  PyObject *m;
   m = PyModule_Create (&module);
   if (m == NULL)
     return NULL;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]