player/Thread: reduce unlock/lock overhead in PlayerCommand::PAUSE handler

This commit is contained in:
Max Kellermann 2016-12-14 20:24:52 +01:00
parent a5b8d7917f
commit d2e47e014a

View File

@ -681,23 +681,17 @@ Player::ProcessCommand()
break;
case PlayerCommand::PAUSE:
pc.Unlock();
paused = !paused;
if (paused) {
pc.outputs.Pause();
pc.Lock();
pc.state = PlayerState::PAUSE;
const ScopeUnlock unlock(pc.mutex);
pc.outputs.Pause();
} else if (!play_audio_format.IsDefined()) {
/* the decoder hasn't provided an audio format
yet - don't open the audio device yet */
pc.Lock();
pc.state = PlayerState::PLAY;
} else {
pc.Lock();
OpenOutput();
}