summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBjörn Stenberg <bjorn@haxx.se>2002-12-05 15:21:18 +0000
committerBjörn Stenberg <bjorn@haxx.se>2002-12-05 15:21:18 +0000
commita5587d02988b5da15ad0ff8e788b27125501b53b (patch)
treec0b3f9f02a9063f3feaa8799e3fc03064d64f104
parent345f7c62ba7247b84990364a2e906cf805d6c406 (diff)
downloadrockbox-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.c34
-rw-r--r--firmware/id3.c19
-rw-r--r--firmware/id3.h1
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;
bool wps_time_countup = true;
static bool wps_loaded = false;
+static const char* const genres[] = {
+ "Blues", "Classic Rock", "Country", "Dance", "Disco", "Funk", "Grunge",
+ "Hip-Hop", "Jazz", "Metal", "New Age", "Oldies", "Other", "Pop", "R&B",
+ "Rap", "Reggae", "Rock", "Techno", "Industrial", "Alternative", "Ska",
+ "Death Metal", "Pranks", "Soundtrack", "Euro-Techno", "Ambient", "Trip-Hop",
+ "Vocal", "Jazz+Funk", "Fusion", "Trance", "Classical", "Instrumental",
+ "Acid", "House", "Game", "Sound Clip", "Gospel", "Noise", "AlternRock",
+ "Bass", "Soul", "Punk", "Space", "Meditative", "Instrumental Pop",
+ "Instrumental Rock", "Ethnic", "Gothic", "Darkwave", "Techno-Industrial",
+ "Electronic", "Pop-Folk", "Eurodance", "Dream", "Southern Rock", "Comedy",
+ "Cult", "Gangsta", "Top 40", "Christian Rap", "Pop/Funk", "Jungle",
+ "Native American", "Cabaret", "New Wave", "Psychadelic", "Rave",
+ "Showtunes", "Trailer", "Lo-Fi", "Tribal", "Acid Punk", "Acid Jazz",
+ "Polka", "Retro", "Musical", "Rock & Roll", "Hard Rock",
+
+ /* winamp extensions */
+ "Folk", "Folk-Rock", "National Folk", "Swing", "Fast Fusion", "Bebob",
+ "Latin", "Revival", "Celtic", "Bluegrass", "Avantgarde", "Gothic Rock",
+ "Progressive Rock", "Psychedelic Rock", "Symphonic Rock", "Slow Rock",
+ "Big Band", "Chorus", "Easy Listening", "Acoustic", "Humour", "Speech",
+ "Chanson", "Opera", "Chamber Music", "Sonata", "Symphony", "Booty Bass",
+ "Primus", "Porn Groove", "Satire", "Slow Jam", "Club", "Tango", "Samba",
+ "Folklore", "Ballad", "Power Ballad", "Rhythmic Soul", "Freestyle",
+ "Duet", "Punk Rock", "Drum Solo", "A capella", "Euro-House", "Dance Hall"
+};
+
+
/* Set format string to use for WPS, splitting it into lines */
static void wps_format(char* fmt)
{
@@ -260,6 +287,13 @@ static char* get_tag(struct mp3entry* id3,
else
return NULL;
break;
+
+ case 'g': /* genre */
+ if (id3->genre < sizeof(genres)/sizeof(char*))
+ return (char*)genres[id3->genre];
+ else
+ return NULL;
+ break;
}
break;
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) {
static bool setid3v1title(int fd, struct mp3entry *entry)
{
unsigned char buffer[128];
- static int offsets[] = {3, 33, 63, 93, 125};
+ static char offsets[] = {3, 33, 63, 93, 125, 127};
int i, j;
if (-1 == lseek(fd, -128, SEEK_END))
@@ -168,7 +168,7 @@ static bool setid3v1title(int fd, struct mp3entry *entry)
if (strncmp(buffer, "TAG", 3))
return false;
- for (i=0;i<5;i++) {
+ for (i=0; i < (int)sizeof offsets; i++) {
char* ptr = buffer + offsets[i];
if (i<3) {
@@ -204,6 +204,11 @@ static bool setid3v1title(int fd, struct mp3entry *entry)
if (*ptr == 0)
entry->tracknum = ptr[1];
break;
+
+ case 5:
+ /* genre */
+ entry->genre = ptr[0];
+ break;
}
}
@@ -339,6 +344,16 @@ static void setid3v2title(int fd, struct mp3entry *entry)
bufferpos += bytesread + 1;
size -= bytesread;
}
+ else if(!strncmp(header, "TCON", 4)) {
+ char* ptr = buffer + bufferpos;
+ bytesread = read(fd, ptr, framelen);
+ if (ptr[1] == '(' && ptr[2] != '(')
+ entry->genre = atoi(ptr+2);
+ else
+ entry->genre = 0xff;
+ bufferpos += bytesread + 1;
+ size -= bytesread;
+ }
else {
/* Unknown frame, skip it using the total size in case
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 {
int version;
int layer;
int year;
+ unsigned char genre;
unsigned int bitrate;
unsigned int frequency;
unsigned int id3v2len;