[gst-devel] multiple watches on a bus
Christopher Backhouse
cjbackhouse at gmail.com
Fri Nov 24 17:26:28 CET 2006
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
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
More information about the gstreamer-devel
mailing list