From 44b200240f1f4b8394dd2e58fec72da3d3ec448f Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Wed, 25 Apr 2018 21:19:26 +0200 Subject: [PATCH] player/Thread: never reuse decoder when switching radio streams When switching to another song manually, the player checks if the decoder is already decoding that song; if so, it will attempt to reuse it by seeking it to the new position. That however fails if the decoder is not seekable (e.g. a radio stream) which leaves the user unable to switch to that song with the bogus error message "Not seekable". --- NEWS | 2 ++ src/decoder/DecoderControl.hxx | 9 +++++++-- src/player/Thread.cxx | 2 +- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/NEWS b/NEWS index f422b2239..c27ab3d35 100644 --- a/NEWS +++ b/NEWS @@ -3,6 +3,8 @@ ver 0.20.19 (not yet released) - validate absolute seek time, reject negative values * input - mms: fix lockup bug and a crash bug +* player + - fix spurious "Not seekable" error when switching radio streams * macOS: fix crash bug ver 0.20.18 (2018/02/24) diff --git a/src/decoder/DecoderControl.hxx b/src/decoder/DecoderControl.hxx index dfd8232e6..920982e80 100644 --- a/src/decoder/DecoderControl.hxx +++ b/src/decoder/DecoderControl.hxx @@ -308,9 +308,14 @@ struct DecoderControl { bool IsCurrentSong(const DetachedSong &_song) const noexcept; gcc_pure - bool LockIsCurrentSong(const DetachedSong &_song) const noexcept { + bool IsSeekableCurrentSong(const DetachedSong &_song) const noexcept { + return seekable && IsCurrentSong(_song); + } + + gcc_pure + bool LockIsSeeakbleCurrentSong(const DetachedSong &_song) const noexcept { const std::lock_guard protect(mutex); - return IsCurrentSong(_song); + return IsSeekableCurrentSong(_song); } private: diff --git a/src/player/Thread.cxx b/src/player/Thread.cxx index 58883307d..651117088 100644 --- a/src/player/Thread.cxx +++ b/src/player/Thread.cxx @@ -584,7 +584,7 @@ Player::SeekDecoder() const SongTime start_time = pc.next_song->GetStartTime(); - if (!dc.LockIsCurrentSong(*pc.next_song)) { + if (!dc.LockIsSeeakbleCurrentSong(*pc.next_song)) { /* the decoder is already decoding the "next" song - stop it and start the previous song again */