diff options
author | Björn Stenberg <bjorn@haxx.se> | 2003-03-10 15:43:16 +0000 |
---|---|---|
committer | Björn Stenberg <bjorn@haxx.se> | 2003-03-10 15:43:16 +0000 |
commit | fac3bc581ae7ec30f8c412e5c9b5b15997565dee (patch) | |
tree | 88e38aa7580b5e1cd2ff960953585cc48109eff4 /firmware/id3.c | |
parent | a1598b5836148f63193425f63e822937d2103482 (diff) |
Ignore duplicate id3v2 tags or frames. Patch by Bill Napier.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@3413 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/id3.c')
-rw-r--r-- | firmware/id3.c | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/firmware/id3.c b/firmware/id3.c index b9e72c66ac..ab638807c3 100644 --- a/firmware/id3.c +++ b/firmware/id3.c @@ -243,7 +243,9 @@ static void setid3v2title(int fd, struct mp3entry *entry) return; } entry->id3version = version; - + entry->tracknum = entry->year = entry->genre = 0; + entry->title = entry->artist = entry->album = NULL; + /* Skip the extended header if it is present */ if(version >= ID3_VER_2_4) { if(header[5] & 0x40) { @@ -334,8 +336,9 @@ static void setid3v2title(int fd, struct mp3entry *entry) DEBUGF("id3v2 frame: %.4s\n", header); /* Check for certain frame headers */ - if(!strncmp(header, "TPE1", strlen("TPE1")) || - !strncmp(header, "TP1", strlen("TP1"))) { + if (!entry->artist && + (!strncmp(header, "TPE1", strlen("TPE1")) || + !strncmp(header, "TP1", strlen("TP1")))) { bytesread = read(fd, buffer + bufferpos, framelen); entry->artist = buffer + bufferpos; unicode_munge(&entry->artist, &bytesread); @@ -343,8 +346,9 @@ static void setid3v2title(int fd, struct mp3entry *entry) bufferpos += bytesread + 2; size -= bytesread; } - else if(!strncmp(header, "TIT2", strlen("TIT2")) || - !strncmp(header, "TT2", strlen("TT2"))) { + else if (!entry->artist && + (!strncmp(header, "TIT2", strlen("TIT2")) || + !strncmp(header, "TT2", strlen("TT2")))) { bytesread = read(fd, buffer + bufferpos, framelen); entry->title = buffer + bufferpos; unicode_munge(&entry->title, &bytesread); @@ -352,7 +356,8 @@ static void setid3v2title(int fd, struct mp3entry *entry) bufferpos += bytesread + 2; size -= bytesread; } - else if(!strncmp(header, "TALB", strlen("TALB"))) { + else if( !entry->album && + !strncmp(header, "TALB", strlen("TALB"))) { bytesread = read(fd, buffer + bufferpos, framelen); entry->album = buffer + bufferpos; unicode_munge(&entry->album, &bytesread); @@ -360,7 +365,8 @@ static void setid3v2title(int fd, struct mp3entry *entry) bufferpos += bytesread + 2; size -= bytesread; } - else if(!strncmp(header, "TRCK", strlen("TRCK"))) { + else if (!entry->tracknum && + !strncmp(header, "TRCK", strlen("TRCK"))) { bytesread = read(fd, buffer + bufferpos, framelen); tracknum = buffer + bufferpos; unicode_munge(&tracknum, &bytesread); @@ -369,8 +375,9 @@ static void setid3v2title(int fd, struct mp3entry *entry) bufferpos += bytesread + 1; size -= bytesread; } - else if(!strncmp(header, "TYER", 4) || - !strncmp(header, "TYR", 3)) { + else if (!entry->year && + (!strncmp(header, "TYER", 4) || + !strncmp(header, "TYR", 3))) { char* ptr = buffer + bufferpos; bytesread = read(fd, ptr, framelen); unicode_munge(&ptr, &bytesread); @@ -378,7 +385,8 @@ static void setid3v2title(int fd, struct mp3entry *entry) bufferpos += bytesread + 1; size -= bytesread; } - else if(!strncmp(header, "TCON", 4)) { + else if (!entry->genre && + !strncmp(header, "TCON", 4)) { char* ptr = buffer + bufferpos; bytesread = read(fd, ptr, framelen); if (ptr[1] == '(' && ptr[2] != '(') |