player/Thread: merge four mutex locks in SeekDecoder()
This commit is contained in:
parent
0772e571b7
commit
5bd1fbb0d6
|
@ -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);
|
||||
|
||||
|
|
Loading…
Reference in New Issue