player/Thread: make seeking into a new song non-blocking
This commit is contained in:
parent
dee378b775
commit
7171e23700
|
@ -210,37 +210,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.
|
||||
*
|
||||
|
@ -553,6 +522,12 @@ Player::CheckDecoderStartup() noexcept
|
|||
if (!success)
|
||||
return false;
|
||||
|
||||
/* 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;
|
||||
}
|
||||
|
@ -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,
|
||||
|
|
Loading…
Reference in New Issue