From 9b9e22731c137ef3f3febde7d4a914e1adfe6253 Mon Sep 17 00:00:00 2001 From: Michael Sevakis Date: Mon, 26 Feb 2007 17:15:04 +0000 Subject: SWCODEC: Fix the problem of replaygain not being applied unless the menu is entered. Make all codecs set the replay gain or else formats that do not have replaygain will not set the gain back to default if a file with gain applied proceeded them. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@12498 a1c6a512-1295-4272-9138-f99709370657 --- apps/codecs/a52.c | 3 ++- apps/codecs/adx.c | 2 ++ apps/codecs/aiff.c | 2 ++ apps/codecs/nsf.c | 2 ++ apps/codecs/shorten.c | 2 ++ apps/codecs/sid.c | 2 ++ apps/codecs/spc.c | 2 ++ apps/codecs/wav.c | 2 ++ apps/dsp.c | 13 ++++++++----- 9 files changed, 24 insertions(+), 6 deletions(-) diff --git a/apps/codecs/a52.c b/apps/codecs/a52.c index 23f5067d47..b2229d4c49 100644 --- a/apps/codecs/a52.c +++ b/apps/codecs/a52.c @@ -134,8 +134,9 @@ next_track: while (!ci->taginfo_ready) ci->yield(); - + ci->configure(DSP_SWITCH_FREQUENCY, ci->id3->frequency); + codec_set_replaygain(ci->id3); /* Intialise the A52 decoder and check for success */ state = a52_init(0); diff --git a/apps/codecs/adx.c b/apps/codecs/adx.c index 19d8110da6..337e07e721 100644 --- a/apps/codecs/adx.c +++ b/apps/codecs/adx.c @@ -70,6 +70,8 @@ next_track: /* wait for track info to load */ while (!*ci->taginfo_ready && !ci->stop_codec) ci->sleep(1); + + codec_set_replaygain(ci->id3); /* Read the entire file (or as much as possible) */ DEBUGF("ADX: request initial buffer\n"); diff --git a/apps/codecs/aiff.c b/apps/codecs/aiff.c index 2e92d9353f..7cb471c432 100644 --- a/apps/codecs/aiff.c +++ b/apps/codecs/aiff.c @@ -75,6 +75,8 @@ next_track: while (!*ci->taginfo_ready) ci->yield(); + + codec_set_replaygain(ci->id3); /* assume the AIFF header is less than 1024 bytes */ buf = ci->request_buffer(&n, 1024); diff --git a/apps/codecs/nsf.c b/apps/codecs/nsf.c index 0ca1275d5e..6f81c6a4bc 100644 --- a/apps/codecs/nsf.c +++ b/apps/codecs/nsf.c @@ -4344,6 +4344,8 @@ next_track: /* wait for track info to load */ while (!*ci->taginfo_ready && !ci->stop_codec) ci->sleep(1); + + codec_set_replaygain(ci->id3); /* Read the entire file */ DEBUGF("NSF: request file\n"); diff --git a/apps/codecs/shorten.c b/apps/codecs/shorten.c index dbfc272c5a..004a4070bd 100644 --- a/apps/codecs/shorten.c +++ b/apps/codecs/shorten.c @@ -61,6 +61,8 @@ next_track: while (!*ci->taginfo_ready) ci->yield(); + codec_set_replaygain(ci->id3); + /* Shorten decoder initialization */ ci->memset(&sc, 0, sizeof(ShortenContext)); diff --git a/apps/codecs/sid.c b/apps/codecs/sid.c index 7c53e8f189..1c98714357 100644 --- a/apps/codecs/sid.c +++ b/apps/codecs/sid.c @@ -1226,6 +1226,8 @@ next_track: while (!*ci->taginfo_ready) ci->yield(); + + codec_set_replaygain(ci->id3); /* Load SID file */ p = sidfile; diff --git a/apps/codecs/spc.c b/apps/codecs/spc.c index 8d621dd677..12b236c53d 100644 --- a/apps/codecs/spc.c +++ b/apps/codecs/spc.c @@ -829,6 +829,8 @@ enum codec_status codec_main(void) while (!*ci->taginfo_ready && !ci->stop_codec) ci->sleep(1); + codec_set_replaygain(ci->id3); + /* Read the entire file */ DEBUGF("SPC: request initial buffer\n"); ci->configure(CODEC_SET_FILEBUF_WATERMARK, ci->filesize); diff --git a/apps/codecs/wav.c b/apps/codecs/wav.c index b4eaaefb64..94099c543d 100644 --- a/apps/codecs/wav.c +++ b/apps/codecs/wav.c @@ -237,6 +237,8 @@ next_track: while (!*ci->taginfo_ready && !ci->stop_codec) ci->sleep(1); + + codec_set_replaygain(ci->id3); /* Need to save offset for later use (cleared indirectly by advance_buffer) */ bytesdone = ci->id3->offset; diff --git a/apps/dsp.c b/apps/dsp.c index f306069a87..f10bdfe2a6 100644 --- a/apps/dsp.c +++ b/apps/dsp.c @@ -1200,11 +1200,14 @@ bool dsp_configure(int setting, intptr_t value) void set_gain_var(long *var, long value) { /* Voice shouldn't mess with these */ - if (dsp != audio_dsp) - return; - - *var = value; - new_gain = true; + if (dsp == audio_dsp) + { + *var = value; + /* In case current gain is zero, force at least one call + to apply_gain or apply_gain won't pick up on new_gain */ + audio_dsp->gain = -1; + new_gain = true; + } } void update_functions(void) -- cgit v1.2.3