player/Thread: merge four mutex locks in SeekDecoder()
This commit is contained in:
@@ -304,12 +304,6 @@ struct DecoderControl {
|
|||||||
gcc_pure
|
gcc_pure
|
||||||
bool IsCurrentSong(const DetachedSong &_song) const noexcept;
|
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:
|
private:
|
||||||
/**
|
/**
|
||||||
* Wait for the command to be finished by the decoder thread.
|
* Wait for the command to be finished by the decoder thread.
|
||||||
|
@@ -615,20 +615,18 @@ Player::SeekDecoder() noexcept
|
|||||||
|
|
||||||
pc.outputs.Cancel();
|
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 -
|
/* the decoder is already decoding the "next" song -
|
||||||
stop it and start the previous song again */
|
stop it and start the previous song again */
|
||||||
|
|
||||||
{
|
StopDecoder();
|
||||||
const std::lock_guard<Mutex> lock(pc.mutex);
|
|
||||||
StopDecoder();
|
|
||||||
}
|
|
||||||
|
|
||||||
/* clear music chunks which might still reside in the
|
/* clear music chunks which might still reside in the
|
||||||
pipe */
|
pipe */
|
||||||
pipe->Clear(buffer);
|
pipe->Clear(buffer);
|
||||||
|
|
||||||
const std::lock_guard<Mutex> lock(pc.mutex);
|
|
||||||
/* re-start the decoder */
|
/* re-start the decoder */
|
||||||
StartDecoder(*pipe);
|
StartDecoder(*pipe);
|
||||||
ActivateDecoder();
|
ActivateDecoder();
|
||||||
@@ -642,8 +640,6 @@ Player::SeekDecoder() noexcept
|
|||||||
ClearAndReplacePipe(dc.pipe);
|
ClearAndReplacePipe(dc.pipe);
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::lock_guard<Mutex> lock(pc.mutex);
|
|
||||||
|
|
||||||
pc.next_song.reset();
|
pc.next_song.reset();
|
||||||
queued = false;
|
queued = false;
|
||||||
|
|
||||||
@@ -660,7 +656,7 @@ Player::SeekDecoder() noexcept
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
pc.LockCommandFinished();
|
pc.CommandFinished();
|
||||||
|
|
||||||
assert(xfade_state == CrossFadeState::UNKNOWN);
|
assert(xfade_state == CrossFadeState::UNKNOWN);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user