From b477f86c922b30621cb7297b706038440a262eb5 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Wed, 14 Nov 2018 11:49:48 +0100 Subject: [PATCH] output/alsa: don't lock the mutex in CancelInternal() CancelInternal() doesn't need to be protected because it is called synchronously from Cancel(). --- src/output/plugins/AlsaOutputPlugin.cxx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/output/plugins/AlsaOutputPlugin.cxx b/src/output/plugins/AlsaOutputPlugin.cxx index b258ed1fd..abacb099a 100644 --- a/src/output/plugins/AlsaOutputPlugin.cxx +++ b/src/output/plugins/AlsaOutputPlugin.cxx @@ -796,6 +796,9 @@ AlsaOutput::Drain() inline void AlsaOutput::CancelInternal() noexcept { + /* this method doesn't need to lock the mutex because while it + runs, the calling thread is blocked inside Cancel() */ + must_prepare = true; snd_pcm_drop(pcm); @@ -804,10 +807,7 @@ AlsaOutput::CancelInternal() noexcept period_buffer.Clear(); ring_buffer->reset(); - { - const std::lock_guard lock(mutex); - active = false; - } + active = false; MultiSocketMonitor::Reset(); defer_invalidate_sockets.Cancel();