diff options
-rw-r--r-- | firmware/mpeg.c | 46 |
1 files changed, 34 insertions, 12 deletions
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) | |||
1717 | t2 = current_tick; | 1717 | t2 = current_tick; |
1718 | DEBUGF("time: %d\n", t2 - t1); | 1718 | DEBUGF("time: %d\n", t2 - t1); |
1719 | DEBUGF("R: %x\n", len); | 1719 | DEBUGF("R: %x\n", len); |
1720 | 1720 | ||
1721 | /* Make sure that the write pointer is at a word | 1721 | /* Now make sure that we don't feed the MAS with ID3V1 |
1722 | boundary when we reach the end of the file */ | 1722 | data */ |
1723 | if (len < amount_to_read) { | 1723 | if (len < amount_to_read) |
1724 | /* Skip id3v1 tag */ | 1724 | { |
1725 | DEBUGF("Skipping ID3v1 tag\n"); | 1725 | int tagptr = mp3buf_write + len - 128; |
1726 | len -= id3tags[tag_read_idx]->id3.id3v1len; | 1726 | int i; |
1727 | /* The very rare case when the buffer wrapped | 1727 | char *tag = "TAG"; |
1728 | inside the tag must be taken care of */ | 1728 | int taglen = 128; |
1729 | if(len < 0) | 1729 | |
1730 | len = 0; | 1730 | for(i = 0;i < 3;i++) |
1731 | } | 1731 | { |
1732 | if(tagptr >= mp3buflen) | ||
1733 | tagptr -= mp3buflen; | ||
1734 | |||
1735 | if(mp3buf[tagptr] != tag[i]) | ||
1736 | taglen = 0; | ||
1737 | |||
1738 | tagptr++; | ||
1739 | } | ||
1740 | |||
1741 | if(taglen) | ||
1742 | { | ||
1743 | /* Skip id3v1 tag */ | ||
1744 | DEBUGF("Skipping ID3v1 tag\n"); | ||
1745 | len -= taglen; | ||
1746 | |||
1747 | /* The very rare case when the entire tag | ||
1748 | wasn't read in this read() call must be | ||
1749 | taken care of */ | ||
1750 | if(len < 0) | ||
1751 | len = 0; | ||
1752 | } | ||
1753 | } | ||
1732 | 1754 | ||
1733 | mp3buf_write += len; | 1755 | mp3buf_write += len; |
1734 | 1756 | ||