avoiding prepare-xwindow-id and gdk threads

Sebastian Dröge sebastian at centricular.com
Fri Nov 29 03:03:02 PST 2013


On Fr, 2013-11-29 at 12:42 +0200, Dan wrote:
> I've been using the pygst Playbin tutorial
> (http://pygstdocs.berlios.de/pygst-tutorial/playbin.html) as a base
> for my video player.
> 
> Now I'm curious if I can get rid of gdk threading. In particular, can
> the imagesink be given a proper xwindow_id:
> 
> 	def on_sync_message(self, bus, message):
> 		if message.structure is None:
> 			return
> 		message_name = message.structure.get_name()
> 		if message_name == "prepare-xwindow-id":
> 			imagesink = message.src
> 			imagesink.set_property("force-aspect-ratio", True)
> 			gtk.gdk.threads_enter()
> 			imagesink.set_xwindow_id(self.movie_window.window.xid)
> 			gtk.gdk.threads_leave()
> 
> without requiring gdk threading? E.g. before the pipeline moves? Or
> later, in a glib idle callback?

You could get the XID of the window before starting the pipeline, store
it in some variable and then just set that when you receive the message.

Alternatively you can also set (since GStreamer 1.0) the window handle
directly on playbin before setting it to PAUSED/PLAYING and it will
automatically pass that on to the sink.


The only thing you should not do is to get the XID from the window from
the sync bus handler. That's what requires gtk.gdk.threads_enter/leave
and is not going to work on other platforms at all and could cause
various problems.

-- 
Sebastian Dröge <sebastian at centricular.com>
Centricular Ltd - http://www.centricular.com
Expertise, Straight from the Source
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 966 bytes
Desc: This is a digitally signed message part
URL: <http://lists.freedesktop.org/archives/gstreamer-devel/attachments/20131129/b402aeac/attachment.pgp>


More information about the gstreamer-devel mailing list