From 00c17ae1937107fa9bff6235c5f84b9882e6670f Mon Sep 17 00:00:00 2001 From: Stein Magnus Jodal Date: Sun, 21 Sep 2014 21:01:11 +0200 Subject: [PATCH] audio: Deprecate emit_end_of_stream --- docs/changelog.rst | 3 +++ mopidy/audio/actor.py | 25 ++++++++++++++++--------- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/docs/changelog.rst b/docs/changelog.rst index 0ff362f8..9611d49d 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -25,6 +25,9 @@ v0.20.0 (UNRELEASED) **Audio** +- Deprecated :meth:`mopidy.audio.Audio.emit_end_of_stream`. Pass a + :class:`None` buffer to :meth:`mopidy.audio.Audio.emit_data` end the stream. + - Internal code cleanup within audio subsystem: - Started splitting audio code into smaller better defined pieces. diff --git a/mopidy/audio/actor.py b/mopidy/audio/actor.py index 5cea9f7b..51b30f91 100644 --- a/mopidy/audio/actor.py +++ b/mopidy/audio/actor.py @@ -131,10 +131,11 @@ class _Appsrc(object): self._source = source def push(self, buffer_): - return self._source.emit('push-buffer', buffer_) == gst.FLOW_OK - - def end_of_stream(self): - self._source.emit('end-of-stream') + if buffer_ is None: + gst_logger.debug('Sending appsrc end-of-stream event.') + return self._source.emit('end-of-stream') == gst.FLOW_OK + else: + return self._source.emit('push-buffer', buffer_) == gst.FLOW_OK def _on_signal(self, element, clocktime, func): # This shim is used to ensure we always return true, and also handles @@ -560,12 +561,16 @@ class Audio(pykka.ThreadingActor): """ Call this to deliver raw audio data to be played. - Note that the uri must be set to ``appsrc://`` for this to work. + If the buffer is :class:`None`, the end-of-stream token is put on the + playbin. We will get a GStreamer message when the stream playback + reaches the token, and can then do any end-of-stream related tasks. - Returns true if data was delivered. + Note that the URI must be set to ``appsrc://`` for this to work. + + Returns :class:`True` if data was delivered. :param buffer_: buffer to pass to appsrc - :type buffer_: :class:`gst.Buffer` + :type buffer_: :class:`gst.Buffer` or :class:`None` :rtype: boolean """ return self._appsrc.push(buffer_) @@ -577,9 +582,11 @@ class Audio(pykka.ThreadingActor): We will get a GStreamer message when the stream playback reaches the token, and can then do any end-of-stream related tasks. + + .. deprecated:: 0.20 + Use :meth:`emit_data` with a :class:`None` buffer instead. """ - self._appsrc.end_of_stream() - gst_logger.debug('Sent appsrc end-of-stream event.') + self._appsrc.push(None) def set_about_to_finish_callback(self, callback): """