Commit 86e8b8c1 authored by Max Kellermann's avatar Max Kellermann

decoder/Thread: skip the ReplayGain loader if the feature is disabled

parent ee57c349
...@@ -257,6 +257,23 @@ LoadReplayGain(DecoderClient &client, InputStream &is) ...@@ -257,6 +257,23 @@ LoadReplayGain(DecoderClient &client, InputStream &is)
} }
/** /**
* Call LoadReplayGain() unless ReplayGain is disabled. This saves
* the I/O overhead when the user is not interested in the feature.
*/
static void
MaybeLoadReplayGain(DecoderBridge &bridge, InputStream &is)
{
{
const ScopeLock protect(bridge.dc.mutex);
if (bridge.dc.replay_gain_mode == ReplayGainMode::OFF)
/* ReplayGain is disabled */
return;
}
LoadReplayGain(bridge, is);
}
/**
* Try decoding a stream. * Try decoding a stream.
* *
* DecoderControl::mutex is not locked by caller. * DecoderControl::mutex is not locked by caller.
...@@ -269,7 +286,7 @@ decoder_run_stream(DecoderBridge &bridge, const char *uri) ...@@ -269,7 +286,7 @@ decoder_run_stream(DecoderBridge &bridge, const char *uri)
auto input_stream = decoder_input_stream_open(dc, uri); auto input_stream = decoder_input_stream_open(dc, uri);
assert(input_stream); assert(input_stream);
LoadReplayGain(bridge, *input_stream); MaybeLoadReplayGain(bridge, *input_stream);
const ScopeLock protect(dc.mutex); const ScopeLock protect(dc.mutex);
...@@ -376,7 +393,7 @@ decoder_run_file(DecoderBridge &bridge, const char *uri_utf8, Path path_fs) ...@@ -376,7 +393,7 @@ decoder_run_file(DecoderBridge &bridge, const char *uri_utf8, Path path_fs)
assert(input_stream); assert(input_stream);
LoadReplayGain(bridge, *input_stream); MaybeLoadReplayGain(bridge, *input_stream);
auto &is = *input_stream; auto &is = *input_stream;
return decoder_plugins_try([&bridge, path_fs, suffix, return decoder_plugins_try([&bridge, path_fs, suffix,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment