From 505d0bfa513153a5f566b51731425df71c187b1f Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Fri, 22 Dec 2017 00:46:03 +0100 Subject: [PATCH] player/Thread: move mutex lock out of StopDecoder() --- src/player/Thread.cxx | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/player/Thread.cxx b/src/player/Thread.cxx index eb8f47b92..433823d5e 100644 --- a/src/player/Thread.cxx +++ b/src/player/Thread.cxx @@ -239,7 +239,7 @@ private: /** * Stop the decoder and clears (and frees) its music pipe. * - * Player lock is not held. + * Caller must lock the mutex. */ void StopDecoder() noexcept; @@ -373,7 +373,6 @@ void Player::StopDecoder() noexcept { const PlayerControl::ScopeOccupied occupied(pc); - const std::lock_guard protect(pc.mutex); dc.Stop(); @@ -592,7 +591,10 @@ Player::SeekDecoder() noexcept /* the decoder is already decoding the "next" song - stop it and start the previous song again */ - StopDecoder(); + { + const std::lock_guard lock(pc.mutex); + StopDecoder(); + } /* clear music chunks which might still reside in the pipe */ @@ -727,12 +729,10 @@ Player::ProcessCommand() noexcept return; } - if (IsDecoderAtNextSong()) { + if (IsDecoderAtNextSong()) /* the decoder is already decoding the song - stop it and reset the position */ - const ScopeUnlock unlock(pc.mutex); StopDecoder(); - } pc.next_song.reset(); queued = false; @@ -1120,6 +1120,8 @@ Player::Run() noexcept pc.Lock(); } + const std::lock_guard lock(pc.mutex); + StopDecoder(); ClearAndDeletePipe(); @@ -1131,8 +1133,6 @@ Player::Run() noexcept song.reset(); } - const std::lock_guard lock(pc.mutex); - pc.ClearTaggedSong(); if (queued) {