summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMax Kellermann <max@musicpd.org>2017-12-30 11:31:26 +0100
committerMax Kellermann <max@musicpd.org>2017-12-30 11:31:26 +0100
commit7171e237007db547088c38295a7351573c0d79bf (patch)
tree3e638bcebbeec2cc19396d72c0cc026fa6f40bf2
parentdee378b77530a0c8ce5631a3d96dc542c467b723 (diff)
player/Thread: make seeking into a new song non-blocking
-rw-r--r--src/player/Thread.cxx45
1 files changed, 12 insertions, 33 deletions
diff --git a/src/player/Thread.cxx b/src/player/Thread.cxx
index 77eee0aa7..801114d06 100644
--- a/src/player/Thread.cxx
+++ b/src/player/Thread.cxx
@@ -211,37 +211,6 @@ private:
bool CheckDecoderStartup() noexcept;
/**
- * Call CheckDecoderStartup() repeatedly until the decoder has
- * finished startup. Returns false on decoder error (and
- * finishes the #PlayerCommand).
- *
- * This method does not check for commands. It is only
- * allowed to be used while a command is being handled.
- *
- * Caller must lock the mutex.
- *
- * @return false if the decoder has failed
- */
- bool WaitDecoderStartup() noexcept {
- while (decoder_starting) {
- if (!CheckDecoderStartup()) {
- /* if decoder startup fails, make sure
- the previous song is not being
- played anymore */
- {
- const ScopeUnlock unlock(pc.mutex);
- pc.outputs.Cancel();
- }
-
- pc.CommandFinished();
- return false;
- }
- }
-
- return true;
- }
-
- /**
* Stop the decoder and clears (and frees) its music pipe.
*
* Caller must lock the mutex.
@@ -555,6 +524,12 @@ Player::CheckDecoderStartup() noexcept
/* re-fill the buffer after seeking */
buffering = true;
+ } else if (pc.seeking) {
+ pc.seeking = false;
+ pc.ClientSignal();
+
+ /* re-fill the buffer after seeking */
+ buffering = true;
}
if (!paused && !OpenOutput()) {
@@ -669,8 +644,12 @@ Player::SeekDecoder() noexcept
StartDecoder(*pipe);
ActivateDecoder();
- if (!WaitDecoderStartup())
- return false;
+ pc.seeking = true;
+ pc.CommandFinished();
+
+ assert(xfade_state == CrossFadeState::UNKNOWN);
+
+ return true;
} else {
if (!IsDecoderAtCurrentSong()) {
/* the decoder is already decoding the "next" song,