diff options
author | Max Kellermann <max@musicpd.org> | 2018-01-03 17:12:21 +0100 |
---|---|---|
committer | Max Kellermann <max@musicpd.org> | 2018-01-03 17:12:21 +0100 |
commit | ec113420f150d891cb91fd2f742d4795af2763e8 (patch) | |
tree | eb12f316b268696feee7ad65a8b23235661b37b0 /src/player/Thread.cxx | |
parent | 1954e94de2b3c7fc09cccc246228079872acf3e8 (diff) |
player/Thread: hold mutex while calling SongBorder()
Eliminates unnecessary mutex locks.
Diffstat (limited to 'src/player/Thread.cxx')
-rw-r--r-- | src/player/Thread.cxx | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/src/player/Thread.cxx b/src/player/Thread.cxx index 801114d06..ebc8abf87 100644 --- a/src/player/Thread.cxx +++ b/src/player/Thread.cxx @@ -333,7 +333,7 @@ private: * has consumed all chunks of the current song, and we should start * sending chunks from the next one. * - * The player lock is not held. + * Caller must lock the mutex. */ void SongBorder() noexcept; @@ -968,20 +968,22 @@ Player::PlayNextChunk() noexcept inline void Player::SongBorder() noexcept { - FormatDefault(player_domain, "played \"%s\"", song->GetURI()); + { + const ScopeUnlock unlock(pc.mutex); - throttle_silence_log.Reset(); + FormatDefault(player_domain, "played \"%s\"", song->GetURI()); - ReplacePipe(dc.pipe); + throttle_silence_log.Reset(); - pc.outputs.SongBorder(); + ReplacePipe(dc.pipe); - { - const std::lock_guard<Mutex> lock(pc.mutex); - ActivateDecoder(); + + pc.outputs.SongBorder(); } - const bool border_pause = pc.LockApplyBorderPause(); + ActivateDecoder(); + + const bool border_pause = pc.ApplyBorderPause(); if (border_pause) { paused = true; idle_add(IDLE_PLAYER); @@ -1101,7 +1103,6 @@ Player::Run() noexcept } else if (IsDecoderAtNextSong()) { /* at the beginning of a new song */ - const ScopeUnlock unlock(pc.mutex); SongBorder(); } else if (dc.IsIdle()) { /* check the size of the pipe again, because |