From 15dcaeda0fbd0677300a26dbb090cea1cce41eaf Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Mon, 7 Aug 2017 17:40:40 +0200 Subject: [PATCH] output/Internal: remove mutex code from BeginPause(), IteratePause() --- src/output/Internal.cxx | 2 -- src/output/Thread.cxx | 20 +++++++++++++++++--- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/output/Internal.cxx b/src/output/Internal.cxx index 112fe98ca..5fe77584c 100644 --- a/src/output/Internal.cxx +++ b/src/output/Internal.cxx @@ -120,7 +120,6 @@ AudioOutput::Close(bool drain) noexcept void AudioOutput::BeginPause() noexcept { - const ScopeUnlock unlock(mutex); ao_plugin_cancel(*this); } @@ -128,7 +127,6 @@ bool AudioOutput::IteratePause() noexcept { try { - const ScopeUnlock unlock(mutex); return ao_plugin_pause(*this); } catch (const std::runtime_error &e) { FormatError(e, "\"%s\" [%s] failed to pause", diff --git a/src/output/Thread.cxx b/src/output/Thread.cxx index f2507bdaf..015f37035 100644 --- a/src/output/Thread.cxx +++ b/src/output/Thread.cxx @@ -343,7 +343,11 @@ AudioOutputControl::InternalPlay() noexcept inline void AudioOutputControl::InternalPause() noexcept { - output->BeginPause(); + { + const ScopeUnlock unlock(mutex); + output->BeginPause(); + } + pause = true; CommandFinished(); @@ -352,14 +356,24 @@ AudioOutputControl::InternalPause() noexcept if (!WaitForDelay()) break; - if (!output->IteratePause()) { + bool success; + { + const ScopeUnlock unlock(mutex); + success = output->IteratePause(); + } + + if (!success) { InternalClose(false); break; } } while (command == Command::NONE); pause = false; - output->EndPause(); + + { + const ScopeUnlock unlock(mutex); + output->EndPause(); + } skip_delay = true; }