diff --git a/src/mixer/Mixer.cxx b/src/mixer/Mixer.cxx index 8024b64a9..d79723cea 100644 --- a/src/mixer/Mixer.cxx +++ b/src/mixer/Mixer.cxx @@ -69,21 +69,22 @@ Mixer::_Close() noexcept int Mixer::LockGetVolume() { - if (IsGlobal() && !failure) - LockOpen(); - const std::scoped_lock lock{mutex}; - if (open) { - try { - return GetVolume(); - } catch (...) { - _Close(); - failure = std::current_exception(); - throw; - } - } else - return -1; + if (!open) { + if (IsGlobal() && !failure) + _Open(); + else + return -1; + } + + try { + return GetVolume(); + } catch (...) { + _Close(); + failure = std::current_exception(); + throw; + } } void @@ -91,13 +92,16 @@ Mixer::LockSetVolume(unsigned volume) { assert(volume <= 100); - if (IsGlobal() && !failure) - LockOpen(); - const std::scoped_lock lock{mutex}; - if (open) - SetVolume(volume); - else if (failure) - std::rethrow_exception(failure); + if (!open) { + if (failure) + std::rethrow_exception(failure); + else if (IsGlobal()) + _Open(); + else + return; + } + + SetVolume(volume); }