FS#6638 - Album artist and comment patch for WPS and tagcache. Export

your database before updating because initialization is needed.


git-svn-id: svn://svn.rockbox.org/rockbox/trunk@12255 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Miika Pekkarinen 2007-02-10 12:09:28 +00:00
parent 7bf62e8da6
commit 4e9766477b
10 changed files with 141 additions and 21 deletions

View file

@ -504,6 +504,12 @@ static char* get_tag(struct wps_data* wps_data,
case 'c': /* ID3 Composer */
return id3->composer;
case 'C': /* ID3 Comment */
return id3->comment;
case 'A': /* ID3 Albumartist */
return id3->albumartist;
case 'y': /* year */
if( id3->year_string )
return id3->year_string;

View file

@ -5391,6 +5391,20 @@
*: ""
</voice>
</phrase>
<phrase>
id: LANG_ID3_ALBUMARTIST
desc: in tag viewer
user:
<source>
*: "[Album Artist]"
</source>
<dest>
*: "[Album-KÃ?nstler]"
</dest>
<voice>
*: ""
</voice>
</phrase>
<phrase>
id: LANG_ID3_TRACKNUM
desc: in tag viewer
@ -5405,6 +5419,20 @@
*: ""
</voice>
</phrase>
<phrase>
id: LANG_ID3_COMMENT
desc: in tag viewer
user:
<source>
*: "[Comment]"
</source>
<dest>
*: "[Kommentar]"
</dest>
<voice>
*: ""
</voice>
</phrase>
<phrase>
id: LANG_ID3_GENRE
desc: in tag viewer

View file

@ -5458,6 +5458,20 @@
*: ""
</voice>
</phrase>
<phrase>
id: LANG_ID3_ALBUMARTIST
desc: in tag viewer
user:
<source>
*: "[Album Artist]"
</source>
<dest>
*: "[Album Artist]"
</dest>
<voice>
*: ""
</voice>
</phrase>
<phrase>
id: LANG_ID3_TRACKNUM
desc: in tag viewer
@ -5472,6 +5486,20 @@
*: ""
</voice>
</phrase>
<phrase>
id: LANG_ID3_COMMENT
desc: in tag viewer
user:
<source>
*: "[Comment]"
</source>
<dest>
*: "[Comment]"
</dest>
<voice>
*: ""
</voice>
</phrase>
<phrase>
id: LANG_ID3_GENRE
desc: in tag viewer

View file

@ -303,6 +303,22 @@ static long parse_tag(const char* name, char* value, struct mp3entry* id3,
{
p = &(id3->composer);
}
else if (strcasecmp(name, "comment") == 0)
{
p = &(id3->comment);
}
else if (strcasecmp(name, "albumartist") == 0)
{
p = &(id3->albumartist);
}
else if (strcasecmp(name, "album artist") == 0)
{
p = &(id3->albumartist);
}
else if (strcasecmp(name, "ensemble") == 0)
{
p = &(id3->albumartist);
}
else
{
len = parse_replaygain(name, value, id3, buf, buf_remaining);

View file

@ -1142,7 +1142,9 @@ static char * id3_get_info(int selected_item, void* data, char *buffer)
LANG_ID3_TITLE,
LANG_ID3_ARTIST,
LANG_ID3_ALBUM,
LANG_ID3_ALBUMARTIST,
LANG_ID3_TRACKNUM,
LANG_ID3_COMMENT,
LANG_ID3_GENRE,
LANG_ID3_YEAR,
LANG_ID3_LENGTH,
@ -1172,7 +1174,10 @@ static char * id3_get_info(int selected_item, void* data, char *buffer)
case 2:/*LANG_ID3_ALBUM*/
info=id3->album;
break;
case 3:/*LANG_ID3_TRACKNUM*/
case 3:/*LANG_ID3_ALBUMARTIST*/
info=id3->albumartist;
break;
case 4:/*LANG_ID3_TRACKNUM*/
if (id3->track_string)
info = id3->track_string;
else if (id3->tracknum)
@ -1181,10 +1186,13 @@ static char * id3_get_info(int selected_item, void* data, char *buffer)
info = buffer;
}
break;
case 4:/*LANG_ID3_GENRE*/
case 5:/*LANG_ID3_COMMENT*/
info=id3->comment;
break;
case 6:/*LANG_ID3_GENRE*/
info = id3_get_genre(id3);
break;
case 5:/*LANG_ID3_YEAR*/
case 7:/*LANG_ID3_YEAR*/
if (id3->year_string)
info = id3->year_string;
else if (id3->year)
@ -1193,34 +1201,34 @@ static char * id3_get_info(int selected_item, void* data, char *buffer)
info = buffer;
}
break;
case 6:/*LANG_ID3_LENGTH*/
case 8:/*LANG_ID3_LENGTH*/
gui_wps_format_time(buffer, MAX_PATH, id3->length);
info=buffer;
break;
case 7:/*LANG_ID3_PLAYLIST*/
case 9:/*LANG_ID3_PLAYLIST*/
snprintf(buffer, MAX_PATH, "%d/%d", playlist_get_display_index(),
playlist_amount());
info=buffer;
break;
case 8:/*LANG_ID3_BITRATE*/
case 10:/*LANG_ID3_BITRATE*/
snprintf(buffer, MAX_PATH, "%d kbps%s", id3->bitrate,
id3->vbr ? str(LANG_ID3_VBR) : (const unsigned char*) "");
info=buffer;
break;
case 9:/*LANG_ID3_FRECUENCY*/
case 11:/*LANG_ID3_FRECUENCY*/
snprintf(buffer, MAX_PATH, "%ld Hz", id3->frequency);
info=buffer;
break;
#if CONFIG_CODEC == SWCODEC
case 10:/*LANG_ID3_TRACK_GAIN*/
case 12:/*LANG_ID3_TRACK_GAIN*/
info=id3->track_gain_string;
break;
case 11:/*LANG_ID3_ALBUM_GAIN*/
case 13:/*LANG_ID3_ALBUM_GAIN*/
info=id3->album_gain_string;
break;
case 12:/*LANG_ID3_PATH*/
case 14:/*LANG_ID3_PATH*/
#else
case 10:/*LANG_ID3_PATH*/
case 12:/*LANG_ID3_PATH*/
#endif
info=id3->path;
break;

View file

@ -102,18 +102,22 @@ static long tempbuf_left; /* Buffer space left. */
static long tempbuf_pos;
/* Tags we want to get sorted (loaded to the tempbuf). */
static const int sorted_tags[] = { tag_artist, tag_album, tag_genre, tag_composer, tag_title };
static const int sorted_tags[] = { tag_artist, tag_album, tag_genre,
tag_composer, tag_comment, tag_albumartist, tag_title };
/* Uniqued tags (we can use these tags with filters and conditional clauses). */
static const int unique_tags[] = { tag_artist, tag_album, tag_genre, tag_composer };
static const int unique_tags[] = { tag_artist, tag_album, tag_genre,
tag_composer, tag_comment, tag_albumartist };
/* Numeric tags (we can use these tags with conditional clauses). */
static const int numeric_tags[] = { tag_year, tag_tracknumber, tag_length, tag_bitrate,
tag_playcount, tag_playtime, tag_lastplayed, tag_virt_autoscore };
static const int numeric_tags[] = { tag_year, tag_tracknumber, tag_length,
tag_bitrate, tag_playcount, tag_playtime, tag_lastplayed,
tag_virt_autoscore };
/* String presentation of the tags defined in tagcache.h. Must be in correct order! */
static const char *tags_str[] = { "artist", "album", "genre", "title",
"filename", "composer", "year", "tracknumber", "bitrate", "length",
"playcount", "playtime", "lastplayed" };
"filename", "composer", "comment", "albumartist", "year", "tracknumber",
"bitrate", "length", "playcount", "playtime", "lastplayed" };
/* Status information of the tagcache. */
static struct tagcache_stat tc_stat;
@ -1393,6 +1397,8 @@ bool tagcache_fill_tags(struct mp3entry *id3, const char *filename)
id3->album = get_tag(entry, tag_album)->tag_data;
id3->genre_string = get_tag(entry, tag_genre)->tag_data;
id3->composer = get_tag(entry, tag_composer)->tag_data;
id3->comment = get_tag(entry, tag_comment)->tag_data;
id3->albumartist = get_tag(entry, tag_albumartist)->tag_data;
id3->year = get_tag_numeric(entry, tag_year);
id3->tracknum = get_tag_numeric(entry, tag_tracknumber);
id3->bitrate = get_tag_numeric(entry, tag_bitrate);
@ -1550,6 +1556,8 @@ static void add_tagcache(char *path)
ADD_TAG(entry, tag_album, &track.id3.album);
ADD_TAG(entry, tag_genre, &genrestr);
ADD_TAG(entry, tag_composer, &track.id3.composer);
ADD_TAG(entry, tag_comment, &track.id3.comment);
ADD_TAG(entry, tag_albumartist, &track.id3.albumartist);
entry.data_length = offset;
/* Write the header */
@ -1562,6 +1570,8 @@ static void add_tagcache(char *path)
write_item(track.id3.album);
write_item(genrestr);
write_item(track.id3.composer);
write_item(track.id3.comment);
write_item(track.id3.albumartist);
total_entry_count++;
}
@ -2882,6 +2892,10 @@ bool tagcache_create_changelog(struct tagcache_search *tcs)
if (! (idx.flag & FLAG_DIRTYNUM) )
continue;
/* Skip deleted entries too. */
if (idx.flag & FLAG_DELETED)
continue;
/* Now retrieve all tags. */
for (j = 0; j < TAG_COUNT; j++)
{

View file

@ -23,12 +23,12 @@
#include "id3.h"
enum tag_type { tag_artist = 0, tag_album, tag_genre, tag_title,
tag_filename, tag_composer, tag_year, tag_tracknumber,
tag_filename, tag_composer, tag_comment, tag_albumartist, tag_year, tag_tracknumber,
tag_bitrate, tag_length, tag_playcount, tag_playtime, tag_lastplayed,
/* Virtual tags */
tag_virt_autoscore };
#define TAG_COUNT 13
#define TAG_COUNT 15
/* Maximum length of a single tag. */
#define TAG_MAXLEN (MAX_PATH*2)
@ -40,7 +40,7 @@ enum tag_type { tag_artist = 0, tag_album, tag_genre, tag_title,
#define IDX_BUF_DEPTH 64
/* Tag Cache Header version 'TCHxx'. Increment when changing internal structures. */
#define TAGCACHE_MAGIC 0x54434806
#define TAGCACHE_MAGIC 0x54434807
/* How much to allocate extra space for ramcache. */
#define TAGCACHE_RESERVE 32768

View file

@ -195,6 +195,9 @@ static int get_tag(int *tag)
MATCH(tag, buf, "artist", tag_artist);
MATCH(tag, buf, "bitrate", tag_bitrate);
MATCH(tag, buf, "composer", tag_composer);
MATCH(tag, buf, "comment", tag_comment);
MATCH(tag, buf, "albumartist", tag_albumartist);
MATCH(tag, buf, "ensemble", tag_albumartist);
MATCH(tag, buf, "genre", tag_genre);
MATCH(tag, buf, "length", tag_length);
MATCH(tag, buf, "title", tag_title);

View file

@ -142,6 +142,8 @@ struct mp3entry {
char* track_string;
char* year_string;
char* composer;
char* comment;
char* albumartist;
int tracknum;
int version;
int layer;

View file

@ -351,6 +351,14 @@ static int parseyearnum( struct mp3entry* entry, char* tag, int bufferpos )
return bufferpos;
}
/* parse comment */
static int parsecomment( struct mp3entry* entry, char* tag, int bufferpos )
{
entry->comment = tag + 4; // simplistic
return bufferpos;
}
/* parse numeric genre from string, version 2.2 and 2.3 */
static int parsegenre( struct mp3entry* entry, char* tag, int bufferpos )
{
@ -448,6 +456,9 @@ static const struct tag_resolver taglist[] = {
{ "TYER", 4, offsetof(struct mp3entry, year_string), &parseyearnum, false },
{ "TYE", 3, offsetof(struct mp3entry, year_string), &parseyearnum, false },
{ "TCOM", 4, offsetof(struct mp3entry, composer), NULL, false },
{ "TPE2", 4, offsetof(struct mp3entry, albumartist), NULL, false },
{ "TP2", 3, offsetof(struct mp3entry, albumartist), NULL, false },
{ "COMM", 4, offsetof(struct mp3entry, comment), &parsecomment, false },
{ "TCON", 4, offsetof(struct mp3entry, genre_string), &parsegenre, false },
{ "TCO", 3, offsetof(struct mp3entry, genre_string), &parsegenre, false },
#if CONFIG_CODEC == SWCODEC
@ -1151,6 +1162,10 @@ void adjust_mp3entry(struct mp3entry *entry, void *dest, void *orig)
entry->year_string += offset;
if (entry->composer)
entry->composer += offset;
if (entry->comment)
entry->comment += offset;
if (entry->albumartist)
entry->albumartist += offset;
#if CONFIG_CODEC == SWCODEC
if (entry->track_gain_string)
entry->track_gain_string += offset;