Genre parsing in id3v2.3 was still wrong. Also, the last frame in the tag could sometimes be ignored. This fixes the strange 1-digit track number bug.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@3984 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Linus Nielsen Feltzing 2003-10-22 21:11:38 +00:00
parent 5557fe3259
commit eee3720ebe

View file

@ -152,33 +152,31 @@ static int parseyearnum( struct mp3entry* entry, char* tag, int bufferpos )
}
/* parse numeric genre from string, version 2.2 and 2.3 */
static int parseoldgenre( struct mp3entry* entry, char* tag, int bufferpos )
static int parsegenre( struct mp3entry* entry, char* tag, int bufferpos )
{
if( tag[0] == '(' && tag[1] != '(' ) {
entry->genre = atoi( tag + 1 );
entry->genre_string = 0;
return tag - entry->id3v2buf;
}
else {
entry->genre = 0xFF;
return bufferpos;
}
}
if(entry->id3version >= ID3_VER_2_3) {
/* In version 2.4 and up, there are no parentheses, and the genre frame
is a list of strings, either numbers or text. */
/* parse numeric genre from string, version 2.4 and up */
static int parsenewgenre( struct mp3entry* entry, char* tag, int bufferpos )
{
/* In version 2.4 and up, there are no parentheses, and the genre frame
is a list of strings, either numbers or text. */
/* Is it a number? */
if(isdigit(tag[0])) {
entry->genre = atoi( tag );
entry->genre_string = 0;
return tag - entry->id3v2buf;
/* Is it a number? */
if(isdigit(tag[0])) {
entry->genre = atoi( tag );
entry->genre_string = 0;
return tag - entry->id3v2buf;
} else {
entry->genre = 0xFF;
return bufferpos;
}
} else {
entry->genre = 0xFF;
return bufferpos;
if( tag[0] == '(' && tag[1] != '(' ) {
entry->genre = atoi( tag + 1 );
entry->genre_string = 0;
return tag - entry->id3v2buf;
}
else {
entry->genre = 0xFF;
return bufferpos;
}
}
}
@ -193,8 +191,8 @@ static struct tag_resolver taglist[] = {
{ "TRCK", 4, offsetof(struct mp3entry, track_string), &parsetracknum },
{ "TYER", 4, offsetof(struct mp3entry, year_string), &parseyearnum },
{ "TYE", 3, offsetof(struct mp3entry, year_string), &parseyearnum },
{ "TCON", 4, offsetof(struct mp3entry, genre_string), &parsenewgenre },
{ "TCO", 3, offsetof(struct mp3entry, genre_string), &parseoldgenre },
{ "TCON", 4, offsetof(struct mp3entry, genre_string), &parsegenre },
{ "TCO", 3, offsetof(struct mp3entry, genre_string), &parsegenre },
{ "TCOM", 4, offsetof(struct mp3entry, composer), NULL }
};
@ -430,7 +428,7 @@ static void setid3v2title(int fd, struct mp3entry *entry)
* We must have at least minframesize bytes left for the
* remaining frames to be interesting
*/
while(size > minframesize ) {
while(size >= minframesize ) {
flags = 0;
/* Read frame header and check length */