From 7be33eba489825d3a36f3ccbb3571002fcc06c0b Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Sat, 5 Jan 2013 02:07:44 +0100 Subject: DecoderAPI: don't use replay_gain_get_real_mode() replay_gain_get_real_mode() accesses dangerous globals. Let's just use the global variable replay_gain_mode, and assume "AUTO" means "TRACK". At this point, this is the best we can do, because neither the decoder nor the player should know about the current replay gain mode. This is applied as a filter in the output thread. --- src/DecoderAPI.cxx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/DecoderAPI.cxx') diff --git a/src/DecoderAPI.cxx b/src/DecoderAPI.cxx index c703faa6..6e0460a8 100644 --- a/src/DecoderAPI.cxx +++ b/src/DecoderAPI.cxx @@ -531,9 +531,13 @@ decoder_replay_gain(struct decoder *decoder, serial = 1; if (REPLAY_GAIN_OFF != replay_gain_mode) { + enum replay_gain_mode rgm = replay_gain_mode; + if (rgm != REPLAY_GAIN_ALBUM) + rgm = REPLAY_GAIN_TRACK; + decoder->dc->replay_gain_db = 20.0 * log10f( replay_gain_tuple_scale( - &replay_gain_info->tuples[replay_gain_get_real_mode()], + &replay_gain_info->tuples[rgm], replay_gain_preamp, replay_gain_missing_preamp, replay_gain_limit)); } -- cgit v1.2.3