examples/: Updates for bus API.

Original commit message from CVS:
2005-09-29  Andy Wingo  <wingo@pobox.com>

* examples/pipeline-tester (Window.play):
* examples/vumeter.py (Window.run): Updates for bus API.
This commit is contained in:
Andy Wingo 2005-09-29 16:38:06 +00:00
parent ced71dad74
commit b27e9ba001
3 changed files with 19 additions and 9 deletions

View file

@ -1,3 +1,8 @@
2005-09-29 Andy Wingo <wingo@pobox.com>
* examples/pipeline-tester (Window.play):
* examples/vumeter.py (Window.run): Updates for bus API.
2005-09-29 Edward Hervey <edward@fluendo.com>
* gst/gst.defs:

View file

@ -44,7 +44,7 @@ data = (('Video capture via V4L',
' ! xvimagesink'),
('Video capture via V4L, fixed frame rate',
'v4lsrc name=source autoprobe=false autoprobe-fps=false \n'
' ! video/x-raw-yuv,framerate=(double)7.5 \n'
' ! video/x-raw-yuv,format=(fourcc)I420,framerate=(double)7.5 \n'
' ! videorate \n'
' ! ffmpegcolorspace \n'
' ! xvimagesink'),
@ -223,13 +223,17 @@ class Window(gtk.Window):
self.set_sensitive(True)
self.error('Could not create pipeline', str(e))
return False
watch_id = pipeline.get_bus().add_watch(self.on_message)
bus = pipeline.get_bus()
bus.add_signal_watch()
watch_id = bus.connect('message', self.on_message)
if pipeline.set_state(gst.STATE_PLAYING) != gst.STATE_CHANGE_SUCCESS:
# make sure we get error messages
while gtk.events_pending():
gtk.main_iteration()
pipeline.set_state(gst.STATE_NULL)
gobject.source_remove(watch_id)
bus.remove_signal_watch()
bus.disconnect(watch_id)
return False
else:
self.pipeline = pipeline
@ -237,9 +241,11 @@ class Window(gtk.Window):
return True
def stop(self):
bus = self.pipeline.get_bus()
bus.disconnect(self.watch_id)
bus.remove_signal_watch()
self.pipeline.set_state(gst.STATE_NULL)
self.pipeline = None
gobject.source_remove(self.watch_id)
del self.watch_id
def play_toggled(self):

View file

@ -89,17 +89,16 @@ class Window(gtk.Dialog):
s = 'alsasrc ! level message=true ! fakesink'
pipeline = gst.parse_launch(s)
self.set_sensitive(True)
# FIXME: using gst.MESSAGE_APPLICATION does not give me
# any messages at all
watch_id = pipeline.get_bus().add_watch(gst.MESSAGE_ANY,
self.on_message)
pipeline.get_bus().add_signal_watch()
i = pipeline.get_bus().connect('message::application', self.on_message)
if pipeline.set_state(gst.STATE_PLAYING) == gst.STATE_CHANGE_SUCCESS:
print "going into main"
gtk.Dialog.run(self)
else:
self.error('Could not set state')
pipeline.get_bus().disconnect(i)
pipeline.get_bus().remove_signal_watch()
pipeline.set_state(gst.STATE_NULL)
gobject.source_remove(watch_id)
except gobject.GError, e:
self.set_sensitive(True)
self.error('Could not create pipeline', e.__str__)