player/Thread: move mutex lock out of StartDecoder()
This commit is contained in:
@@ -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
|
|||||||
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
|
|||||||
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
|
|||||||
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
|
|||||||
{
|
{
|
||||||
pipe = new MusicPipe();
|
pipe = new MusicPipe();
|
||||||
|
|
||||||
StartDecoder(*pipe);
|
|
||||||
pc.Lock();
|
pc.Lock();
|
||||||
|
|
||||||
|
StartDecoder(*pipe);
|
||||||
ActivateDecoder();
|
ActivateDecoder();
|
||||||
|
|
||||||
pc.state = PlayerState::PLAY;
|
pc.state = PlayerState::PLAY;
|
||||||
|
Reference in New Issue
Block a user