diff options
author | Björn Stenberg <bjorn@haxx.se> | 2002-12-05 15:21:18 +0000 |
---|---|---|
committer | Björn Stenberg <bjorn@haxx.se> | 2002-12-05 15:21:18 +0000 |
commit | a5587d02988b5da15ad0ff8e788b27125501b53b (patch) | |
tree | c0b3f9f02a9063f3feaa8799e3fc03064d64f104 | |
parent | 345f7c62ba7247b84990364a2e906cf805d6c406 (diff) | |
download | rockbox-a5587d02988b5da15ad0ff8e788b27125501b53b.tar.gz rockbox-a5587d02988b5da15ad0ff8e788b27125501b53b.zip |
Added ID3 tag 'genre': %ig
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@2950 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r-- | apps/wps-display.c | 34 | ||||
-rw-r--r-- | firmware/id3.c | 19 | ||||
-rw-r--r-- | firmware/id3.h | 1 |
3 files changed, 52 insertions, 2 deletions
diff --git a/apps/wps-display.c b/apps/wps-display.c index 521d2b5d77..1699807e47 100644 --- a/apps/wps-display.c +++ b/apps/wps-display.c | |||
@@ -63,6 +63,33 @@ static int ff_rewind_count; | |||
63 | bool wps_time_countup = true; | 63 | bool wps_time_countup = true; |
64 | static bool wps_loaded = false; | 64 | static bool wps_loaded = false; |
65 | 65 | ||
66 | static const char* const genres[] = { | ||
67 | "Blues", "Classic Rock", "Country", "Dance", "Disco", "Funk", "Grunge", | ||
68 | "Hip-Hop", "Jazz", "Metal", "New Age", "Oldies", "Other", "Pop", "R&B", | ||
69 | "Rap", "Reggae", "Rock", "Techno", "Industrial", "Alternative", "Ska", | ||
70 | "Death Metal", "Pranks", "Soundtrack", "Euro-Techno", "Ambient", "Trip-Hop", | ||
71 | "Vocal", "Jazz+Funk", "Fusion", "Trance", "Classical", "Instrumental", | ||
72 | "Acid", "House", "Game", "Sound Clip", "Gospel", "Noise", "AlternRock", | ||
73 | "Bass", "Soul", "Punk", "Space", "Meditative", "Instrumental Pop", | ||
74 | "Instrumental Rock", "Ethnic", "Gothic", "Darkwave", "Techno-Industrial", | ||
75 | "Electronic", "Pop-Folk", "Eurodance", "Dream", "Southern Rock", "Comedy", | ||
76 | "Cult", "Gangsta", "Top 40", "Christian Rap", "Pop/Funk", "Jungle", | ||
77 | "Native American", "Cabaret", "New Wave", "Psychadelic", "Rave", | ||
78 | "Showtunes", "Trailer", "Lo-Fi", "Tribal", "Acid Punk", "Acid Jazz", | ||
79 | "Polka", "Retro", "Musical", "Rock & Roll", "Hard Rock", | ||
80 | |||
81 | /* winamp extensions */ | ||
82 | "Folk", "Folk-Rock", "National Folk", "Swing", "Fast Fusion", "Bebob", | ||
83 | "Latin", "Revival", "Celtic", "Bluegrass", "Avantgarde", "Gothic Rock", | ||
84 | "Progressive Rock", "Psychedelic Rock", "Symphonic Rock", "Slow Rock", | ||
85 | "Big Band", "Chorus", "Easy Listening", "Acoustic", "Humour", "Speech", | ||
86 | "Chanson", "Opera", "Chamber Music", "Sonata", "Symphony", "Booty Bass", | ||
87 | "Primus", "Porn Groove", "Satire", "Slow Jam", "Club", "Tango", "Samba", | ||
88 | "Folklore", "Ballad", "Power Ballad", "Rhythmic Soul", "Freestyle", | ||
89 | "Duet", "Punk Rock", "Drum Solo", "A capella", "Euro-House", "Dance Hall" | ||
90 | }; | ||
91 | |||
92 | |||
66 | /* Set format string to use for WPS, splitting it into lines */ | 93 | /* Set format string to use for WPS, splitting it into lines */ |
67 | static void wps_format(char* fmt) | 94 | static void wps_format(char* fmt) |
68 | { | 95 | { |
@@ -260,6 +287,13 @@ static char* get_tag(struct mp3entry* id3, | |||
260 | else | 287 | else |
261 | return NULL; | 288 | return NULL; |
262 | break; | 289 | break; |
290 | |||
291 | case 'g': /* genre */ | ||
292 | if (id3->genre < sizeof(genres)/sizeof(char*)) | ||
293 | return (char*)genres[id3->genre]; | ||
294 | else | ||
295 | return NULL; | ||
296 | break; | ||
263 | } | 297 | } |
264 | break; | 298 | break; |
265 | 299 | ||
diff --git a/firmware/id3.c b/firmware/id3.c index c0e6c564d0..4b72e4ca4d 100644 --- a/firmware/id3.c +++ b/firmware/id3.c | |||
@@ -156,7 +156,7 @@ static int unicode_munge(char** string, int *len) { | |||
156 | static bool setid3v1title(int fd, struct mp3entry *entry) | 156 | static bool setid3v1title(int fd, struct mp3entry *entry) |
157 | { | 157 | { |
158 | unsigned char buffer[128]; | 158 | unsigned char buffer[128]; |
159 | static int offsets[] = {3, 33, 63, 93, 125}; | 159 | static char offsets[] = {3, 33, 63, 93, 125, 127}; |
160 | int i, j; | 160 | int i, j; |
161 | 161 | ||
162 | if (-1 == lseek(fd, -128, SEEK_END)) | 162 | if (-1 == lseek(fd, -128, SEEK_END)) |
@@ -168,7 +168,7 @@ static bool setid3v1title(int fd, struct mp3entry *entry) | |||
168 | if (strncmp(buffer, "TAG", 3)) | 168 | if (strncmp(buffer, "TAG", 3)) |
169 | return false; | 169 | return false; |
170 | 170 | ||
171 | for (i=0;i<5;i++) { | 171 | for (i=0; i < (int)sizeof offsets; i++) { |
172 | char* ptr = buffer + offsets[i]; | 172 | char* ptr = buffer + offsets[i]; |
173 | 173 | ||
174 | if (i<3) { | 174 | if (i<3) { |
@@ -204,6 +204,11 @@ static bool setid3v1title(int fd, struct mp3entry *entry) | |||
204 | if (*ptr == 0) | 204 | if (*ptr == 0) |
205 | entry->tracknum = ptr[1]; | 205 | entry->tracknum = ptr[1]; |
206 | break; | 206 | break; |
207 | |||
208 | case 5: | ||
209 | /* genre */ | ||
210 | entry->genre = ptr[0]; | ||
211 | break; | ||
207 | } | 212 | } |
208 | } | 213 | } |
209 | 214 | ||
@@ -339,6 +344,16 @@ static void setid3v2title(int fd, struct mp3entry *entry) | |||
339 | bufferpos += bytesread + 1; | 344 | bufferpos += bytesread + 1; |
340 | size -= bytesread; | 345 | size -= bytesread; |
341 | } | 346 | } |
347 | else if(!strncmp(header, "TCON", 4)) { | ||
348 | char* ptr = buffer + bufferpos; | ||
349 | bytesread = read(fd, ptr, framelen); | ||
350 | if (ptr[1] == '(' && ptr[2] != '(') | ||
351 | entry->genre = atoi(ptr+2); | ||
352 | else | ||
353 | entry->genre = 0xff; | ||
354 | bufferpos += bytesread + 1; | ||
355 | size -= bytesread; | ||
356 | } | ||
342 | else { | 357 | else { |
343 | /* Unknown frame, skip it using the total size in case | 358 | /* Unknown frame, skip it using the total size in case |
344 | it was truncated */ | 359 | it was truncated */ |
diff --git a/firmware/id3.h b/firmware/id3.h index ae88bbf16c..11d9eee19e 100644 --- a/firmware/id3.h +++ b/firmware/id3.h | |||
@@ -30,6 +30,7 @@ struct mp3entry { | |||
30 | int version; | 30 | int version; |
31 | int layer; | 31 | int layer; |
32 | int year; | 32 | int year; |
33 | unsigned char genre; | ||
33 | unsigned int bitrate; | 34 | unsigned int bitrate; |
34 | unsigned int frequency; | 35 | unsigned int frequency; |
35 | unsigned int id3v2len; | 36 | unsigned int id3v2len; |