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();
}
[[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
* DecoderState::DECODE.

View File

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