Commit 4bcc38c7 authored by Max Kellermann's avatar Max Kellermann

player/Thread: move mutex lock out of WaitDecoderStartup()

parent 5becffbb
...@@ -208,11 +208,11 @@ private: ...@@ -208,11 +208,11 @@ private:
* This method does not check for commands. It is only * This method does not check for commands. It is only
* allowed to be used while a command is being handled. * allowed to be used while a command is being handled.
* *
* Caller must lock the mutex.
*
* @return false if the decoder has failed * @return false if the decoder has failed
*/ */
bool WaitDecoderStartup() noexcept { bool WaitDecoderStartup() noexcept {
const std::lock_guard<Mutex> lock(pc.mutex);
while (decoder_starting) { while (decoder_starting) {
if (!CheckDecoderStartup()) { if (!CheckDecoderStartup()) {
/* if decoder startup fails, make sure /* if decoder startup fails, make sure
...@@ -231,6 +231,11 @@ private: ...@@ -231,6 +231,11 @@ private:
return true; return true;
} }
bool LockWaitDecoderStartup() noexcept {
const std::lock_guard<Mutex> lock(pc.mutex);
return WaitDecoderStartup();
}
/** /**
* Stop the decoder and clears (and frees) its music pipe. * Stop the decoder and clears (and frees) its music pipe.
* *
...@@ -596,7 +601,7 @@ Player::SeekDecoder() noexcept ...@@ -596,7 +601,7 @@ Player::SeekDecoder() noexcept
StartDecoder(*pipe); StartDecoder(*pipe);
ActivateDecoder(); ActivateDecoder();
if (!WaitDecoderStartup()) if (!LockWaitDecoderStartup())
return false; return false;
} else { } else {
if (!IsDecoderAtCurrentSong()) { if (!IsDecoderAtCurrentSong()) {
...@@ -613,7 +618,7 @@ Player::SeekDecoder() noexcept ...@@ -613,7 +618,7 @@ Player::SeekDecoder() noexcept
(just in case that happens to be still in (just in case that happens to be still in
progress) */ progress) */
if (!WaitDecoderStartup()) if (!LockWaitDecoderStartup())
return false; return false;
/* send the SEEK command */ /* send the SEEK command */
......
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