From 39580e19485b707fa0dc4e0a1deeecc9011c513a Mon Sep 17 00:00:00 2001 From: Thomas Adamcik Date: Sat, 5 Jan 2013 16:46:16 +0100 Subject: [PATCH] Use blocking calls when changing tracks on EOT. This ensures that we block about-to-finish and the pipeline until the next URI is set, alowing for at least EOS free playback. If the uri is set quickly enough this will also be gapless. --- mopidy/audio/actor.py | 5 +++++ mopidy/core/playback.py | 5 ++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/mopidy/audio/actor.py b/mopidy/audio/actor.py index e3d5ac87..701fe2ac 100644 --- a/mopidy/audio/actor.py +++ b/mopidy/audio/actor.py @@ -95,6 +95,11 @@ class Audio(pykka.ThreadingActor): from mopidy.core import Core logger.debug(u'Triggering reached end of track event') core = pykka.ActorRegistry.get_by_class(Core)[0].proxy() + + # Note that we can not let this function return until we have the next + # URI set for gapless / EOS free playback. This means all the + # subsequent remote calls to backends etc. down this code path need to + # block. core.playback.on_end_of_track().get() def _on_new_source(self, element, pad): diff --git a/mopidy/core/playback.py b/mopidy/core/playback.py index afd34394..1c105f0c 100644 --- a/mopidy/core/playback.py +++ b/mopidy/core/playback.py @@ -330,10 +330,13 @@ class PlaybackController(object): original_tl_track = self.current_tl_track + # As noted in mopidy.audio which calls this code, we need to make sure + # the calls to the backend are blocking or gapless / EOS free playback + # will break. if self.tl_track_at_eot: self.current_tl_track = self.tl_track_at_eot self._trigger_track_playback_ended() - self._get_backend().playback.change_track(self.current_track) + self._get_backend().playback.change_track(self.current_track).get() self._trigger_track_playback_started() if self.consume: