Merge pull request #855 from jodal/feature/emit-none-to-emit-eos

audio: Deprecate emit_end_of_stream
This commit is contained in:
Thomas Adamcik 2014-09-22 22:58:32 +02:00
commit 508391cf51
2 changed files with 19 additions and 9 deletions

View File

@ -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.

View File

@ -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):
"""