diff --git a/src/decoder/Control.hxx b/src/decoder/Control.hxx index 27d302875..1aa257f09 100644 --- a/src/decoder/Control.hxx +++ b/src/decoder/Control.hxx @@ -257,6 +257,12 @@ public: return HasFailed(); } + [[gnu::pure]] + bool LockIsReplayGainEnabled() const noexcept { + const std::scoped_lock protect(mutex); + return replay_gain_mode != ReplayGainMode::OFF; + } + /** * Transition this obejct from DecoderState::START to * DecoderState::DECODE. diff --git a/src/decoder/Thread.cxx b/src/decoder/Thread.cxx index b302dab72..4432c6605 100644 --- a/src/decoder/Thread.cxx +++ b/src/decoder/Thread.cxx @@ -261,12 +261,9 @@ LoadReplayGain(DecoderClient &client, InputStream &is) static void MaybeLoadReplayGain(DecoderBridge &bridge, InputStream &is) { - { - const std::scoped_lock protect(bridge.dc.mutex); - if (bridge.dc.replay_gain_mode == ReplayGainMode::OFF) - /* ReplayGain is disabled */ - return; - } + if (!bridge.dc.LockIsReplayGainEnabled()) + /* ReplayGain is disabled */ + return; LoadReplayGain(bridge, is); }