diff options
-rw-r--r-- | apps/tagcache.c | 23 | ||||
-rw-r--r-- | apps/tagcache.h | 5 | ||||
-rw-r--r-- | apps/tagtree.c | 9 |
3 files changed, 25 insertions, 12 deletions
diff --git a/apps/tagcache.c b/apps/tagcache.c index 14445d6618..2ed80a860b 100644 --- a/apps/tagcache.c +++ b/apps/tagcache.c | |||
@@ -478,6 +478,12 @@ bool tagcache_find_index(struct tagcache_search *tcs, const char *filename) | |||
478 | static bool get_index(int masterfd, int idxid, | 478 | static bool get_index(int masterfd, int idxid, |
479 | struct index_entry *idx, bool use_ram) | 479 | struct index_entry *idx, bool use_ram) |
480 | { | 480 | { |
481 | if (idxid < 0) | ||
482 | { | ||
483 | logf("Incorrect idxid: %d", idxid); | ||
484 | return false; | ||
485 | } | ||
486 | |||
481 | #ifdef HAVE_TC_RAMCACHE | 487 | #ifdef HAVE_TC_RAMCACHE |
482 | if (stat.ramcache && use_ram) | 488 | if (stat.ramcache && use_ram) |
483 | { | 489 | { |
@@ -1005,13 +1011,13 @@ static bool open_files(struct tagcache_search *tcs) | |||
1005 | } | 1011 | } |
1006 | 1012 | ||
1007 | #define TAG_FILENAME_RAM(tcs) ((tcs->type == tag_filename) \ | 1013 | #define TAG_FILENAME_RAM(tcs) ((tcs->type == tag_filename) \ |
1008 | ? (tcs->seek_flags[tcs->seek_list_count] \ | 1014 | ? (flag & FLAG_DIRCACHE) : 1) |
1009 | & FLAG_DIRCACHE) : 1) | ||
1010 | 1015 | ||
1011 | static bool get_next(struct tagcache_search *tcs) | 1016 | static bool get_next(struct tagcache_search *tcs) |
1012 | { | 1017 | { |
1013 | static char buf[MAX_PATH]; | 1018 | static char buf[MAX_PATH]; |
1014 | struct tagfile_entry entry; | 1019 | struct tagfile_entry entry; |
1020 | long flag = 0; | ||
1015 | 1021 | ||
1016 | if (!tcs->valid || !stat.ready) | 1022 | if (!tcs->valid || !stat.ready) |
1017 | return false; | 1023 | return false; |
@@ -1039,6 +1045,7 @@ static bool get_next(struct tagcache_search *tcs) | |||
1039 | } | 1045 | } |
1040 | 1046 | ||
1041 | tcs->seek_list_count--; | 1047 | tcs->seek_list_count--; |
1048 | flag = tcs->seek_flags[tcs->seek_list_count]; | ||
1042 | 1049 | ||
1043 | /* Seek stream to the correct position and continue to direct fetch. */ | 1050 | /* Seek stream to the correct position and continue to direct fetch. */ |
1044 | if ((!tcs->ramsearch || !TAG_FILENAME_RAM(tcs)) | 1051 | if ((!tcs->ramsearch || !TAG_FILENAME_RAM(tcs)) |
@@ -1076,10 +1083,7 @@ static bool get_next(struct tagcache_search *tcs) | |||
1076 | } | 1083 | } |
1077 | tcs->entry_count--; | 1084 | tcs->entry_count--; |
1078 | 1085 | ||
1079 | if (tagcache_is_unique_tag(tcs->type)) | 1086 | tcs->result_seek = tcs->position; |
1080 | tcs->result_seek = tcs->position; | ||
1081 | else | ||
1082 | tcs->result_seek = tcs->idx_id; | ||
1083 | 1087 | ||
1084 | # ifdef HAVE_DIRCACHE | 1088 | # ifdef HAVE_DIRCACHE |
1085 | if (tcs->type == tag_filename) | 1089 | if (tcs->type == tag_filename) |
@@ -1088,6 +1092,8 @@ static bool get_next(struct tagcache_search *tcs) | |||
1088 | buf, sizeof buf); | 1092 | buf, sizeof buf); |
1089 | tcs->result = buf; | 1093 | tcs->result = buf; |
1090 | tcs->result_len = strlen(buf) + 1; | 1094 | tcs->result_len = strlen(buf) + 1; |
1095 | tcs->idx_id = FLAG_GET_ATTR(flag); | ||
1096 | tcs->ramresult = false; | ||
1091 | 1097 | ||
1092 | return true; | 1098 | return true; |
1093 | } | 1099 | } |
@@ -1098,6 +1104,7 @@ static bool get_next(struct tagcache_search *tcs) | |||
1098 | tcs->result = ep->tag_data; | 1104 | tcs->result = ep->tag_data; |
1099 | tcs->result_len = strlen(tcs->result) + 1; | 1105 | tcs->result_len = strlen(tcs->result) + 1; |
1100 | tcs->idx_id = ep->idx_id; | 1106 | tcs->idx_id = ep->idx_id; |
1107 | tcs->ramresult = true; | ||
1101 | 1108 | ||
1102 | return true; | 1109 | return true; |
1103 | } | 1110 | } |
@@ -1134,8 +1141,7 @@ static bool get_next(struct tagcache_search *tcs) | |||
1134 | tcs->result = buf; | 1141 | tcs->result = buf; |
1135 | tcs->result_len = strlen(tcs->result) + 1; | 1142 | tcs->result_len = strlen(tcs->result) + 1; |
1136 | tcs->idx_id = entry.idx_id; | 1143 | tcs->idx_id = entry.idx_id; |
1137 | if (!tagcache_is_unique_tag(tcs->type)) | 1144 | tcs->ramresult = false; |
1138 | tcs->result_seek = tcs->idx_id; | ||
1139 | 1145 | ||
1140 | return true; | 1146 | return true; |
1141 | } | 1147 | } |
@@ -3116,6 +3122,7 @@ static bool load_tagcache(void) | |||
3116 | } | 3122 | } |
3117 | 3123 | ||
3118 | idx->flag |= FLAG_DIRCACHE; | 3124 | idx->flag |= FLAG_DIRCACHE; |
3125 | FLAG_SET_ATTR(idx->flag, fe->idx_id); | ||
3119 | idx->tag_seek[tag_filename] = (long)dc; | 3126 | idx->tag_seek[tag_filename] = (long)dc; |
3120 | } | 3127 | } |
3121 | else | 3128 | else |
diff --git a/apps/tagcache.h b/apps/tagcache.h index d9e1c93cab..dd61931bcd 100644 --- a/apps/tagcache.h +++ b/apps/tagcache.h | |||
@@ -70,6 +70,8 @@ enum tag_type { tag_artist = 0, tag_album, tag_genre, tag_title, | |||
70 | #define FLAG_DELETED 0x0001 /* Entry has been removed from db */ | 70 | #define FLAG_DELETED 0x0001 /* Entry has been removed from db */ |
71 | #define FLAG_DIRCACHE 0x0002 /* Filename is a dircache pointer */ | 71 | #define FLAG_DIRCACHE 0x0002 /* Filename is a dircache pointer */ |
72 | #define FLAG_DIRTYNUM 0x0004 /* Numeric data has been modified */ | 72 | #define FLAG_DIRTYNUM 0x0004 /* Numeric data has been modified */ |
73 | #define FLAG_GET_ATTR(flag) ((flag >> 16) & 0x0000ffff) | ||
74 | #define FLAG_SET_ATTR(flag,attr) flag = (flag & 0x0000ffff) | (attr << 16) | ||
73 | 75 | ||
74 | enum clause { clause_none, clause_is, clause_is_not, clause_gt, clause_gteq, | 76 | enum clause { clause_none, clause_is, clause_is_not, clause_gt, clause_gteq, |
75 | clause_lt, clause_lteq, clause_contains, clause_not_contains, | 77 | clause_lt, clause_lteq, clause_contains, clause_not_contains, |
@@ -111,7 +113,6 @@ struct tagcache_search { | |||
111 | int clause_count; | 113 | int clause_count; |
112 | int seek_list_count; | 114 | int seek_list_count; |
113 | int seek_pos; | 115 | int seek_pos; |
114 | int idx_id; | ||
115 | long position; | 116 | long position; |
116 | int entry_count; | 117 | int entry_count; |
117 | bool valid; | 118 | bool valid; |
@@ -122,10 +123,12 @@ struct tagcache_search { | |||
122 | 123 | ||
123 | /* Exported variables. */ | 124 | /* Exported variables. */ |
124 | bool ramsearch; | 125 | bool ramsearch; |
126 | bool ramresult; | ||
125 | int type; | 127 | int type; |
126 | char *result; | 128 | char *result; |
127 | int result_len; | 129 | int result_len; |
128 | long result_seek; | 130 | long result_seek; |
131 | int idx_id; | ||
129 | }; | 132 | }; |
130 | 133 | ||
131 | int tagcache_str_to_tag(const char *str); | 134 | int tagcache_str_to_tag(const char *str); |
diff --git a/apps/tagtree.c b/apps/tagtree.c index b922aa7395..8ef78699dd 100644 --- a/apps/tagtree.c +++ b/apps/tagtree.c | |||
@@ -698,12 +698,15 @@ int retrieve_entries(struct tree_context *c, struct tagcache_search *tcs, | |||
698 | continue; | 698 | continue; |
699 | 699 | ||
700 | dptr->newtable = navibrowse; | 700 | dptr->newtable = navibrowse; |
701 | dptr->extraseek = tcs->result_seek; | ||
702 | if (tag == tag_title || tag == tag_filename) | 701 | if (tag == tag_title || tag == tag_filename) |
702 | { | ||
703 | dptr->newtable = playtrack; | 703 | dptr->newtable = playtrack; |
704 | dptr->extraseek = tcs->idx_id; | ||
705 | } | ||
706 | else | ||
707 | dptr->extraseek = tcs->result_seek; | ||
704 | 708 | ||
705 | if (!tcs->ramsearch || fmt->valid | 709 | if (!tcs->ramresult || fmt->valid) |
706 | || tagcache_is_numeric_tag(tag)) | ||
707 | { | 710 | { |
708 | char buf[MAX_PATH]; | 711 | char buf[MAX_PATH]; |
709 | int buf_pos = 0; | 712 | int buf_pos = 0; |