diff --git a/src/output/Internal.hxx b/src/output/Internal.hxx index 7c338588a..496f2235a 100644 --- a/src/output/Internal.hxx +++ b/src/output/Internal.hxx @@ -323,13 +323,17 @@ public: /** * Enables the device. + * + * Caller must lock the mutex. */ - void LockEnableWait(); + void EnableWait(); /** * Disables the device. + * + * Caller must lock the mutex. */ - void LockDisableWait(); + void DisableWait(); void LockPauseAsync(); diff --git a/src/output/MultipleOutputs.cxx b/src/output/MultipleOutputs.cxx index a9228b457..34fb23acf 100644 --- a/src/output/MultipleOutputs.cxx +++ b/src/output/MultipleOutputs.cxx @@ -44,7 +44,11 @@ MultipleOutputs::MultipleOutputs(MixerListener &_mixer_listener) MultipleOutputs::~MultipleOutputs() { for (auto i : outputs) { - i->LockDisableWait(); + { + const ScopeLock lock(i->mutex); + i->DisableWait(); + } + i->Finish(); } } @@ -107,17 +111,13 @@ void MultipleOutputs::EnableDisable() { for (auto ao : outputs) { - bool enabled; + const ScopeLock lock(ao->mutex); - ao->mutex.lock(); - enabled = ao->really_enabled; - ao->mutex.unlock(); - - if (ao->enabled != enabled) { + if (ao->enabled != ao->really_enabled) { if (ao->enabled) - ao->LockEnableWait(); + ao->EnableWait(); else - ao->LockDisableWait(); + ao->DisableWait(); } } } diff --git a/src/output/OutputControl.cxx b/src/output/OutputControl.cxx index a848063d9..17ba3da53 100644 --- a/src/output/OutputControl.cxx +++ b/src/output/OutputControl.cxx @@ -70,7 +70,7 @@ AudioOutput::LockCommandWait(Command cmd) } void -AudioOutput::LockEnableWait() +AudioOutput::EnableWait() { if (!thread.IsDefined()) { if (plugin.enable == nullptr) { @@ -84,11 +84,11 @@ AudioOutput::LockEnableWait() StartThread(); } - LockCommandWait(Command::ENABLE); + CommandWait(Command::ENABLE); } void -AudioOutput::LockDisableWait() +AudioOutput::DisableWait() { if (!thread.IsDefined()) { if (plugin.disable == nullptr) @@ -101,7 +101,7 @@ AudioOutput::LockDisableWait() return; } - LockCommandWait(Command::DISABLE); + CommandWait(Command::DISABLE); } inline bool