From 42946151928206fc7c1ddfea1524ee87b8e5ebb5 Mon Sep 17 00:00:00 2001 From: Miika Pekkarinen Date: Wed, 30 Aug 2006 18:18:37 +0000 Subject: Fixed tagcache returning incorrect entries. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@10810 a1c6a512-1295-4272-9138-f99709370657 --- apps/tagcache.c | 23 +++++++++++++++-------- apps/tagcache.h | 5 ++++- apps/tagtree.c | 9 ++++++--- 3 files changed, 25 insertions(+), 12 deletions(-) (limited to 'apps') 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) static bool get_index(int masterfd, int idxid, struct index_entry *idx, bool use_ram) { + if (idxid < 0) + { + logf("Incorrect idxid: %d", idxid); + return false; + } + #ifdef HAVE_TC_RAMCACHE if (stat.ramcache && use_ram) { @@ -1005,13 +1011,13 @@ static bool open_files(struct tagcache_search *tcs) } #define TAG_FILENAME_RAM(tcs) ((tcs->type == tag_filename) \ - ? (tcs->seek_flags[tcs->seek_list_count] \ - & FLAG_DIRCACHE) : 1) + ? (flag & FLAG_DIRCACHE) : 1) static bool get_next(struct tagcache_search *tcs) { static char buf[MAX_PATH]; struct tagfile_entry entry; + long flag = 0; if (!tcs->valid || !stat.ready) return false; @@ -1039,6 +1045,7 @@ static bool get_next(struct tagcache_search *tcs) } tcs->seek_list_count--; + flag = tcs->seek_flags[tcs->seek_list_count]; /* Seek stream to the correct position and continue to direct fetch. */ if ((!tcs->ramsearch || !TAG_FILENAME_RAM(tcs)) @@ -1076,10 +1083,7 @@ static bool get_next(struct tagcache_search *tcs) } tcs->entry_count--; - if (tagcache_is_unique_tag(tcs->type)) - tcs->result_seek = tcs->position; - else - tcs->result_seek = tcs->idx_id; + tcs->result_seek = tcs->position; # ifdef HAVE_DIRCACHE if (tcs->type == tag_filename) @@ -1088,6 +1092,8 @@ static bool get_next(struct tagcache_search *tcs) buf, sizeof buf); tcs->result = buf; tcs->result_len = strlen(buf) + 1; + tcs->idx_id = FLAG_GET_ATTR(flag); + tcs->ramresult = false; return true; } @@ -1098,6 +1104,7 @@ static bool get_next(struct tagcache_search *tcs) tcs->result = ep->tag_data; tcs->result_len = strlen(tcs->result) + 1; tcs->idx_id = ep->idx_id; + tcs->ramresult = true; return true; } @@ -1134,8 +1141,7 @@ static bool get_next(struct tagcache_search *tcs) tcs->result = buf; tcs->result_len = strlen(tcs->result) + 1; tcs->idx_id = entry.idx_id; - if (!tagcache_is_unique_tag(tcs->type)) - tcs->result_seek = tcs->idx_id; + tcs->ramresult = false; return true; } @@ -3116,6 +3122,7 @@ static bool load_tagcache(void) } idx->flag |= FLAG_DIRCACHE; + FLAG_SET_ATTR(idx->flag, fe->idx_id); idx->tag_seek[tag_filename] = (long)dc; } 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, #define FLAG_DELETED 0x0001 /* Entry has been removed from db */ #define FLAG_DIRCACHE 0x0002 /* Filename is a dircache pointer */ #define FLAG_DIRTYNUM 0x0004 /* Numeric data has been modified */ +#define FLAG_GET_ATTR(flag) ((flag >> 16) & 0x0000ffff) +#define FLAG_SET_ATTR(flag,attr) flag = (flag & 0x0000ffff) | (attr << 16) enum clause { clause_none, clause_is, clause_is_not, clause_gt, clause_gteq, clause_lt, clause_lteq, clause_contains, clause_not_contains, @@ -111,7 +113,6 @@ struct tagcache_search { int clause_count; int seek_list_count; int seek_pos; - int idx_id; long position; int entry_count; bool valid; @@ -122,10 +123,12 @@ struct tagcache_search { /* Exported variables. */ bool ramsearch; + bool ramresult; int type; char *result; int result_len; long result_seek; + int idx_id; }; 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, continue; dptr->newtable = navibrowse; - dptr->extraseek = tcs->result_seek; if (tag == tag_title || tag == tag_filename) + { dptr->newtable = playtrack; + dptr->extraseek = tcs->idx_id; + } + else + dptr->extraseek = tcs->result_seek; - if (!tcs->ramsearch || fmt->valid - || tagcache_is_numeric_tag(tag)) + if (!tcs->ramresult || fmt->valid) { char buf[MAX_PATH]; int buf_pos = 0; -- cgit v1.2.3