Commit 5bd1fbb0 authored by Max Kellermann's avatar Max Kellermann

player/Thread: merge four mutex locks in SeekDecoder()

parent 0772e571
......@@ -304,12 +304,6 @@ struct DecoderControl {
gcc_pure
bool IsCurrentSong(const DetachedSong &_song) const noexcept;
gcc_pure
bool LockIsCurrentSong(const DetachedSong &_song) const noexcept {
const std::lock_guard<Mutex> protect(mutex);
return IsCurrentSong(_song);
}
private:
/**
* Wait for the command to be finished by the decoder thread.
......
......@@ -615,20 +615,18 @@ Player::SeekDecoder() noexcept
pc.outputs.Cancel();
if (!dc.LockIsCurrentSong(*pc.next_song)) {
const std::lock_guard<Mutex> lock(pc.mutex);
if (!dc.IsCurrentSong(*pc.next_song)) {
/* the decoder is already decoding the "next" song -
stop it and start the previous song again */
{
const std::lock_guard<Mutex> lock(pc.mutex);
StopDecoder();
}
StopDecoder();
/* clear music chunks which might still reside in the
pipe */
pipe->Clear(buffer);
const std::lock_guard<Mutex> lock(pc.mutex);
/* re-start the decoder */
StartDecoder(*pipe);
ActivateDecoder();
......@@ -642,8 +640,6 @@ Player::SeekDecoder() noexcept
ClearAndReplacePipe(dc.pipe);
}
const std::lock_guard<Mutex> lock(pc.mutex);
pc.next_song.reset();
queued = false;
......@@ -660,7 +656,7 @@ Player::SeekDecoder() noexcept
return false;
}
pc.LockCommandFinished();
pc.CommandFinished();
assert(xfade_state == CrossFadeState::UNKNOWN);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment