From f2b975cc37c93cf5633f85497d6e4c5ffa7f572a Mon Sep 17 00:00:00 2001 From: Thomas Adamcik Date: Thu, 15 Nov 2012 22:38:27 +0100 Subject: [PATCH] Update emit_data to return true if data was delivered. This is probably not needed, but for the sake of correctnes it doesn't hurt. --- mopidy/audio/actor.py | 5 ++++- mopidy/backends/spotify/session_manager.py | 6 ++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/mopidy/audio/actor.py b/mopidy/audio/actor.py index b422bc67..a17033ed 100644 --- a/mopidy/audio/actor.py +++ b/mopidy/audio/actor.py @@ -231,11 +231,14 @@ class Audio(pykka.ThreadingActor): Note that the uri must be set to ``appsrc://`` for this to work. + Returns true if data was delivered. + :param buffer_: buffer to pass to appsrc :type buffer_: :class:`gst.Buffer` + :rtype: boolean """ source = self._playbin.get_property('source') - source.emit('push-buffer', buffer_) + return source.emit('push-buffer', buffer_) == gst.FLOW_OK def emit_end_of_stream(self): """ diff --git a/mopidy/backends/spotify/session_manager.py b/mopidy/backends/spotify/session_manager.py index 8032a289..998e4d5e 100644 --- a/mopidy/backends/spotify/session_manager.py +++ b/mopidy/backends/spotify/session_manager.py @@ -115,8 +115,10 @@ class SpotifySessionManager(process.BaseThread, PyspotifySessionManager): buffer_ = gst.Buffer(bytes(frames)) buffer_.set_caps(gst.caps_from_string(capabilites)) - self.audio.emit_data(buffer_) - return num_frames + if self.audio.emit_data(buffer_).get(): + return num_frames + else: + return 0 def play_token_lost(self, session): """Callback used by pyspotify"""