summaryrefslogtreecommitdiffstats
path: root/firmware
diff options
context:
space:
mode:
authorRobert Kukla <roolku@rockbox.org>2007-03-02 21:49:42 +0000
committerRobert Kukla <roolku@rockbox.org>2007-03-02 21:49:42 +0000
commit79a2a936a289ed7dc6e997b6f8fdd53d45a48b57 (patch)
tree32c00625190da49f11a0a274bed4f3bb7a6f118d /firmware
parent2187e815e20d8127df077ef02886867ff8dcaed4 (diff)
downloadrockbox-79a2a936a289ed7dc6e997b6f8fdd53d45a48b57.tar.gz
rockbox-79a2a936a289ed7dc6e997b6f8fdd53d45a48b57.zip
remove numerical genre and use genre_string consistently:
- fix spurious display of "blues" genre for missing genre tag - simplify code/use less code - numerical->string conversion only once instead of at every use git-svn-id: svn://svn.rockbox.org/rockbox/trunk@12552 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware')
-rw-r--r--firmware/export/id3.h3
-rw-r--r--firmware/id3.c23
2 files changed, 8 insertions, 18 deletions
diff --git a/firmware/export/id3.h b/firmware/export/id3.h
index 367854fdd1..d3d5dd35ce 100644
--- a/firmware/export/id3.h
+++ b/firmware/export/id3.h
@@ -153,7 +153,6 @@ struct mp3entry {
int layer;
int year;
unsigned char id3version;
- unsigned char genre;
unsigned int codectype;
unsigned int bitrate;
unsigned long frequency;
@@ -228,7 +227,7 @@ enum {
bool get_mp3_metadata(int fd, struct mp3entry *entry, const char *filename, bool v1first);
bool mp3info(struct mp3entry *entry, const char *filename, bool v1first);
-char* id3_get_genre(const struct mp3entry* id3);
+char* id3_get_num_genre(const unsigned int genre_num);
char* id3_get_codec(const struct mp3entry* id3);
int getid3v2len(int fd);
void adjust_mp3entry(struct mp3entry *entry, void *dest, void *orig);
diff --git a/firmware/id3.c b/firmware/id3.c
index ac9397a209..88bc399b71 100644
--- a/firmware/id3.c
+++ b/firmware/id3.c
@@ -179,13 +179,10 @@ static const char* const genres[] = {
"Synthpop"
};
-char* id3_get_genre(const struct mp3entry* id3)
+char* id3_get_num_genre(const unsigned int genre_num)
{
- if( id3->genre_string )
- return id3->genre_string ;
-
- if (id3->genre < sizeof(genres)/sizeof(char*))
- return (char*)genres[id3->genre];
+ if (genre_num < sizeof(genres)/sizeof(char*))
+ return (char*)genres[genre_num];
return NULL;
}
@@ -364,23 +361,19 @@ static int parsegenre( struct mp3entry* entry, char* tag, int bufferpos )
/* Is it a number? */
if(isdigit(tag[0])) {
- entry->genre = atoi( tag );
- entry->genre_string = 0;
+ entry->genre_string = id3_get_num_genre(atoi( tag ));
return tag - entry->id3v2buf;
} else {
entry->genre_string = tag;
- entry->genre = 0xff;
return bufferpos;
}
} else {
if( tag[0] == '(' && tag[1] != '(' ) {
- entry->genre = atoi( tag + 1 );
- entry->genre_string = 0;
+ entry->genre_string = id3_get_num_genre(atoi( tag + 1 ));
return tag - entry->id3v2buf;
}
else {
entry->genre_string = tag;
- entry->genre = 0xff;
return bufferpos;
}
}
@@ -616,7 +609,7 @@ static bool setid3v1title(int fd, struct mp3entry *entry)
case 6:
/* genre */
- entry->genre = ptr[0];
+ entry->genre_string = id3_get_num_genre(ptr[0]);
break;
}
}
@@ -695,8 +688,7 @@ static void setid3v2title(int fd, struct mp3entry *entry)
}
entry->id3version = version;
entry->tracknum = entry->year = 0;
- entry->genre = 0xff;
- entry->title = entry->artist = entry->album = NULL;
+ entry->title = entry->artist = entry->album = NULL; /* FIXME incomplete */
global_flags = header[5];
@@ -1117,7 +1109,6 @@ bool get_mp3_metadata(int fd, struct mp3entry *entry, const char *filename, bool
entry->filesize = filesize(fd);
entry->id3v2len = getid3v2len(fd);
entry->tracknum = 0;
- entry->genre = 0xff;
if(v1first)
v1found = setid3v1title(fd, entry);