[Sugar-devel] [PATCH jukebox] Don't call into GTK+ when setting video sink from gstreamer thread

Daniel Drake dsd at laptop.org
Mon Jun 6 12:58:58 EDT 2011


As noted at http://bugs.sugarlabs.org/ticket/2853
Jukebox often crashes when loading content or shows its content in the
wrong window.

This is because it is calling into GTK+ from the gstreamer thread,
without taking the appropriate locks.

Fix this by following the suggestion of the gstreamer documentation, where
the xid is queried earlier from the correct thread:
http://gstreamer.freedesktop.org/data/doc/gstreamer/head/gst-plugins-base-libs/html/gst-plugins-base-libs-gstxoverlay.html
---
 jukeboxactivity.py |    9 +++++----
 1 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/jukeboxactivity.py b/jukeboxactivity.py
index fc20f2b..9366fb5 100644
--- a/jukeboxactivity.py
+++ b/jukeboxactivity.py
@@ -423,7 +423,9 @@ class GstPlayer(gobject.GObject):
             self.player.set_property('vis-plugin', vis_plug)
 
         self.overlay = None
+        videowidget.realize()
         self.videowidget = videowidget
+        self.videowidget_xid = videowidget.window.xid
         self._init_video_sink()
 
         bus = self.player.get_bus()
@@ -439,7 +441,7 @@ class GstPlayer(gobject.GObject):
         if message.structure is None:
             return
         if message.structure.get_name() == 'prepare-xwindow-id':
-            self.videowidget.set_sink(message.src)
+            self.videowidget.set_sink(message.src, self.videowidget_xid)
             message.src.set_property('force-aspect-ratio', True)
             
     def on_message(self, bus, message):
@@ -581,10 +583,9 @@ class VideoWidget(gtk.DrawingArea):
         else:
             return True
 
-    def set_sink(self, sink):
-        assert self.window.xid
+    def set_sink(self, sink, xid):
         self.imagesink = sink
-        self.imagesink.set_xwindow_id(self.window.xid)
+        self.imagesink.set_xwindow_id(xid)
 
 
 
-- 
1.7.5.2



More information about the Sugar-devel mailing list