summaryrefslogtreecommitdiff
path: root/apps/tagcache.h
diff options
context:
space:
mode:
authorMiika Pekkarinen <miipekk@ihme.org>2009-06-20 16:17:54 +0000
committerMiika Pekkarinen <miipekk@ihme.org>2009-06-20 16:17:54 +0000
commit8e2bdcaab6857daed1174487e4262d1a4c5db9ab (patch)
tree66441264df232454d909ca94bdfdc9a915842e59 /apps/tagcache.h
parentd79d239382e53fc570cf49e8ea4b5150b42c906e (diff)
downloadrockbox-8e2bdcaab6857daed1174487e4262d1a4c5db9ab.tar.gz
rockbox-8e2bdcaab6857daed1174487e4262d1a4c5db9ab.zip
A bunch of stability fixes into tagcache engine and database browser. Mainly data retrieval problems, races, data corruption of sorted index files at the end with junk data, access to unitialized memory and so on. Should fix FS#8710 and may fix FS#8414.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@21402 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/tagcache.h')
-rw-r--r--apps/tagcache.h33
1 files changed, 19 insertions, 14 deletions
diff --git a/apps/tagcache.h b/apps/tagcache.h
index f2b975c566..0908e3571c 100644
--- a/apps/tagcache.h
+++ b/apps/tagcache.h
@@ -112,8 +112,6 @@ enum tag_type { tag_artist = 0, tag_album, tag_genre, tag_title,
112#define FLAG_DIRTYNUM 0x0004 /* Numeric data has been modified */ 112#define FLAG_DIRTYNUM 0x0004 /* Numeric data has been modified */
113#define FLAG_TRKNUMGEN 0x0008 /* Track number has been generated */ 113#define FLAG_TRKNUMGEN 0x0008 /* Track number has been generated */
114#define FLAG_RESURRECTED 0x0010 /* Statistics data has been resurrected */ 114#define FLAG_RESURRECTED 0x0010 /* Statistics data has been resurrected */
115#define FLAG_GET_ATTR(flag) ((flag >> 16) & 0x0000ffff)
116#define FLAG_SET_ATTR(flag,attr) flag = (flag & 0x0000ffff) | (attr << 16)
117 115
118enum clause { clause_none, clause_is, clause_is_not, clause_gt, clause_gteq, 116enum clause { clause_none, clause_is, clause_is_not, clause_gt, clause_gteq,
119 clause_lt, clause_lteq, clause_contains, clause_not_contains, 117 clause_lt, clause_lteq, clause_contains, clause_not_contains,
@@ -156,20 +154,26 @@ struct tagcache_search_clause
156 char *str; 154 char *str;
157}; 155};
158 156
157struct tagcache_seeklist_entry {
158 int32_t seek;
159 int32_t flag;
160 int32_t idx_id;
161};
162
159struct tagcache_search { 163struct tagcache_search {
160 /* For internal use only. */ 164 /* For internal use only. */
161 int fd, masterfd; 165 int fd, masterfd;
162 int idxfd[TAG_COUNT]; 166 int idxfd[TAG_COUNT];
163 long seek_list[SEEK_LIST_SIZE]; 167 struct tagcache_seeklist_entry seeklist[SEEK_LIST_SIZE];
164 long seek_flags[SEEK_LIST_SIZE]; 168 int seek_list_count;
165 long filter_tag[TAGCACHE_MAX_FILTERS]; 169 int32_t filter_tag[TAGCACHE_MAX_FILTERS];
166 long filter_seek[TAGCACHE_MAX_FILTERS]; 170 int32_t filter_seek[TAGCACHE_MAX_FILTERS];
167 int filter_count; 171 int filter_count;
168 struct tagcache_search_clause *clause[TAGCACHE_MAX_CLAUSES]; 172 struct tagcache_search_clause *clause[TAGCACHE_MAX_CLAUSES];
169 int clause_count; 173 int clause_count;
170 int seek_list_count; 174 int list_position;
171 int seek_pos; 175 int seek_pos;
172 long position; 176 int32_t position;
173 int entry_count; 177 int entry_count;
174 bool valid; 178 bool valid;
175 bool initialized; 179 bool initialized;
@@ -178,13 +182,13 @@ struct tagcache_search {
178 int unique_list_count; 182 int unique_list_count;
179 183
180 /* Exported variables. */ 184 /* Exported variables. */
181 bool ramsearch; 185 bool ramsearch; /* Is ram copy of the tagcache being used. */
182 bool ramresult; 186 bool ramresult; /* False if result is not static, and must be copied. */
183 int type; 187 int type;
184 char *result; 188 char *result; /* The result data for all tags. */
185 int result_len; 189 int result_len; /* Length of the result including \0 */
186 long result_seek; 190 int32_t result_seek; /* Current position in the tag data. */
187 int idx_id; 191 int32_t idx_id; /* Entry number in the master index. */
188}; 192};
189 193
190void tagcache_build(const char *path); 194void tagcache_build(const char *path);
@@ -201,6 +205,7 @@ bool tagcache_is_numeric_tag(int type);
201bool tagcache_find_index(struct tagcache_search *tcs, const char *filename); 205bool tagcache_find_index(struct tagcache_search *tcs, const char *filename);
202bool tagcache_check_clauses(struct tagcache_search *tcs, 206bool tagcache_check_clauses(struct tagcache_search *tcs,
203 struct tagcache_search_clause **clause, int count); 207 struct tagcache_search_clause **clause, int count);
208bool tagcache_is_busy(void);
204bool tagcache_search(struct tagcache_search *tcs, int tag); 209bool tagcache_search(struct tagcache_search *tcs, int tag);
205void tagcache_search_set_uniqbuf(struct tagcache_search *tcs, 210void tagcache_search_set_uniqbuf(struct tagcache_search *tcs,
206 void *buffer, long length); 211 void *buffer, long length);