summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
authorMagnus Holmgren <magnushol@gmail.com>2005-07-27 11:54:33 +0000
committerMagnus Holmgren <magnushol@gmail.com>2005-07-27 11:54:33 +0000
commit988ea2cffc36d891d5b4752484c741a98eddede3 (patch)
tree7118198c6da300be6f5d90692988d243bcbcda04 /apps
parente44372ef18cbf30f0e174ed76be4ee4e6206f2cc (diff)
downloadrockbox-988ea2cffc36d891d5b4752484c741a98eddede3.zip
rockbox-988ea2cffc36d891d5b4752484c741a98eddede3.tar.gz
rockbox-988ea2cffc36d891d5b4752484c741a98eddede3.tar.bz2
rockbox-988ea2cffc36d891d5b4752484c741a98eddede3.tar.xz
Added support for ID3V2 ReplayGain tags (as written by Foobar). Generalized the replaygain tag parsing a bit, to cut down the code size (APE tags should use this as well, but as it requires larger changes, it will have to wait for another commit). Also fixed a bug in the ID3V2 parser; ISO-8859-1 strings could confuse the main parsing loop (causing bufferpos to come out of sync).
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@7243 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps')
-rw-r--r--apps/codecs/mpa.c3
-rw-r--r--apps/metadata.c38
-rw-r--r--apps/screens.c8
3 files changed, 13 insertions, 36 deletions
diff --git a/apps/codecs/mpa.c b/apps/codecs/mpa.c
index 2dcc719..fb47822 100644
--- a/apps/codecs/mpa.c
+++ b/apps/codecs/mpa.c
@@ -118,6 +118,7 @@ enum codec_status codec_start(struct codec_api* api)
frequency_divider = 441;
ci->configure(DSP_SET_FREQUENCY, (int *)ci->id3->frequency);
+ codec_set_replaygain(ci->id3);
ci->request_buffer(&size, ci->id3->first_frame_offset);
ci->advance_buffer(size);
@@ -144,7 +145,7 @@ enum codec_status codec_start(struct codec_api* api)
samplecount = ci->id3->length * frequency_divider / 10;
samplesdone = ci->id3->elapsed * frequency_divider / 10;
}
-
+
/* This is the decoding loop. */
while (1) {
ci->yield();
diff --git a/apps/metadata.c b/apps/metadata.c
index 409bdf8..bbbfe07 100644
--- a/apps/metadata.c
+++ b/apps/metadata.c
@@ -528,7 +528,7 @@ static bool get_apetag_info (struct mp3entry *entry, int fd)
if (rem_space > 1 &&
get_apetag_item (&temp_apetag, "replaygain_track_gain", temp_buffer, rem_space)) {
- entry->track_gain = get_replaygain (entry->track_gain_str = temp_buffer);
+ entry->track_gain = get_replaygain (entry->track_gain_string = temp_buffer);
str_space = strlen (temp_buffer) + 1;
temp_buffer += str_space;
rem_space -= str_space;
@@ -536,7 +536,7 @@ static bool get_apetag_info (struct mp3entry *entry, int fd)
if (rem_space > 1 &&
get_apetag_item (&temp_apetag, "replaygain_album_gain", temp_buffer, rem_space)) {
- entry->album_gain = get_replaygain (entry->album_gain_str = temp_buffer);
+ entry->album_gain = get_replaygain (entry->album_gain_string = temp_buffer);
str_space = strlen (temp_buffer) + 1;
temp_buffer += str_space;
rem_space -= str_space;
@@ -910,37 +910,13 @@ static bool get_vorbis_comments (struct mp3entry *entry, int fd)
} else if (strncasecmp(temp, "TRACKNUMBER=", 12) == 0) {
name_length = 11;
p = &(entry->track_string);
- } else if ((strncasecmp(temp, "RG_RADIO=", 9) == 0)
- && !entry->track_gain) {
- entry->track_gain = get_replaygain(&temp[9]);
- name_length = 8;
- p = &(entry->track_gain_str);
- } else if (strncasecmp(temp, "REPLAYGAIN_TRACK_GAIN=", 22) == 0) {
- entry->track_gain = get_replaygain(&temp[22]);
- name_length = 21;
- p = &(entry->track_gain_str);
- } else if ((strncasecmp(temp, "RG_AUDIOPHILE=", 14) == 0)
- && !entry->album_gain) {
- entry->album_gain = get_replaygain(&temp[14]);
- name_length = 13;
- p = &(entry->album_gain_str);
- } else if (strncasecmp(temp, "REPLAYGAIN_ALBUM_GAIN=", 22) == 0) {
- entry->album_gain = get_replaygain(&temp[22]);
- name_length = 21;
- p = &(entry->album_gain_str);
- } else if ((strncasecmp(temp, "RG_PEAK=", 8) == 0)
- && !entry->track_peak) {
- entry->track_peak = get_replaypeak(&temp[8]);
- p = NULL;
- } else if (strncasecmp(temp, "REPLAYGAIN_TRACK_PEAK=", 22) == 0) {
- entry->track_peak = get_replaypeak(&temp[22]);
- p = NULL;
- } else if (strncasecmp(temp, "REPLAYGAIN_ALBUM_PEAK=", 22) == 0) {
- entry->album_peak = get_replaypeak(&temp[22]);
- p = NULL;
} else {
+ int value_length = parse_replaygain(temp, NULL, entry, buffer,
+ buffer_remaining);
+ buffer_remaining -= value_length;
+ buffer += value_length;
p = NULL;
- }
+ }
if (p) {
comment_length -= (name_length + 1);
diff --git a/apps/screens.c b/apps/screens.c
index 86d11a7..2c7d5fe 100644
--- a/apps/screens.c
+++ b/apps/screens.c
@@ -1388,15 +1388,15 @@ bool browse_id3(void)
#if CONFIG_HWCODEC == MASNONE
case 11:
lcd_puts(0, 0, str(LANG_ID3_TRACK_GAIN));
- lcd_puts(0, 1, id3->track_gain_str
- ? id3->track_gain_str
+ lcd_puts(0, 1, id3->track_gain_string
+ ? id3->track_gain_string
: (char*) str(LANG_ID3_NO_GAIN));
break;
case 12:
lcd_puts(0, 0, str(LANG_ID3_ALBUM_GAIN));
- lcd_puts(0, 1, id3->album_gain_str
- ? id3->album_gain_str
+ lcd_puts(0, 1, id3->album_gain_string
+ ? id3->album_gain_string
: (char*) str(LANG_ID3_NO_GAIN));
break;
#endif