summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBjörn Stenberg <bjorn@haxx.se>2002-09-09 22:31:11 +0000
committerBjörn Stenberg <bjorn@haxx.se>2002-09-09 22:31:11 +0000
commitf50b4fc20c8c8f61169406ae63f05c5ce9e31a87 (patch)
tree839ef44b5616238538e682277b6b22f516901fbb
parentddfa4cb0e566f1abc91eb963de22aebc58551743 (diff)
Read tracknum from id3v1.1 tag (Kenneth Kiraly)
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@2248 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--firmware/id3.c40
1 files changed, 23 insertions, 17 deletions
diff --git a/firmware/id3.c b/firmware/id3.c
index d83285568f..4df5ad020a 100644
--- a/firmware/id3.c
+++ b/firmware/id3.c
@@ -115,32 +115,38 @@ stripspaces(char *buffer)
*/
static bool setid3v1title(int fd, struct mp3entry *entry)
{
- char buffer[31];
- int offsets[3] = {-95,-65,-125};
+ unsigned char buffer[31];
+ int offsets[4] = {-95,-65,-125,-31};
int i;
- for(i=0;i<3;i++) {
- if(-1 == lseek(fd, offsets[i], SEEK_END))
+ for (i=0;i<4;i++) {
+ if (-1 == lseek(fd, offsets[i], SEEK_END))
return false;
buffer[30]=0;
read(fd, buffer, 30);
stripspaces(buffer);
- if(buffer[0]) {
+ if (buffer[0] || i == 3) {
switch(i) {
- case 0:
- strcpy(entry->id3v1buf[0], buffer);
- entry->artist = entry->id3v1buf[0];
- break;
- case 1:
- strcpy(entry->id3v1buf[1], buffer);
- entry->album = entry->id3v1buf[1];
- break;
- case 2:
- strcpy(entry->id3v1buf[2], buffer);
- entry->title = entry->id3v1buf[2];
- break;
+ case 0:
+ strcpy(entry->id3v1buf[0], buffer);
+ entry->artist = entry->id3v1buf[0];
+ break;
+ case 1:
+ strcpy(entry->id3v1buf[1], buffer);
+ entry->album = entry->id3v1buf[1];
+ break;
+ case 2:
+ strcpy(entry->id3v1buf[2], buffer);
+ entry->title = entry->id3v1buf[2];
+ break;
+ case 3:
+ /* id3v1.1 uses last two bytes of comment field for track
+ number: first must be 0 and second is track num */
+ if (buffer[28] == 0)
+ entry->tracknum = buffer[29];
+ break;
}
}
}