[gst-devel] multiple watches on a bus

Wim Taymans wim at fluendo.com
Fri Nov 24 17:39:02 CET 2006


On Fri, 2006-11-24 at 16:26 +0000, Christopher Backhouse wrote:
> I am trying to add two watches to a bus like so:
> 
> 
> import gst,gtk
> 
> def onBus1(bus,msg,data):
> 	print '1'
> 	if msg.type==gst.MESSAGE_APPLICATION: print msg
> 	return True
> 			
> def onBus2(bus,msg,data):
> 	print '2'
> 	if msg.type==gst.MESSAGE_APPLICATION: print msg
> 	return True		
> 
> playbin=gst.element_factory_make('playbin','myplayer')
> bus=playbin.get_bus()
> bus.add_watch(onBus1,None)
> bus.add_watch(onBus2,None)
> 	 	
> foo=gst.Structure('foo')
> playbin.get_bus().post(gst.message_new_application(playbin,foo))
> 
> gtk.main()
> 
> 
> When I run this I get:
> 
> 1
> <gst.Message foo from myplayer at 0x81c3910>
> 
> (bustest:9769): GStreamer-CRITICAL **: gst_bus_source_dispatch: 
> assertion `message != NULL' failed

I think this is a bug in the dispatcher when you have multiple sources
reading from the bus. Currently both GSources are dispatched because
there is a message on the bus. The first dispatched source pops the
message from the bus, the second dispatched source is surprised it got
dispatched without there being a message on the bus. Silly but annoying
to fix, you ideally want both sources to see the message, which involves
having some post dispatch action popping and unreffing the message,
dunno. Probably the best way is to hide (without asserting) the message
from the second source (like GIOChannel) and document this properly.

For now, don't use two watches, you can use 1 watch and dispatch to
multiple listeners from there or use the signal mechanism to dispatch
the message (which works fine for multiple listeners).

Wim
> 
> 
> Looking at the doc it says "The message passed to the function will be 
> unreffed after execution of this function so it should not be freed in 
> the function." I guess this is my problem.
> Will just adding a reference to it in the bus callback work? (as soon as 
> I work out what function I need to call to do that)
> Presumably this is a bad idea as then I am leaking the messages. Better 
> ideas for handling this? presumably this is a reasonably common 
> requirement...
> 
> Thanks - Chris
> 
> -------------------------------------------------------------------------
> Take Surveys. Earn Cash. Influence the Future of IT
> Join SourceForge.net's Techsay panel and you'll get the chance to share your
> opinions on IT & business topics through brief surveys - and earn cash
> http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
> _______________________________________________
> gstreamer-devel mailing list
> gstreamer-devel at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
-- 
Wim Taymans <wim at fluendo.com>





More information about the gstreamer-devel mailing list