player/Thread: move mutex lock out of WaitDecoderStartup()
This commit is contained in:
@@ -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:
|
|||||||
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
|
|||||||
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
|
|||||||
(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 */
|
||||||
|
Reference in New Issue
Block a user