diff options
-rw-r--r-- | apps/tagcache.c | 25 | ||||
-rw-r--r-- | apps/tagcache.h | 8 |
2 files changed, 23 insertions, 10 deletions
diff --git a/apps/tagcache.c b/apps/tagcache.c index 9455b97327..ffad383b47 100644 --- a/apps/tagcache.c +++ b/apps/tagcache.c | |||
@@ -55,6 +55,8 @@ | |||
55 | * | 55 | * |
56 | */ | 56 | */ |
57 | 57 | ||
58 | /* #define LOGF_ENABLE */ | ||
59 | |||
58 | #include <stdio.h> | 60 | #include <stdio.h> |
59 | #include <stdlib.h> | 61 | #include <stdlib.h> |
60 | #include <ctype.h> | 62 | #include <ctype.h> |
@@ -100,7 +102,6 @@ static const char tagcache_thread_name[] = "tagcache"; | |||
100 | 102 | ||
101 | /* Previous path when scanning directory tree recursively. */ | 103 | /* Previous path when scanning directory tree recursively. */ |
102 | static char curpath[TAG_MAXLEN+32]; | 104 | static char curpath[TAG_MAXLEN+32]; |
103 | static long curpath_size = sizeof(curpath); | ||
104 | 105 | ||
105 | /* Used when removing duplicates. */ | 106 | /* Used when removing duplicates. */ |
106 | static char *tempbuf; /* Allocated when needed. */ | 107 | static char *tempbuf; /* Allocated when needed. */ |
@@ -190,7 +191,11 @@ struct master_header { | |||
190 | 191 | ||
191 | /* For the endianess correction */ | 192 | /* For the endianess correction */ |
192 | static const char *tagfile_entry_ec = "ss"; | 193 | static const char *tagfile_entry_ec = "ss"; |
193 | static const char *index_entry_ec = "lllllllllllllllllllll"; /* (1 + TAG_COUNT) * l */ | 194 | /** |
195 | Note: This should be (1 + TAG_COUNT) amount of l's. | ||
196 | */ | ||
197 | static const char *index_entry_ec = "lllllllllllllllllllll"; | ||
198 | |||
194 | static const char *tagcache_header_ec = "lll"; | 199 | static const char *tagcache_header_ec = "lll"; |
195 | static const char *master_header_ec = "llllll"; | 200 | static const char *master_header_ec = "llllll"; |
196 | 201 | ||
@@ -654,8 +659,9 @@ static bool write_index(int masterfd, int idxid, struct index_entry *idx) | |||
654 | } | 659 | } |
655 | } | 660 | } |
656 | 661 | ||
657 | /* Don't touch the dircache flag. */ | 662 | /* Don't touch the dircache flag or attributes. */ |
658 | idx_ram->flag = idx->flag | (idx_ram->flag & FLAG_DIRCACHE); | 663 | idx_ram->flag = (idx->flag & 0x0000ffff) |
664 | | (idx_ram->flag & (0xffff0000 | FLAG_DIRCACHE)); | ||
659 | } | 665 | } |
660 | #endif | 666 | #endif |
661 | 667 | ||
@@ -1693,6 +1699,9 @@ static void add_tagcache(char *path, unsigned long mtime | |||
1693 | { | 1699 | { |
1694 | struct index_entry idx; | 1700 | struct index_entry idx; |
1695 | 1701 | ||
1702 | /* TODO: Mark that the index exists (for fast reverse scan) */ | ||
1703 | //found_idx[idx_id/8] |= idx_id%8; | ||
1704 | |||
1696 | if (!get_index(-1, idx_id, &idx, true)) | 1705 | if (!get_index(-1, idx_id, &idx, true)) |
1697 | { | 1706 | { |
1698 | logf("failed to retrieve index entry"); | 1707 | logf("failed to retrieve index entry"); |
@@ -2621,7 +2630,7 @@ static int build_index(int index_type, struct tagcache_header *h, int tmpfd) | |||
2621 | 2630 | ||
2622 | if (idxbuf[j].tag_seek[index_type] < 0) | 2631 | if (idxbuf[j].tag_seek[index_type] < 0) |
2623 | { | 2632 | { |
2624 | logf("update error: %d/%d/%ld", | 2633 | logf("update error: %d/%d/%d", |
2625 | idxbuf[j].flag, i+j, tcmh.tch.entry_count); | 2634 | idxbuf[j].flag, i+j, tcmh.tch.entry_count); |
2626 | error = true; | 2635 | error = true; |
2627 | goto error_exit; | 2636 | goto error_exit; |
@@ -3308,8 +3317,8 @@ static int parse_changelog_line(int line_n, const char *buf, void *parameters) | |||
3308 | 3317 | ||
3309 | idx.tag_seek[import_tags[i]] = data; | 3318 | idx.tag_seek[import_tags[i]] = data; |
3310 | 3319 | ||
3311 | if (import_tags[i] == tag_lastplayed && data > current_tcmh.serial) | 3320 | if (import_tags[i] == tag_lastplayed && data >= current_tcmh.serial) |
3312 | current_tcmh.serial = data; | 3321 | current_tcmh.serial = data + 1; |
3313 | else if (import_tags[i] == tag_commitid && data >= current_tcmh.commitid) | 3322 | else if (import_tags[i] == tag_commitid && data >= current_tcmh.commitid) |
3314 | current_tcmh.commitid = data + 1; | 3323 | current_tcmh.commitid = data + 1; |
3315 | } | 3324 | } |
@@ -4114,7 +4123,7 @@ static bool check_dir(const char *dirname, int add_files) | |||
4114 | yield(); | 4123 | yield(); |
4115 | 4124 | ||
4116 | len = strlen(curpath); | 4125 | len = strlen(curpath); |
4117 | snprintf(&curpath[len], curpath_size - len, "/%s", | 4126 | snprintf(&curpath[len], sizeof(curpath) - len, "/%s", |
4118 | entry->d_name); | 4127 | entry->d_name); |
4119 | 4128 | ||
4120 | processed_dir_count++; | 4129 | processed_dir_count++; |
diff --git a/apps/tagcache.h b/apps/tagcache.h index 9415c9815e..e49b65f1f3 100644 --- a/apps/tagcache.h +++ b/apps/tagcache.h | |||
@@ -24,17 +24,21 @@ | |||
24 | 24 | ||
25 | #include "id3.h" | 25 | #include "id3.h" |
26 | 26 | ||
27 | /** | ||
28 | Note: When adding new tags, make sure to update index_entry_ec in | ||
29 | tagcache.c and bump up the header version too. | ||
30 | */ | ||
27 | enum tag_type { tag_artist = 0, tag_album, tag_genre, tag_title, | 31 | enum tag_type { tag_artist = 0, tag_album, tag_genre, tag_title, |
28 | tag_filename, tag_composer, tag_comment, tag_albumartist, tag_grouping, tag_year, | 32 | tag_filename, tag_composer, tag_comment, tag_albumartist, tag_grouping, tag_year, |
29 | tag_discnumber, tag_tracknumber, tag_bitrate, tag_length, tag_playcount, tag_rating, | 33 | tag_discnumber, tag_tracknumber, tag_bitrate, tag_length, tag_playcount, tag_rating, |
30 | tag_playtime, tag_lastplayed, tag_commitid, tag_mtime, | 34 | tag_playtime, tag_lastplayed, tag_commitid, tag_mtime, |
35 | /* Real tags end here, count them. */ | ||
36 | TAG_COUNT, | ||
31 | /* Virtual tags */ | 37 | /* Virtual tags */ |
32 | tag_virt_length_min, tag_virt_length_sec, | 38 | tag_virt_length_min, tag_virt_length_sec, |
33 | tag_virt_playtime_min, tag_virt_playtime_sec, | 39 | tag_virt_playtime_min, tag_virt_playtime_sec, |
34 | tag_virt_entryage, tag_virt_autoscore }; | 40 | tag_virt_entryage, tag_virt_autoscore }; |
35 | 41 | ||
36 | #define TAG_COUNT 20 | ||
37 | |||
38 | /* Maximum length of a single tag. */ | 42 | /* Maximum length of a single tag. */ |
39 | #define TAG_MAXLEN (MAX_PATH*2) | 43 | #define TAG_MAXLEN (MAX_PATH*2) |
40 | 44 | ||