diff --git a/src/output/Internal.hxx b/src/output/Internal.hxx index 496f2235a..a6f0d9d2e 100644 --- a/src/output/Internal.hxx +++ b/src/output/Internal.hxx @@ -335,6 +335,23 @@ public: */ void DisableWait(); + /** + * Attempt to enable or disable the device as specified by the + * #enabled attribute; attempt to sync it with #really_enabled + * (wrapper for EnableWait() or DisableWait()). + * + * Caller must lock the mutex. + */ + void EnableDisableWait() { + if (enabled == really_enabled) + return; + + if (enabled) + EnableWait(); + else + DisableWait(); + } + void LockPauseAsync(); /** diff --git a/src/output/MultipleOutputs.cxx b/src/output/MultipleOutputs.cxx index 34fb23acf..7b7a99146 100644 --- a/src/output/MultipleOutputs.cxx +++ b/src/output/MultipleOutputs.cxx @@ -112,13 +112,7 @@ MultipleOutputs::EnableDisable() { for (auto ao : outputs) { const ScopeLock lock(ao->mutex); - - if (ao->enabled != ao->really_enabled) { - if (ao->enabled) - ao->EnableWait(); - else - ao->DisableWait(); - } + ao->EnableDisableWait(); } }