player/Thread: mutex must be locked inside OpenOutput()
This commit is contained in:
parent
d0e735ee4b
commit
a5b8d7917f
@ -297,6 +297,8 @@ private:
|
|||||||
* Wrapper for MultipleOutputs::Open(). Upon failure, it
|
* Wrapper for MultipleOutputs::Open(). Upon failure, it
|
||||||
* pauses the player.
|
* pauses the player.
|
||||||
*
|
*
|
||||||
|
* Caller must lock the mutex.
|
||||||
|
*
|
||||||
* @return true on success
|
* @return true on success
|
||||||
*/
|
*/
|
||||||
bool OpenOutput();
|
bool OpenOutput();
|
||||||
@ -457,6 +459,7 @@ Player::OpenOutput()
|
|||||||
pc.state == PlayerState::PAUSE);
|
pc.state == PlayerState::PAUSE);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
const ScopeUnlock unlock(pc.mutex);
|
||||||
pc.outputs.Open(play_audio_format, buffer);
|
pc.outputs.Open(play_audio_format, buffer);
|
||||||
} catch (const std::runtime_error &e) {
|
} catch (const std::runtime_error &e) {
|
||||||
LogError(e);
|
LogError(e);
|
||||||
@ -467,7 +470,7 @@ Player::OpenOutput()
|
|||||||
audio output becomes available */
|
audio output becomes available */
|
||||||
paused = true;
|
paused = true;
|
||||||
|
|
||||||
pc.LockSetOutputError(std::current_exception());
|
pc.SetOutputError(std::current_exception());
|
||||||
|
|
||||||
idle_add(IDLE_PLAYER);
|
idle_add(IDLE_PLAYER);
|
||||||
|
|
||||||
@ -477,10 +480,7 @@ Player::OpenOutput()
|
|||||||
output_open = true;
|
output_open = true;
|
||||||
paused = false;
|
paused = false;
|
||||||
|
|
||||||
{
|
pc.state = PlayerState::PLAY;
|
||||||
const ScopeLock lock(pc.mutex);
|
|
||||||
pc.state = PlayerState::PLAY;
|
|
||||||
}
|
|
||||||
|
|
||||||
idle_add(IDLE_PLAYER);
|
idle_add(IDLE_PLAYER);
|
||||||
|
|
||||||
@ -510,8 +510,6 @@ Player::CheckDecoderStartup()
|
|||||||
play_audio_format = dc.out_audio_format;
|
play_audio_format = dc.out_audio_format;
|
||||||
decoder_starting = false;
|
decoder_starting = false;
|
||||||
|
|
||||||
const ScopeUnlock unlock(pc.mutex);
|
|
||||||
|
|
||||||
idle_add(IDLE_PLAYER);
|
idle_add(IDLE_PLAYER);
|
||||||
|
|
||||||
if (!paused && !OpenOutput()) {
|
if (!paused && !OpenOutput()) {
|
||||||
@ -698,9 +696,9 @@ Player::ProcessCommand()
|
|||||||
|
|
||||||
pc.state = PlayerState::PLAY;
|
pc.state = PlayerState::PLAY;
|
||||||
} else {
|
} else {
|
||||||
OpenOutput();
|
|
||||||
|
|
||||||
pc.Lock();
|
pc.Lock();
|
||||||
|
|
||||||
|
OpenOutput();
|
||||||
}
|
}
|
||||||
|
|
||||||
pc.CommandFinished();
|
pc.CommandFinished();
|
||||||
|
Loading…
Reference in New Issue
Block a user