diff options
author | Linus Nielsen Feltzing <linus@haxx.se> | 2003-10-21 10:44:34 +0000 |
---|---|---|
committer | Linus Nielsen Feltzing <linus@haxx.se> | 2003-10-21 10:44:34 +0000 |
commit | d9ae29a6910b2bd89cfd748a585fb8133a159c56 (patch) | |
tree | 8522b818efa946f1228de6f2447dfb02340be71c /firmware/id3.c | |
parent | 0bce9580a1ae8b14712c350825a201028c923236 (diff) | |
download | rockbox-d9ae29a6910b2bd89cfd748a585fb8133a159c56.tar.gz rockbox-d9ae29a6910b2bd89cfd748a585fb8133a159c56.zip |
An attempt to fix the ID3V2 genre tag parsing
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@3981 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/id3.c')
-rw-r--r-- | firmware/id3.c | 29 |
1 files changed, 24 insertions, 5 deletions
diff --git a/firmware/id3.c b/firmware/id3.c index dd3fb1ab8a..d059841991 100644 --- a/firmware/id3.c +++ b/firmware/id3.c | |||
@@ -33,6 +33,7 @@ | |||
33 | #include <errno.h> | 33 | #include <errno.h> |
34 | #include <stdbool.h> | 34 | #include <stdbool.h> |
35 | #include <stddef.h> | 35 | #include <stddef.h> |
36 | #include <ctype.h> | ||
36 | #include "file.h" | 37 | #include "file.h" |
37 | #include "debug.h" | 38 | #include "debug.h" |
38 | #include "atoi.h" | 39 | #include "atoi.h" |
@@ -121,11 +122,11 @@ static int parseyearnum( struct mp3entry* entry, char* tag, int bufferpos ) | |||
121 | return bufferpos; | 122 | return bufferpos; |
122 | } | 123 | } |
123 | 124 | ||
124 | /* parse numeric genre from string */ | 125 | /* parse numeric genre from string, version 2.2 and 2.3 */ |
125 | static int parsegenre( struct mp3entry* entry, char* tag, int bufferpos ) | 126 | static int parseoldgenre( struct mp3entry* entry, char* tag, int bufferpos ) |
126 | { | 127 | { |
127 | if( tag[ 1 ] == '(' && tag[ 2 ] != '(' ) { | 128 | if( tag[0] == '(' && tag[1] != '(' ) { |
128 | entry->genre = atoi( tag + 2 ); | 129 | entry->genre = atoi( tag + 1 ); |
129 | entry->genre_string = 0; | 130 | entry->genre_string = 0; |
130 | return tag - entry->id3v2buf; | 131 | return tag - entry->id3v2buf; |
131 | } | 132 | } |
@@ -135,6 +136,23 @@ static int parsegenre( struct mp3entry* entry, char* tag, int bufferpos ) | |||
135 | } | 136 | } |
136 | } | 137 | } |
137 | 138 | ||
139 | /* parse numeric genre from string, version 2.4 and up */ | ||
140 | static int parsenewgenre( struct mp3entry* entry, char* tag, int bufferpos ) | ||
141 | { | ||
142 | /* In version 2.4 and up, there are no parentheses, and the genre frame | ||
143 | is a list of strings, either numbers or text. */ | ||
144 | |||
145 | /* Is it a number? */ | ||
146 | if(isdigit(tag[0])) { | ||
147 | entry->genre = atoi( tag ); | ||
148 | entry->genre_string = 0; | ||
149 | return tag - entry->id3v2buf; | ||
150 | } else { | ||
151 | entry->genre = 0xFF; | ||
152 | return bufferpos; | ||
153 | } | ||
154 | } | ||
155 | |||
138 | static struct tag_resolver taglist[] = { | 156 | static struct tag_resolver taglist[] = { |
139 | { "TPE1", 4, offsetof(struct mp3entry, artist), NULL }, | 157 | { "TPE1", 4, offsetof(struct mp3entry, artist), NULL }, |
140 | { "TP1", 3, offsetof(struct mp3entry, artist), NULL }, | 158 | { "TP1", 3, offsetof(struct mp3entry, artist), NULL }, |
@@ -146,7 +164,8 @@ static struct tag_resolver taglist[] = { | |||
146 | { "TRCK", 4, offsetof(struct mp3entry, track_string), &parsetracknum }, | 164 | { "TRCK", 4, offsetof(struct mp3entry, track_string), &parsetracknum }, |
147 | { "TYER", 4, offsetof(struct mp3entry, year_string), &parseyearnum }, | 165 | { "TYER", 4, offsetof(struct mp3entry, year_string), &parseyearnum }, |
148 | { "TYE", 3, offsetof(struct mp3entry, year_string), &parseyearnum }, | 166 | { "TYE", 3, offsetof(struct mp3entry, year_string), &parseyearnum }, |
149 | { "TCON", 4, offsetof(struct mp3entry, genre_string), &parsegenre }, | 167 | { "TCON", 4, offsetof(struct mp3entry, genre_string), &parsenewgenre }, |
168 | { "TCO", 3, offsetof(struct mp3entry, genre_string), &parseoldgenre }, | ||
150 | { "TCOM", 4, offsetof(struct mp3entry, composer), NULL } | 169 | { "TCOM", 4, offsetof(struct mp3entry, composer), NULL } |
151 | }; | 170 | }; |
152 | 171 | ||