summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMax Kellermann <max@musicpd.org>2019-08-20 20:01:53 +0200
committerMax Kellermann <max@musicpd.org>2019-08-20 20:01:53 +0200
commitca450663d09b0e467292aaa17f636db71b95d574 (patch)
treef4409808d6ea5391618b359afb562c28e81b3e0d
parentf3d16f6d1bad64c6ef395997e68e6c682ada13e4 (diff)
decoder/Control: work around crash after SEEK was too late
See code comment. Closes https://github.com/MusicPlayerDaemon/MPD/issues/629
-rw-r--r--NEWS2
-rw-r--r--src/decoder/Control.cxx12
2 files changed, 14 insertions, 0 deletions
diff --git a/NEWS b/NEWS
index acc735d2e..56ce212c9 100644
--- a/NEWS
+++ b/NEWS
@@ -3,6 +3,8 @@ ver 0.21.14 (not yet released)
- sidplay: show track durations in database
- sidplay: convert tag values from Windows-1252 charset
- sidplay: strip text from "Date" tag
+* player
+ - fix crash after song change
ver 0.21.13 (2019/08/06)
* input
diff --git a/src/decoder/Control.cxx b/src/decoder/Control.cxx
index 5faa23fe5..cf8a74385 100644
--- a/src/decoder/Control.cxx
+++ b/src/decoder/Control.cxx
@@ -147,6 +147,18 @@ DecoderControl::Seek(SongTime t)
seek_error = false;
SynchronousCommandLocked(DecoderCommand::SEEK);
+ while (state == DecoderState::START)
+ /* If the decoder falls back to DecoderState::START,
+ this means that our SEEK command arrived too late,
+ and the decoder had meanwhile finished decoding and
+ went idle. Our SEEK command is finished, but that
+ means only that the decoder thread has launched the
+ decoder. To work around illegal states, we wait
+ until the decoder plugin has become ready. This is
+ a kludge, built on top of the "late seek" kludge.
+ Not exactly elegant, sorry. */
+ WaitForDecoder();
+
if (seek_error)
throw std::runtime_error("Decoder failed to seek");
}