From 3e12ed1f69d63bbab57d0bcde1ff9f6a7d2674d6 Mon Sep 17 00:00:00 2001 From: Thomas Adamcik Date: Thu, 28 Jul 2016 21:16:21 +0200 Subject: [PATCH] audio: Postpone set_metadata until track is playing --- docs/changelog.rst | 3 +++ mopidy/audio/actor.py | 14 +++++++++----- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/docs/changelog.rst b/docs/changelog.rst index 22199087..a13baa3d 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -35,6 +35,9 @@ Bug fix release. - Audio: Ensure audio tags are never ``None``. (Fixes: :issue:`1449`) +- Audio: Update :meth:`mopidy.audio.Audio.set_metadata` to postpone sending + tags if there is a pending track change. (Fixes: :issue:`1357`) + - Core: Avoid endless loop if all tracks in the tracklist are unplayable and consume mode is off. (Fixes: :issue:`1221`, :issue:`1454`, PR: :issue:`1455`) diff --git a/mopidy/audio/actor.py b/mopidy/audio/actor.py index 61a8e008..f96834e7 100644 --- a/mopidy/audio/actor.py +++ b/mopidy/audio/actor.py @@ -374,6 +374,10 @@ class _Handler(object): logger.debug('Audio event: tags_changed(tags=%r)', tags.keys()) AudioListener.send('tags_changed', tags=tags.keys()) + if self._audio._pending_metadata: + self._audio._playbin.send_event(self._audio._pending_metadata) + self._audio._pending_metadata = None + def on_segment(self, segment): gst_logger.debug( 'Got SEGMENT pad event: ' @@ -412,6 +416,7 @@ class Audio(pykka.ThreadingActor): self._tags = {} self._pending_uri = None self._pending_tags = None + self._pending_metadata = None self._playbin = None self._outputs = None @@ -800,12 +805,11 @@ class Audio(pykka.ThreadingActor): if track.album and track.album.name: set_value(Gst.TAG_ALBUM, track.album.name) - gst_logger.debug( - 'Sending TAG event for track %r: %r', - track.uri, taglist.to_string()) event = Gst.Event.new_tag(taglist) - # TODO: check if we get this back on our own bus? - self._playbin.send_event(event) + if not self._pending_uri: + self._playbin.send_event(event) + else: + self._pending_metadata = event def get_current_tags(self): """