Fixed tagcache returning incorrect entries.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@10810 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
658202d42a
commit
4294615192
3 changed files with 25 additions and 12 deletions
|
@ -478,6 +478,12 @@ bool tagcache_find_index(struct tagcache_search *tcs, const char *filename)
|
||||||
static bool get_index(int masterfd, int idxid,
|
static bool get_index(int masterfd, int idxid,
|
||||||
struct index_entry *idx, bool use_ram)
|
struct index_entry *idx, bool use_ram)
|
||||||
{
|
{
|
||||||
|
if (idxid < 0)
|
||||||
|
{
|
||||||
|
logf("Incorrect idxid: %d", idxid);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef HAVE_TC_RAMCACHE
|
#ifdef HAVE_TC_RAMCACHE
|
||||||
if (stat.ramcache && use_ram)
|
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) \
|
#define TAG_FILENAME_RAM(tcs) ((tcs->type == tag_filename) \
|
||||||
? (tcs->seek_flags[tcs->seek_list_count] \
|
? (flag & FLAG_DIRCACHE) : 1)
|
||||||
& FLAG_DIRCACHE) : 1)
|
|
||||||
|
|
||||||
static bool get_next(struct tagcache_search *tcs)
|
static bool get_next(struct tagcache_search *tcs)
|
||||||
{
|
{
|
||||||
static char buf[MAX_PATH];
|
static char buf[MAX_PATH];
|
||||||
struct tagfile_entry entry;
|
struct tagfile_entry entry;
|
||||||
|
long flag = 0;
|
||||||
|
|
||||||
if (!tcs->valid || !stat.ready)
|
if (!tcs->valid || !stat.ready)
|
||||||
return false;
|
return false;
|
||||||
|
@ -1039,6 +1045,7 @@ static bool get_next(struct tagcache_search *tcs)
|
||||||
}
|
}
|
||||||
|
|
||||||
tcs->seek_list_count--;
|
tcs->seek_list_count--;
|
||||||
|
flag = tcs->seek_flags[tcs->seek_list_count];
|
||||||
|
|
||||||
/* Seek stream to the correct position and continue to direct fetch. */
|
/* Seek stream to the correct position and continue to direct fetch. */
|
||||||
if ((!tcs->ramsearch || !TAG_FILENAME_RAM(tcs))
|
if ((!tcs->ramsearch || !TAG_FILENAME_RAM(tcs))
|
||||||
|
@ -1076,10 +1083,7 @@ static bool get_next(struct tagcache_search *tcs)
|
||||||
}
|
}
|
||||||
tcs->entry_count--;
|
tcs->entry_count--;
|
||||||
|
|
||||||
if (tagcache_is_unique_tag(tcs->type))
|
|
||||||
tcs->result_seek = tcs->position;
|
tcs->result_seek = tcs->position;
|
||||||
else
|
|
||||||
tcs->result_seek = tcs->idx_id;
|
|
||||||
|
|
||||||
# ifdef HAVE_DIRCACHE
|
# ifdef HAVE_DIRCACHE
|
||||||
if (tcs->type == tag_filename)
|
if (tcs->type == tag_filename)
|
||||||
|
@ -1088,6 +1092,8 @@ static bool get_next(struct tagcache_search *tcs)
|
||||||
buf, sizeof buf);
|
buf, sizeof buf);
|
||||||
tcs->result = buf;
|
tcs->result = buf;
|
||||||
tcs->result_len = strlen(buf) + 1;
|
tcs->result_len = strlen(buf) + 1;
|
||||||
|
tcs->idx_id = FLAG_GET_ATTR(flag);
|
||||||
|
tcs->ramresult = false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -1098,6 +1104,7 @@ static bool get_next(struct tagcache_search *tcs)
|
||||||
tcs->result = ep->tag_data;
|
tcs->result = ep->tag_data;
|
||||||
tcs->result_len = strlen(tcs->result) + 1;
|
tcs->result_len = strlen(tcs->result) + 1;
|
||||||
tcs->idx_id = ep->idx_id;
|
tcs->idx_id = ep->idx_id;
|
||||||
|
tcs->ramresult = true;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -1134,8 +1141,7 @@ static bool get_next(struct tagcache_search *tcs)
|
||||||
tcs->result = buf;
|
tcs->result = buf;
|
||||||
tcs->result_len = strlen(tcs->result) + 1;
|
tcs->result_len = strlen(tcs->result) + 1;
|
||||||
tcs->idx_id = entry.idx_id;
|
tcs->idx_id = entry.idx_id;
|
||||||
if (!tagcache_is_unique_tag(tcs->type))
|
tcs->ramresult = false;
|
||||||
tcs->result_seek = tcs->idx_id;
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -3116,6 +3122,7 @@ static bool load_tagcache(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
idx->flag |= FLAG_DIRCACHE;
|
idx->flag |= FLAG_DIRCACHE;
|
||||||
|
FLAG_SET_ATTR(idx->flag, fe->idx_id);
|
||||||
idx->tag_seek[tag_filename] = (long)dc;
|
idx->tag_seek[tag_filename] = (long)dc;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -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_DELETED 0x0001 /* Entry has been removed from db */
|
||||||
#define FLAG_DIRCACHE 0x0002 /* Filename is a dircache pointer */
|
#define FLAG_DIRCACHE 0x0002 /* Filename is a dircache pointer */
|
||||||
#define FLAG_DIRTYNUM 0x0004 /* Numeric data has been modified */
|
#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,
|
enum clause { clause_none, clause_is, clause_is_not, clause_gt, clause_gteq,
|
||||||
clause_lt, clause_lteq, clause_contains, clause_not_contains,
|
clause_lt, clause_lteq, clause_contains, clause_not_contains,
|
||||||
|
@ -111,7 +113,6 @@ struct tagcache_search {
|
||||||
int clause_count;
|
int clause_count;
|
||||||
int seek_list_count;
|
int seek_list_count;
|
||||||
int seek_pos;
|
int seek_pos;
|
||||||
int idx_id;
|
|
||||||
long position;
|
long position;
|
||||||
int entry_count;
|
int entry_count;
|
||||||
bool valid;
|
bool valid;
|
||||||
|
@ -122,10 +123,12 @@ struct tagcache_search {
|
||||||
|
|
||||||
/* Exported variables. */
|
/* Exported variables. */
|
||||||
bool ramsearch;
|
bool ramsearch;
|
||||||
|
bool ramresult;
|
||||||
int type;
|
int type;
|
||||||
char *result;
|
char *result;
|
||||||
int result_len;
|
int result_len;
|
||||||
long result_seek;
|
long result_seek;
|
||||||
|
int idx_id;
|
||||||
};
|
};
|
||||||
|
|
||||||
int tagcache_str_to_tag(const char *str);
|
int tagcache_str_to_tag(const char *str);
|
||||||
|
|
|
@ -698,12 +698,15 @@ int retrieve_entries(struct tree_context *c, struct tagcache_search *tcs,
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
dptr->newtable = navibrowse;
|
dptr->newtable = navibrowse;
|
||||||
dptr->extraseek = tcs->result_seek;
|
|
||||||
if (tag == tag_title || tag == tag_filename)
|
if (tag == tag_title || tag == tag_filename)
|
||||||
|
{
|
||||||
dptr->newtable = playtrack;
|
dptr->newtable = playtrack;
|
||||||
|
dptr->extraseek = tcs->idx_id;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
dptr->extraseek = tcs->result_seek;
|
||||||
|
|
||||||
if (!tcs->ramsearch || fmt->valid
|
if (!tcs->ramresult || fmt->valid)
|
||||||
|| tagcache_is_numeric_tag(tag))
|
|
||||||
{
|
{
|
||||||
char buf[MAX_PATH];
|
char buf[MAX_PATH];
|
||||||
int buf_pos = 0;
|
int buf_pos = 0;
|
||||||
|
|
Loading…
Reference in a new issue