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
diff --git a/apps/gui/gwps-common.c b/apps/gui/gwps-common.c
index 41edc00..53b1223 100644
--- a/apps/gui/gwps-common.c
+++ b/apps/gui/gwps-common.c
@@ -504,6 +504,12 @@
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;
diff --git a/apps/lang/deutsch.lang b/apps/lang/deutsch.lang
index 4ae438f..70f8f91 100644
--- a/apps/lang/deutsch.lang
+++ b/apps/lang/deutsch.lang
@@ -5392,6 +5392,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
user:
@@ -5406,6 +5420,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
user:
diff --git a/apps/lang/english.lang b/apps/lang/english.lang
index 66f9060..6590e10 100644
--- a/apps/lang/english.lang
+++ b/apps/lang/english.lang
@@ -5459,6 +5459,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
user:
@@ -5473,6 +5487,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
user:
diff --git a/apps/metadata.c b/apps/metadata.c
index 3f2c496..f5e5d1b 100644
--- a/apps/metadata.c
+++ b/apps/metadata.c
@@ -303,6 +303,22 @@
{
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);
diff --git a/apps/screens.c b/apps/screens.c
index d1929c2..631ce80 100644
--- a/apps/screens.c
+++ b/apps/screens.c
@@ -1142,7 +1142,9 @@
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 @@
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 @@
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 @@
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;
diff --git a/apps/tagcache.c b/apps/tagcache.c
index f6c4ad3..57bde77 100644
--- a/apps/tagcache.c
+++ b/apps/tagcache.c
@@ -102,18 +102,22 @@
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 @@
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 @@
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 @@
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 @@
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++)
{
diff --git a/apps/tagcache.h b/apps/tagcache.h
index 4194851..503da8c 100644
--- a/apps/tagcache.h
+++ b/apps/tagcache.h
@@ -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_bitrate, tag_length, tag_playcount, tag_playtime, tag_lastplayed,
+ 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 @@
#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
diff --git a/apps/tagtree.c b/apps/tagtree.c
index d5d70ac..885ff3e 100644
--- a/apps/tagtree.c
+++ b/apps/tagtree.c
@@ -195,6 +195,9 @@
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);
diff --git a/firmware/export/id3.h b/firmware/export/id3.h
index 75af992..83fc2cd 100644
--- a/firmware/export/id3.h
+++ b/firmware/export/id3.h
@@ -142,6 +142,8 @@
char* track_string;
char* year_string;
char* composer;
+ char* comment;
+ char* albumartist;
int tracknum;
int version;
int layer;
diff --git a/firmware/id3.c b/firmware/id3.c
index bc42cf5..bdcf8e5 100644
--- a/firmware/id3.c
+++ b/firmware/id3.c
@@ -351,6 +351,14 @@
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 @@
{ "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 @@
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;