From d1766a1510b6092fa8ea0e644fdd1c1e508d9c4d Mon Sep 17 00:00:00 2001 From: Andree Buschmann Date: Mon, 4 Apr 2011 15:21:44 +0000 Subject: [PATCH] Rework parts of the replaygain code to be able to differentiate between 0.00 dB set intentionally and having no replaygain information at all. Bump codec api. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29679 a1c6a512-1295-4272-9138-f99709370657 --- apps/codecs.h | 4 ++-- apps/dsp.c | 4 ++-- apps/gui/skin_engine/skin_tokens.c | 4 ++-- apps/metadata.h | 2 ++ apps/replaygain.c | 18 +++++++++++------- apps/replaygain.h | 1 - apps/screens.c | 8 ++++---- 7 files changed, 23 insertions(+), 18 deletions(-) diff --git a/apps/codecs.h b/apps/codecs.h index daf2c8694e..d96b2a7c9a 100644 --- a/apps/codecs.h +++ b/apps/codecs.h @@ -75,12 +75,12 @@ #define CODEC_ENC_MAGIC 0x52454E43 /* RENC */ /* increase this every time the api struct changes */ -#define CODEC_API_VERSION 40 +#define CODEC_API_VERSION 41 /* update this to latest version if a change to the api struct breaks backwards compatibility (and please take the opportunity to sort in any new function which are "waiting" at the end of the function table) */ -#define CODEC_MIN_API_VERSION 40 +#define CODEC_MIN_API_VERSION 41 /* codec return codes */ enum codec_status { diff --git a/apps/dsp.c b/apps/dsp.c index 3aab2f2df5..3cff1918d7 100644 --- a/apps/dsp.c +++ b/apps/dsp.c @@ -1475,12 +1475,12 @@ intptr_t dsp_configure(struct dsp_config *dsp, int setting, intptr_t value) case DSP_SET_TRACK_GAIN: if (dsp == &AUDIO_DSP) - dsp_set_gain_var(&track_gain, value ? convert_gain(value) : 0); + dsp_set_gain_var(&track_gain, value); break; case DSP_SET_ALBUM_GAIN: if (dsp == &AUDIO_DSP) - dsp_set_gain_var(&album_gain, value ? convert_gain(value) : 0); + dsp_set_gain_var(&album_gain, value); break; case DSP_SET_TRACK_PEAK: diff --git a/apps/gui/skin_engine/skin_tokens.c b/apps/gui/skin_engine/skin_tokens.c index a315bae609..3aa7947edc 100644 --- a/apps/gui/skin_engine/skin_tokens.c +++ b/apps/gui/skin_engine/skin_tokens.c @@ -1332,11 +1332,11 @@ const char *get_token_value(struct gui_wps *gwps, /* due to above, coming here with !id3 shouldn't be possible */ case 2: case 4: - replaygain_itoa(buf, buf_size, id3->track_gain); + replaygain_itoa(buf, buf_size, id3->track_level); break; case 3: case 5: - replaygain_itoa(buf, buf_size, id3->album_gain); + replaygain_itoa(buf, buf_size, id3->album_level); break; } return buf; diff --git a/apps/metadata.h b/apps/metadata.h index 4c7e94f394..a520f40989 100644 --- a/apps/metadata.h +++ b/apps/metadata.h @@ -282,6 +282,8 @@ struct mp3entry { /* replaygain support */ #if CONFIG_CODEC == SWCODEC + long track_level; /* holds the level in dB * (1<track_gain) { - entry->track_gain = get_replaygain(value); + entry->track_level = get_replaygain(value); + entry->track_gain = convert_gain(entry->track_level); } else if (((strcasecmp(key, "replaygain_album_gain") == 0) || (strcasecmp(key, "rg_audiophile") == 0)) && !entry->album_gain) { - entry->album_gain = get_replaygain(value); + entry->album_level = get_replaygain(value); + entry->album_gain = convert_gain(entry->album_level); } else if (((strcasecmp(key, "replaygain_track_peak") == 0) || (strcasecmp(key, "rg_peak") == 0)) && @@ -207,12 +209,14 @@ void parse_replaygain_int(bool album, long gain, long peak, if (album) { - entry->album_gain = gain; - entry->album_peak = peak; + entry->album_level = gain; + entry->album_gain = convert_gain(gain); + entry->album_peak = peak; } else { - entry->track_gain = gain; - entry->track_peak = peak; + entry->track_level = gain; + entry->track_gain = convert_gain(gain); + entry->track_peak = peak; } } diff --git a/apps/replaygain.h b/apps/replaygain.h index 4fb5476e23..215464dfdf 100644 --- a/apps/replaygain.h +++ b/apps/replaygain.h @@ -30,6 +30,5 @@ void parse_replaygain(const char* key, const char* value, void parse_replaygain_int(bool album, long gain, long peak, struct mp3entry* entry); void replaygain_itoa(char* buffer, int length, long int_gain); -long convert_gain(long gain); #endif diff --git a/apps/screens.c b/apps/screens.c index b1a48c5bd6..6c70477fbd 100644 --- a/apps/screens.c +++ b/apps/screens.c @@ -729,12 +729,12 @@ static const char* id3_get_info(int selected_item, void* data, break; #if CONFIG_CODEC == SWCODEC case LANG_ID3_TRACK_GAIN: - replaygain_itoa(buffer, buffer_len, id3->track_gain); - val=(id3->track_gain) ? buffer : NULL; /* only show gains!=0 */ + replaygain_itoa(buffer, buffer_len, id3->track_level); + val=(id3->track_level) ? buffer : NULL; /* only show level!=0 */ break; case LANG_ID3_ALBUM_GAIN: - replaygain_itoa(buffer, buffer_len, id3->album_gain); - val=(id3->album_gain) ? buffer : NULL; /* only show gains!=0 */ + replaygain_itoa(buffer, buffer_len, id3->album_level); + val=(id3->album_level) ? buffer : NULL; /* only show level!=0 */ break; #endif case LANG_ID3_PATH: