diff options
author | Manuel Kaufmann <humitos@gmail.com> | 2013-01-24 16:37:50 (GMT) |
---|---|---|
committer | Gonzalo Odiard <godiard@gmail.com> | 2013-01-25 13:05:02 (GMT) |
commit | 00310ed7f0b389028b63dde51edd23abcc24e216 (patch) | |
tree | f1ea535cf57dd99bd15710dbf1ebea48af84eaef | |
parent | 1c74c065e73654f4e3564e81e614b800d7a1bef2 (diff) |
Visualization on Audio streams removed
This cause a 100% of CPU usage on XO-4 and XO-1.75. An empty widget is
shown when an Audio stream is played and the Video stream is shown if
a Video stream is played.
Signed-off-by: Manuel Kaufmann <humitos@gmail.com>
Reviewed-by: Gonzalo Odiard <gonzalo@laptop.org>
-rw-r--r-- | activity.py | 17 | ||||
-rw-r--r-- | player.py | 31 |
2 files changed, 19 insertions, 29 deletions
diff --git a/activity.py b/activity.py index 10a2490..e163a6c 100644 --- a/activity.py +++ b/activity.py @@ -169,6 +169,8 @@ class JukeboxActivity(activity.Activity): self.player = GstPlayer(self.videowidget) self.player.connect("eos", self._player_eos_cb) self.player.connect("error", self._player_error_cb) + self.player.connect('play', self.__player_play_cb) + self.p_position = Gst.CLOCK_TIME_NONE self.p_duration = Gst.CLOCK_TIME_NONE @@ -349,6 +351,21 @@ class JukeboxActivity(activity.Activity): def _alert_cancel_cb(self, alert, response_id): self.remove_alert(alert) + def __player_play_cb(self, widget): + # Do not show the visualization widget if we are playing just + # an audio stream + + def callback(): + if self.player.playing_video(): + self._switch_canvas(True) + else: + self._switch_canvas(False) + return False + + # HACK: we need a timeout here because gstreamer returns + # n-video = 0 if we call it immediately + GObject.timeout_add(1000, callback) + def _player_error_cb(self, widget, message, detail): self.player.stop() self.player.set_uri(None) @@ -37,6 +37,7 @@ class GstPlayer(GObject.GObject): __gsignals__ = { 'error': (GObject.SignalFlags.RUN_FIRST, None, [str, str]), 'eos': (GObject.SignalFlags.RUN_FIRST, None, []), + 'play': (GObject.SignalFlags.RUN_FIRST, None, []), } def __init__(self, videowidget): @@ -62,21 +63,6 @@ class GstPlayer(GObject.GObject): self.player = Gst.ElementFactory.make('playbin', None) self.pipeline.add(self.player) - # Set the proper flags to render the vis-plugin - GST_PLAY_FLAG_VIS = 1 << 3 - GST_PLAY_FLAG_TEXT = 1 << 2 - self.player.props.flags |= GST_PLAY_FLAG_VIS - self.player.props.flags |= GST_PLAY_FLAG_TEXT - - r = Gst.Registry.get() - l = [x for x in r.get_feature_list(Gst.ElementFactory) - if (x.get_metadata('klass') == "Visualization")] - if len(l): - e = l.pop() # take latest plugin in the list - vis_plug = Gst.ElementFactory.make(e.get_name(), e.get_name()) - self.player.set_property('vis-plugin', vis_plug) - - self.overlay = None videowidget.realize() self.videowidget = videowidget self.videowidget_xid = videowidget.get_window().get_xid() @@ -102,20 +88,6 @@ class GstPlayer(GObject.GObject): logging.debug('### Setting URI: %s', uri) self.player.set_property('uri', uri) - def set_overlay(self, title, artist, album): - text = "%s\n%s" % (title, artist) - if album and len(album): - text += "\n%s" % album - self.overlay.set_property("text", text) - self.overlay.set_property("font-desc", "sans bold 14") - self.overlay.set_property("halignment", "right") - self.overlay.set_property("valignment", "bottom") - try: - # Only in OLPC versions of gstreamer-plugins-base for now - self.overlay.set_property("line-align", "left") - except: - pass - def query_position(self): "Returns a (position, duration) tuple" @@ -145,6 +117,7 @@ class GstPlayer(GObject.GObject): self.pipeline.set_state(Gst.State.PLAYING) self.playing = True self.error = False + self.emit('play') def stop(self): self.playing = False |