From c0d5bd204894d97802c1258f163bff9064d66e4e Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Fri, 8 Jul 2022 16:19:40 +0200 Subject: [PATCH] decoder/Thread: move code to DecoderControl::LockIsReplayGainEnabled() --- src/decoder/Control.hxx | 6 ++++++ src/decoder/Thread.cxx | 9 +++------ 2 files changed, 9 insertions(+), 6 deletions(-) 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); }