From 5990017d5174321c560e8a7d66ac106115dcf443 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Mon, 7 Aug 2017 17:39:20 +0200 Subject: [PATCH] output/Internal: remove mutex code from Enable() and Disable() --- src/output/Internal.cxx | 2 -- src/output/Thread.cxx | 8 +++++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/output/Internal.cxx b/src/output/Internal.cxx index 1e46a29f1..faaf28532 100644 --- a/src/output/Internal.cxx +++ b/src/output/Internal.cxx @@ -32,7 +32,6 @@ void AudioOutput::Enable() { try { - const ScopeUnlock unlock(mutex); ao_plugin_enable(*this); } catch (const std::runtime_error &e) { std::throw_with_nested(FormatRuntimeError("Failed to enable output \"%s\" [%s]", @@ -43,7 +42,6 @@ AudioOutput::Enable() void AudioOutput::Disable() noexcept { - const ScopeUnlock unlock(mutex); ao_plugin_disable(*this); } diff --git a/src/output/Thread.cxx b/src/output/Thread.cxx index 3bce9cfa6..f2507bdaf 100644 --- a/src/output/Thread.cxx +++ b/src/output/Thread.cxx @@ -104,7 +104,11 @@ AudioOutputControl::InternalEnable() noexcept last_error = nullptr; try { - output->Enable(); + { + const ScopeUnlock unlock(mutex); + output->Enable(); + } + really_enabled = true; return true; } catch (const std::runtime_error &e) { @@ -124,6 +128,8 @@ AudioOutputControl::InternalDisable() noexcept InternalCheckClose(false); really_enabled = false; + + const ScopeUnlock unlock(mutex); output->Disable(); }