decoder/Thread: move code to DecoderControl::LockIsReplayGainEnabled()

This commit is contained in:
Max Kellermann 2022-07-08 16:19:40 +02:00
parent 666e5d7904
commit c0d5bd2048
2 changed files with 9 additions and 6 deletions

View File

@ -257,6 +257,12 @@ public:
return HasFailed(); return HasFailed();
} }
[[gnu::pure]]
bool LockIsReplayGainEnabled() const noexcept {
const std::scoped_lock<Mutex> protect(mutex);
return replay_gain_mode != ReplayGainMode::OFF;
}
/** /**
* Transition this obejct from DecoderState::START to * Transition this obejct from DecoderState::START to
* DecoderState::DECODE. * DecoderState::DECODE.

View File

@ -261,12 +261,9 @@ LoadReplayGain(DecoderClient &client, InputStream &is)
static void static void
MaybeLoadReplayGain(DecoderBridge &bridge, InputStream &is) MaybeLoadReplayGain(DecoderBridge &bridge, InputStream &is)
{ {
{ if (!bridge.dc.LockIsReplayGainEnabled())
const std::scoped_lock<Mutex> protect(bridge.dc.mutex); /* ReplayGain is disabled */
if (bridge.dc.replay_gain_mode == ReplayGainMode::OFF) return;
/* ReplayGain is disabled */
return;
}
LoadReplayGain(bridge, is); LoadReplayGain(bridge, is);
} }