summaryrefslogtreecommitdiff
path: root/apps/tagcache.c
diff options
context:
space:
mode:
authorDan Everton <dan@iocaine.org>2007-08-08 10:19:56 +0000
committerDan Everton <dan@iocaine.org>2007-08-08 10:19:56 +0000
commiteecfe9f1cb85b53b59d2487e0ae4c05bf43a8bd3 (patch)
tree9ec358e6b12735468c63eebaaa02da9a7b5d0f65 /apps/tagcache.c
parentecae04a9f27f6694e748bbde5d49fbd47a01fec3 (diff)
downloadrockbox-eecfe9f1cb85b53b59d2487e0ae4c05bf43a8bd3.tar.gz
rockbox-eecfe9f1cb85b53b59d2487e0ae4c05bf43a8bd3.zip
Add support for grouping tags. From FS#7362.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@14242 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/tagcache.c')
-rw-r--r--apps/tagcache.c28
1 files changed, 24 insertions, 4 deletions
diff --git a/apps/tagcache.c b/apps/tagcache.c
index da51e0c4e9..309718a932 100644
--- a/apps/tagcache.c
+++ b/apps/tagcache.c
@@ -108,11 +108,11 @@ static long tempbuf_pos;
108 108
109/* Tags we want to get sorted (loaded to the tempbuf). */ 109/* Tags we want to get sorted (loaded to the tempbuf). */
110static const int sorted_tags[] = { tag_artist, tag_album, tag_genre, 110static const int sorted_tags[] = { tag_artist, tag_album, tag_genre,
111 tag_composer, tag_comment, tag_albumartist, tag_title }; 111 tag_composer, tag_comment, tag_albumartist, tag_grouping, tag_title };
112 112
113/* Uniqued tags (we can use these tags with filters and conditional clauses). */ 113/* Uniqued tags (we can use these tags with filters and conditional clauses). */
114static const int unique_tags[] = { tag_artist, tag_album, tag_genre, 114static const int unique_tags[] = { tag_artist, tag_album, tag_genre,
115 tag_composer, tag_comment, tag_albumartist }; 115 tag_composer, tag_comment, tag_albumartist, tag_grouping };
116 116
117/* Numeric tags (we can use these tags with conditional clauses). */ 117/* Numeric tags (we can use these tags with conditional clauses). */
118static const int numeric_tags[] = { tag_year, tag_discnumber, tag_tracknumber, tag_length, 118static const int numeric_tags[] = { tag_year, tag_discnumber, tag_tracknumber, tag_length,
@@ -123,7 +123,7 @@ static const int numeric_tags[] = { tag_year, tag_discnumber, tag_tracknumber, t
123 123
124/* String presentation of the tags defined in tagcache.h. Must be in correct order! */ 124/* String presentation of the tags defined in tagcache.h. Must be in correct order! */
125static const char *tags_str[] = { "artist", "album", "genre", "title", 125static const char *tags_str[] = { "artist", "album", "genre", "title",
126 "filename", "composer", "comment", "albumartist", "year", "discnumber", "tracknumber", 126 "filename", "composer", "comment", "albumartist", "grouping", "year", "discnumber", "tracknumber",
127 "bitrate", "length", "playcount", "rating", "playtime", "lastplayed", "commitid" }; 127 "bitrate", "length", "playcount", "rating", "playtime", "lastplayed", "commitid" };
128 128
129/* Status information of the tagcache. */ 129/* Status information of the tagcache. */
@@ -188,7 +188,7 @@ struct master_header {
188 188
189/* For the endianess correction */ 189/* For the endianess correction */
190static const char *tagfile_entry_ec = "ss"; 190static const char *tagfile_entry_ec = "ss";
191static const char *index_entry_ec = "lllllllllllllllllll"; /* (1 + TAG_COUNT) * l */ 191static const char *index_entry_ec = "llllllllllllllllllll"; /* (1 + TAG_COUNT) * l */
192static const char *tagcache_header_ec = "lll"; 192static const char *tagcache_header_ec = "lll";
193static const char *master_header_ec = "llllll"; 193static const char *master_header_ec = "llllll";
194 194
@@ -1549,6 +1549,7 @@ bool tagcache_fill_tags(struct mp3entry *id3, const char *filename)
1549 id3->composer = get_tag_string(entry, tag_composer); 1549 id3->composer = get_tag_string(entry, tag_composer);
1550 id3->comment = get_tag_string(entry, tag_comment); 1550 id3->comment = get_tag_string(entry, tag_comment);
1551 id3->albumartist = get_tag_string(entry, tag_albumartist); 1551 id3->albumartist = get_tag_string(entry, tag_albumartist);
1552 id3->grouping = get_tag_string(entry, tag_grouping);
1552 1553
1553 id3->playcount = get_tag_numeric(entry, tag_playcount); 1554 id3->playcount = get_tag_numeric(entry, tag_playcount);
1554 id3->rating = get_tag_numeric(entry, tag_rating); 1555 id3->rating = get_tag_numeric(entry, tag_rating);
@@ -1615,6 +1616,7 @@ static void add_tagcache(char *path)
1615 int offset = 0; 1616 int offset = 0;
1616 int path_length = strlen(path); 1617 int path_length = strlen(path);
1617 bool has_albumartist; 1618 bool has_albumartist;
1619 bool has_grouping;
1618 1620
1619 if (cachefd < 0) 1621 if (cachefd < 0)
1620 return ; 1622 return ;
@@ -1708,6 +1710,8 @@ static void add_tagcache(char *path)
1708 /* String tags. */ 1710 /* String tags. */
1709 has_albumartist = track.id3.albumartist != NULL 1711 has_albumartist = track.id3.albumartist != NULL
1710 && strlen(track.id3.albumartist) > 0; 1712 && strlen(track.id3.albumartist) > 0;
1713 has_grouping = track.id3.grouping != NULL
1714 && strlen(track.id3.grouping) > 0;
1711 1715
1712 ADD_TAG(entry, tag_filename, &path); 1716 ADD_TAG(entry, tag_filename, &path);
1713 ADD_TAG(entry, tag_title, &track.id3.title); 1717 ADD_TAG(entry, tag_title, &track.id3.title);
@@ -1724,6 +1728,14 @@ static void add_tagcache(char *path)
1724 { 1728 {
1725 ADD_TAG(entry, tag_albumartist, &track.id3.artist); 1729 ADD_TAG(entry, tag_albumartist, &track.id3.artist);
1726 } 1730 }
1731 if (has_grouping)
1732 {
1733 ADD_TAG(entry, tag_grouping, &track.id3.grouping);
1734 }
1735 else
1736 {
1737 ADD_TAG(entry, tag_grouping, &track.id3.title);
1738 }
1727 entry.data_length = offset; 1739 entry.data_length = offset;
1728 1740
1729 /* Write the header */ 1741 /* Write the header */
@@ -1745,6 +1757,14 @@ static void add_tagcache(char *path)
1745 { 1757 {
1746 write_item(track.id3.artist); 1758 write_item(track.id3.artist);
1747 } 1759 }
1760 if (has_grouping)
1761 {
1762 write_item(track.id3.grouping);
1763 }
1764 else
1765 {
1766 write_item(track.id3.title);
1767 }
1748 total_entry_count++; 1768 total_entry_count++;
1749} 1769}
1750 1770