Index: apps/tagcache.c =================================================================== --- apps/tagcache.c (revision 15908) +++ apps/tagcache.c (working copy) @@ -78,6 +78,7 @@ #include "lang.h" #include "eeprom_settings.h" #endif +#include "albumart.h" #ifdef __PCTOOL__ #define yield() do { } while(0) @@ -108,11 +109,12 @@ /* Tags we want to get sorted (loaded to the tempbuf). */ static const int sorted_tags[] = { tag_artist, tag_album, tag_genre, - tag_composer, tag_comment, tag_albumartist, tag_grouping, tag_title }; + tag_composer, tag_comment, tag_albumartist, tag_grouping, tag_cover, + 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, tag_comment, tag_albumartist, tag_grouping }; + tag_composer, tag_comment, tag_albumartist, tag_grouping, tag_cover }; /* Numeric tags (we can use these tags with conditional clauses). */ static const int numeric_tags[] = { tag_year, tag_discnumber, tag_tracknumber, tag_length, @@ -123,7 +125,8 @@ /* 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", "comment", "albumartist", "grouping", "year", "discnumber", "tracknumber", + "filename", "composer", "comment", "albumartist", "grouping", "cover", + "year", "discnumber", "tracknumber", "bitrate", "length", "playcount", "rating", "playtime", "lastplayed", "commitid" }; /* Status information of the tagcache. */ @@ -188,7 +191,7 @@ /* For the endianess correction */ static const char *tagfile_entry_ec = "ss"; -static const char *index_entry_ec = "llllllllllllllllllll"; /* (1 + TAG_COUNT) * l */ +static const char *index_entry_ec = "lllllllllllllllllllll"; /* (1 + TAG_COUNT) * l */ static const char *tagcache_header_ec = "lll"; static const char *master_header_ec = "llllll"; @@ -1617,6 +1620,7 @@ int path_length = strlen(path); bool has_albumartist; bool has_grouping; + char buf[MAX_PATH]="", *cover=buf; if (cachefd < 0) return ; @@ -1654,7 +1658,7 @@ if (fd < 0) { logf("open fail: %s", path); - return ; + return ; } memset(&id3, 0, sizeof(struct mp3entry)); @@ -1663,6 +1667,8 @@ ret = get_metadata(&id3, fd, path); close(fd); + search_albumart_files(&id3, ".100x100", cover, MAX_PATH); + if (!ret) return ; @@ -1736,6 +1742,7 @@ { ADD_TAG(entry, tag_grouping, &id3.title); } + ADD_TAG(entry, tag_cover, &cover); entry.data_length = offset; /* Write the header */ @@ -1765,6 +1772,7 @@ { write_item(id3.title); } + write_item(cover); total_entry_count++; } Index: apps/tagcache.h =================================================================== --- apps/tagcache.h (revision 15908) +++ apps/tagcache.h (working copy) @@ -23,15 +23,16 @@ #include "id3.h" enum tag_type { tag_artist = 0, tag_album, tag_genre, tag_title, - tag_filename, tag_composer, tag_comment, tag_albumartist, tag_grouping, tag_year, - tag_discnumber, tag_tracknumber, tag_bitrate, tag_length, tag_playcount, tag_rating, + tag_filename, tag_composer, tag_comment, tag_albumartist, tag_grouping, + tag_cover, tag_year, tag_discnumber, tag_tracknumber, tag_bitrate, + tag_length, tag_playcount, tag_rating, tag_playtime, tag_lastplayed, tag_commitid, /* Virtual tags */ tag_virt_length_min, tag_virt_length_sec, tag_virt_playtime_min, tag_virt_playtime_sec, tag_virt_entryage, tag_virt_autoscore }; -#define TAG_COUNT 19 +#define TAG_COUNT 20 /* Maximum length of a single tag. */ #define TAG_MAXLEN (MAX_PATH*2) @@ -43,7 +44,7 @@ #define IDX_BUF_DEPTH 64 /* Tag Cache Header version 'TCHxx'. Increment when changing internal structures. */ -#define TAGCACHE_MAGIC 0x5443480b +#define TAGCACHE_MAGIC 0x5443482b /* How much to allocate extra space for ramcache. */ #define TAGCACHE_RESERVE 32768 Index: apps/tagnavi.config =================================================================== --- apps/tagnavi.config (revision 15908) +++ apps/tagnavi.config (working copy) @@ -147,6 +147,14 @@ "Album" -> title = "fmt_title" ? album = "#album#" "Composer" -> title = "fmt_title" ? composer = "#composer#" +# Define the "cover" sub menu +%menu_start "cover" "Cover by..." +"Genre" -> genre -> cover -> title = "fmt_title" +"Artist" -> artist -> cover -> title = "fmt_title" +"Composer" -> composer -> cover -> title = "fmt_title" +"Year" -> year -> cover -> title = "fmt_title" +"All" -> cover -> title = "fmt_title" + # Define the runtime sub menu %menu_start "runtime" "Play history" "Most played (Plays|Score)" -> title = "fmt_mostplayed" ? playcount > "0" @@ -176,6 +184,7 @@ "History..." ==> "runtime" "Same as current..." ==> "same" "Search..." ==> "search" +"Cover by..." ==> "cover" "Custom view..." ==> "custom" # And finally set main menu as our root menu Index: apps/tagtree.c =================================================================== --- apps/tagtree.c (revision 15908) +++ apps/tagtree.c (working copy) @@ -215,6 +215,7 @@ MATCH(tag, buf, "albumartist", tag_albumartist); MATCH(tag, buf, "ensemble", tag_albumartist); MATCH(tag, buf, "grouping", tag_grouping); + MATCH(tag, buf, "cover", tag_cover); MATCH(tag, buf, "genre", tag_genre); MATCH(tag, buf, "length", tag_length); MATCH(tag, buf, "Lm", tag_virt_length_min);