Commit 0772e571 authored by Max Kellermann's avatar Max Kellermann

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

parent 910496ce
...@@ -183,7 +183,7 @@ private: ...@@ -183,7 +183,7 @@ private:
/** /**
* Start the decoder. * Start the decoder.
* *
* Player lock is not held. * Caller must lock the mutex.
*/ */
void StartDecoder(MusicPipe &pipe) noexcept; void StartDecoder(MusicPipe &pipe) noexcept;
...@@ -361,8 +361,6 @@ Player::StartDecoder(MusicPipe &_pipe) noexcept ...@@ -361,8 +361,6 @@ Player::StartDecoder(MusicPipe &_pipe) noexcept
assert(queued || pc.command == PlayerCommand::SEEK); assert(queued || pc.command == PlayerCommand::SEEK);
assert(pc.next_song != nullptr); assert(pc.next_song != nullptr);
const std::lock_guard<Mutex> protect(pc.mutex);
/* copy ReplayGain parameters to the decoder */ /* copy ReplayGain parameters to the decoder */
dc.replay_gain_mode = pc.replay_gain_mode; dc.replay_gain_mode = pc.replay_gain_mode;
...@@ -630,9 +628,9 @@ Player::SeekDecoder() noexcept ...@@ -630,9 +628,9 @@ Player::SeekDecoder() noexcept
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);
const std::lock_guard<Mutex> lock(pc.mutex);
ActivateDecoder(); ActivateDecoder();
if (!WaitDecoderStartup()) if (!WaitDecoderStartup())
...@@ -699,11 +697,8 @@ Player::ProcessCommand() noexcept ...@@ -699,11 +697,8 @@ Player::ProcessCommand() noexcept
queued = true; queued = true;
pc.CommandFinished(); pc.CommandFinished();
{ if (dc.IsIdle())
const ScopeUnlock unlock(pc.mutex);
if (dc.LockIsIdle())
StartDecoder(*new MusicPipe()); StartDecoder(*new MusicPipe());
}
break; break;
...@@ -981,8 +976,9 @@ Player::Run() noexcept ...@@ -981,8 +976,9 @@ Player::Run() noexcept
{ {
pipe = new MusicPipe(); pipe = new MusicPipe();
StartDecoder(*pipe);
pc.Lock(); pc.Lock();
StartDecoder(*pipe);
ActivateDecoder(); ActivateDecoder();
pc.state = PlayerState::PLAY; pc.state = PlayerState::PLAY;
......
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