forked from len0rd/rockbox
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
This commit is contained in:
parent
2187e815e2
commit
79a2a936a2
6 changed files with 14 additions and 32 deletions
|
@ -506,7 +506,7 @@ static char* get_tag(struct wps_data* wps_data,
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
case 'g': /* genre */
|
case 'g': /* genre */
|
||||||
return id3_get_genre(id3);
|
return id3->genre_string;
|
||||||
|
|
||||||
case 'v': /* id3 version */
|
case 'v': /* id3 version */
|
||||||
switch (id3->id3version)
|
switch (id3->id3version)
|
||||||
|
|
|
@ -305,8 +305,6 @@ static bool read_ape_tags(int fd, struct mp3entry* id3)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
id3->genre = 0xff;
|
|
||||||
|
|
||||||
if ((header.version == 2000) && (header.item_count > 0)
|
if ((header.version == 2000) && (header.item_count > 0)
|
||||||
&& (header.length > APETAG_HEADER_LENGTH))
|
&& (header.length > APETAG_HEADER_LENGTH))
|
||||||
{
|
{
|
||||||
|
@ -388,8 +386,6 @@ static bool read_vorbis_tags(int fd, struct mp3entry *id3,
|
||||||
int buf_remaining = sizeof(id3->id3v2buf) + sizeof(id3->id3v1buf);
|
int buf_remaining = sizeof(id3->id3v2buf) + sizeof(id3->id3v1buf);
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
id3->genre = 255;
|
|
||||||
|
|
||||||
if (ecread(fd, &len, 1, "l", IS_BIG_ENDIAN) < (long) sizeof(len))
|
if (ecread(fd, &len, 1, "l", IS_BIG_ENDIAN) < (long) sizeof(len))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
|
@ -1355,7 +1351,7 @@ static bool read_mp4_tags(int fd, struct mp3entry* id3,
|
||||||
unsigned short genre;
|
unsigned short genre;
|
||||||
|
|
||||||
read_mp4_tag(fd, size, (char*) &genre, sizeof(genre));
|
read_mp4_tag(fd, size, (char*) &genre, sizeof(genre));
|
||||||
id3->genre = betoh16(genre);
|
id3->genre_string = id3_get_num_genre(betoh16(genre));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -1591,7 +1587,6 @@ static bool read_mp4_container(int fd, struct mp3entry* id3,
|
||||||
static bool get_mp4_metadata(int fd, struct mp3entry* id3)
|
static bool get_mp4_metadata(int fd, struct mp3entry* id3)
|
||||||
{
|
{
|
||||||
id3->codectype = AFMT_UNKNOWN;
|
id3->codectype = AFMT_UNKNOWN;
|
||||||
id3->genre = 255;
|
|
||||||
id3->filesize = 0;
|
id3->filesize = 0;
|
||||||
errno = 0;
|
errno = 0;
|
||||||
|
|
||||||
|
@ -2179,7 +2174,7 @@ bool get_metadata(struct track_info* track, int fd, const char* trackname,
|
||||||
break;
|
break;
|
||||||
case AFMT_SPC:
|
case AFMT_SPC:
|
||||||
track->id3.filesize = filesize(fd);
|
track->id3.filesize = filesize(fd);
|
||||||
track->id3.genre = 36;
|
track->id3.genre_string = id3_get_num_genre(36);
|
||||||
break;
|
break;
|
||||||
case AFMT_ADX:
|
case AFMT_ADX:
|
||||||
if (!get_adx_metadata(fd, &(track->id3)))
|
if (!get_adx_metadata(fd, &(track->id3)))
|
||||||
|
|
|
@ -1181,7 +1181,7 @@ static char * id3_get_info(int selected_item, void* data, char *buffer)
|
||||||
info=id3->comment;
|
info=id3->comment;
|
||||||
break;
|
break;
|
||||||
case 6:/*LANG_ID3_GENRE*/
|
case 6:/*LANG_ID3_GENRE*/
|
||||||
info = id3_get_genre(id3);
|
info = id3->genre_string;
|
||||||
break;
|
break;
|
||||||
case 7:/*LANG_ID3_YEAR*/
|
case 7:/*LANG_ID3_YEAR*/
|
||||||
if (id3->year_string)
|
if (id3->year_string)
|
||||||
|
|
|
@ -1534,7 +1534,6 @@ static void add_tagcache(char *path)
|
||||||
bool ret;
|
bool ret;
|
||||||
int fd;
|
int fd;
|
||||||
char tracknumfix[3];
|
char tracknumfix[3];
|
||||||
char *genrestr;
|
|
||||||
int offset = 0;
|
int offset = 0;
|
||||||
int path_length = strlen(path);
|
int path_length = strlen(path);
|
||||||
|
|
||||||
|
@ -1620,8 +1619,6 @@ static void add_tagcache(char *path)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
genrestr = id3_get_genre(&track.id3);
|
|
||||||
|
|
||||||
/* Numeric tags */
|
/* Numeric tags */
|
||||||
entry.tag_offset[tag_year] = track.id3.year;
|
entry.tag_offset[tag_year] = track.id3.year;
|
||||||
entry.tag_offset[tag_tracknumber] = track.id3.tracknum;
|
entry.tag_offset[tag_tracknumber] = track.id3.tracknum;
|
||||||
|
@ -1633,7 +1630,7 @@ static void add_tagcache(char *path)
|
||||||
ADD_TAG(entry, tag_title, &track.id3.title);
|
ADD_TAG(entry, tag_title, &track.id3.title);
|
||||||
ADD_TAG(entry, tag_artist, &track.id3.artist);
|
ADD_TAG(entry, tag_artist, &track.id3.artist);
|
||||||
ADD_TAG(entry, tag_album, &track.id3.album);
|
ADD_TAG(entry, tag_album, &track.id3.album);
|
||||||
ADD_TAG(entry, tag_genre, &genrestr);
|
ADD_TAG(entry, tag_genre, &track.id3.genre_string);
|
||||||
ADD_TAG(entry, tag_composer, &track.id3.composer);
|
ADD_TAG(entry, tag_composer, &track.id3.composer);
|
||||||
ADD_TAG(entry, tag_comment, &track.id3.comment);
|
ADD_TAG(entry, tag_comment, &track.id3.comment);
|
||||||
ADD_TAG(entry, tag_albumartist, &track.id3.albumartist);
|
ADD_TAG(entry, tag_albumartist, &track.id3.albumartist);
|
||||||
|
@ -1647,7 +1644,7 @@ static void add_tagcache(char *path)
|
||||||
write_item(track.id3.title);
|
write_item(track.id3.title);
|
||||||
write_item(track.id3.artist);
|
write_item(track.id3.artist);
|
||||||
write_item(track.id3.album);
|
write_item(track.id3.album);
|
||||||
write_item(genrestr);
|
write_item(track.id3.genre_string);
|
||||||
write_item(track.id3.composer);
|
write_item(track.id3.composer);
|
||||||
write_item(track.id3.comment);
|
write_item(track.id3.comment);
|
||||||
write_item(track.id3.albumartist);
|
write_item(track.id3.albumartist);
|
||||||
|
|
|
@ -153,7 +153,6 @@ struct mp3entry {
|
||||||
int layer;
|
int layer;
|
||||||
int year;
|
int year;
|
||||||
unsigned char id3version;
|
unsigned char id3version;
|
||||||
unsigned char genre;
|
|
||||||
unsigned int codectype;
|
unsigned int codectype;
|
||||||
unsigned int bitrate;
|
unsigned int bitrate;
|
||||||
unsigned long frequency;
|
unsigned long frequency;
|
||||||
|
@ -228,7 +227,7 @@ enum {
|
||||||
|
|
||||||
bool get_mp3_metadata(int fd, struct mp3entry *entry, const char *filename, bool v1first);
|
bool get_mp3_metadata(int fd, struct mp3entry *entry, const char *filename, bool v1first);
|
||||||
bool mp3info(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);
|
char* id3_get_codec(const struct mp3entry* id3);
|
||||||
int getid3v2len(int fd);
|
int getid3v2len(int fd);
|
||||||
void adjust_mp3entry(struct mp3entry *entry, void *dest, void *orig);
|
void adjust_mp3entry(struct mp3entry *entry, void *dest, void *orig);
|
||||||
|
|
|
@ -179,13 +179,10 @@ static const char* const genres[] = {
|
||||||
"Synthpop"
|
"Synthpop"
|
||||||
};
|
};
|
||||||
|
|
||||||
char* id3_get_genre(const struct mp3entry* id3)
|
char* id3_get_num_genre(const unsigned int genre_num)
|
||||||
{
|
{
|
||||||
if( id3->genre_string )
|
if (genre_num < sizeof(genres)/sizeof(char*))
|
||||||
return id3->genre_string ;
|
return (char*)genres[genre_num];
|
||||||
|
|
||||||
if (id3->genre < sizeof(genres)/sizeof(char*))
|
|
||||||
return (char*)genres[id3->genre];
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -364,23 +361,19 @@ static int parsegenre( struct mp3entry* entry, char* tag, int bufferpos )
|
||||||
|
|
||||||
/* Is it a number? */
|
/* Is it a number? */
|
||||||
if(isdigit(tag[0])) {
|
if(isdigit(tag[0])) {
|
||||||
entry->genre = atoi( tag );
|
entry->genre_string = id3_get_num_genre(atoi( tag ));
|
||||||
entry->genre_string = 0;
|
|
||||||
return tag - entry->id3v2buf;
|
return tag - entry->id3v2buf;
|
||||||
} else {
|
} else {
|
||||||
entry->genre_string = tag;
|
entry->genre_string = tag;
|
||||||
entry->genre = 0xff;
|
|
||||||
return bufferpos;
|
return bufferpos;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if( tag[0] == '(' && tag[1] != '(' ) {
|
if( tag[0] == '(' && tag[1] != '(' ) {
|
||||||
entry->genre = atoi( tag + 1 );
|
entry->genre_string = id3_get_num_genre(atoi( tag + 1 ));
|
||||||
entry->genre_string = 0;
|
|
||||||
return tag - entry->id3v2buf;
|
return tag - entry->id3v2buf;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
entry->genre_string = tag;
|
entry->genre_string = tag;
|
||||||
entry->genre = 0xff;
|
|
||||||
return bufferpos;
|
return bufferpos;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -616,7 +609,7 @@ static bool setid3v1title(int fd, struct mp3entry *entry)
|
||||||
|
|
||||||
case 6:
|
case 6:
|
||||||
/* genre */
|
/* genre */
|
||||||
entry->genre = ptr[0];
|
entry->genre_string = id3_get_num_genre(ptr[0]);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -695,8 +688,7 @@ static void setid3v2title(int fd, struct mp3entry *entry)
|
||||||
}
|
}
|
||||||
entry->id3version = version;
|
entry->id3version = version;
|
||||||
entry->tracknum = entry->year = 0;
|
entry->tracknum = entry->year = 0;
|
||||||
entry->genre = 0xff;
|
entry->title = entry->artist = entry->album = NULL; /* FIXME incomplete */
|
||||||
entry->title = entry->artist = entry->album = NULL;
|
|
||||||
|
|
||||||
global_flags = header[5];
|
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->filesize = filesize(fd);
|
||||||
entry->id3v2len = getid3v2len(fd);
|
entry->id3v2len = getid3v2len(fd);
|
||||||
entry->tracknum = 0;
|
entry->tracknum = 0;
|
||||||
entry->genre = 0xff;
|
|
||||||
|
|
||||||
if(v1first)
|
if(v1first)
|
||||||
v1found = setid3v1title(fd, entry);
|
v1found = setid3v1title(fd, entry);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue