From cc136c5c606556a59fcf6ca15ed76e2c1ce2c085 Mon Sep 17 00:00:00 2001 From: Linus Nielsen Feltzing Date: Sun, 2 Mar 2003 03:58:54 +0000 Subject: Now correctly skips ID3V1 tags to avoid gaps between tracks git-svn-id: svn://svn.rockbox.org/rockbox/trunk@3365 a1c6a512-1295-4272-9138-f99709370657 --- firmware/mpeg.c | 46 ++++++++++++++++++++++++++++++++++------------ 1 file changed, 34 insertions(+), 12 deletions(-) (limited to 'firmware/mpeg.c') diff --git a/firmware/mpeg.c b/firmware/mpeg.c index b0f183592e..47b93bf77a 100644 --- a/firmware/mpeg.c +++ b/firmware/mpeg.c @@ -1717,18 +1717,40 @@ static void mpeg_thread(void) t2 = current_tick; DEBUGF("time: %d\n", t2 - t1); DEBUGF("R: %x\n", len); - - /* Make sure that the write pointer is at a word - boundary when we reach the end of the file */ - if (len < amount_to_read) { - /* Skip id3v1 tag */ - DEBUGF("Skipping ID3v1 tag\n"); - len -= id3tags[tag_read_idx]->id3.id3v1len; - /* The very rare case when the buffer wrapped - inside the tag must be taken care of */ - if(len < 0) - len = 0; - } + + /* Now make sure that we don't feed the MAS with ID3V1 + data */ + if (len < amount_to_read) + { + int tagptr = mp3buf_write + len - 128; + int i; + char *tag = "TAG"; + int taglen = 128; + + for(i = 0;i < 3;i++) + { + if(tagptr >= mp3buflen) + tagptr -= mp3buflen; + + if(mp3buf[tagptr] != tag[i]) + taglen = 0; + + tagptr++; + } + + if(taglen) + { + /* Skip id3v1 tag */ + DEBUGF("Skipping ID3v1 tag\n"); + len -= taglen; + + /* The very rare case when the entire tag + wasn't read in this read() call must be + taken care of */ + if(len < 0) + len = 0; + } + } mp3buf_write += len; -- cgit v1.2.3