summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
authorBrandon Low <lostlogic@rockbox.org>2006-04-14 04:42:11 +0000
committerBrandon Low <lostlogic@rockbox.org>2006-04-14 04:42:11 +0000
commit2f4edabfcecbbde68d531a9c11e8a6ecec9517b3 (patch)
tree30d7d81421a6a372959109163f453413e9d8e856 /apps
parent2f11d60dcd1dec9305f85b60144213de5c3ca96b (diff)
downloadrockbox-2f4edabfcecbbde68d531a9c11e8a6ecec9517b3.zip
rockbox-2f4edabfcecbbde68d531a9c11e8a6ecec9517b3.tar.gz
rockbox-2f4edabfcecbbde68d531a9c11e8a6ecec9517b3.tar.bz2
rockbox-2f4edabfcecbbde68d531a9c11e8a6ecec9517b3.tar.xz
Tweak id3v1 tag stripping, better code, same functionality. Ensure correct buf_idx on track when rebuffer&seek.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@9653 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps')
-rw-r--r--apps/playback.c47
1 files changed, 20 insertions, 27 deletions
diff --git a/apps/playback.c b/apps/playback.c
index 808cb52..01f165c 100644
--- a/apps/playback.c
+++ b/apps/playback.c
@@ -892,7 +892,7 @@ static void rebuffer_and_seek(size_t newpos)
/* Clear codec buffer. */
filebufused = 0;
- buf_ridx = buf_widx = 0;
+ buf_ridx = buf_widx = cur_ti->buf_idx + newpos;
/* Write to the now current track */
track_widx = track_ridx;
@@ -1113,39 +1113,32 @@ void strip_id3v1_tag(void)
{
int i;
static const unsigned char tag[] = "TAG";
- size_t tagptr;
- bool found = true;
+ size_t tag_idx;
+ size_t cur_idx;
- if (filebufused >= 128)
- {
- tagptr = buf_widx;
- if (tagptr < 128)
- tagptr += filebuflen;
- tagptr -= 128;
+ tag_idx = buf_widx;
+ if (tag_idx < 128)
+ tag_idx += filebuflen;
+ tag_idx -= 128;
+ if (filebufused > 128 && tag_idx > buf_ridx)
+ {
+ cur_idx = tag_idx;
for(i = 0;i < 3;i++)
{
- if(filebuf[tagptr] != tag[i])
- {
- found = false;
- break;
- }
+ if(filebuf[cur_idx] != tag[i])
+ return;
- if(++tagptr >= filebuflen)
- tagptr -= filebuflen;
+ if(++cur_idx >= filebuflen)
+ cur_idx -= filebuflen;
}
- if(found)
- {
- /* Skip id3v1 tag */
- logf("Skipping ID3v1 tag");
- if (buf_widx < 128)
- buf_widx += filebuflen;
- buf_widx -= 128;
- tracks[track_widx].available -= 128;
- tracks[track_widx].filesize -= 128;
- filebufused -= 128;
- }
+ /* Skip id3v1 tag */
+ logf("Skipping ID3v1 tag");
+ buf_widx = tag_idx;
+ tracks[track_widx].available -= 128;
+ tracks[track_widx].filesize -= 128;
+ filebufused -= 128;
}
}