mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-10-13 18:17:39 -04:00
tagcache/tagtree remove static buffer from tagcache_get_next
callers can supply their own buffer Change-Id: I8996ecfb88e30926296a0cb0563cf6c46977323e
This commit is contained in:
parent
eee48dca39
commit
6634a60bf0
6 changed files with 56 additions and 48 deletions
|
@ -351,6 +351,7 @@ static const struct plugin_api rockbox_api = {
|
||||||
yesno_pop,
|
yesno_pop,
|
||||||
|
|
||||||
/* action handling */
|
/* action handling */
|
||||||
|
list_do_action,
|
||||||
get_custom_action,
|
get_custom_action,
|
||||||
get_action,
|
get_action,
|
||||||
#ifdef HAVE_TOUCHSCREEN
|
#ifdef HAVE_TOUCHSCREEN
|
||||||
|
@ -443,6 +444,7 @@ static const struct plugin_api rockbox_api = {
|
||||||
|
|
||||||
/* talking */
|
/* talking */
|
||||||
talk_id,
|
talk_id,
|
||||||
|
talk_idarray,
|
||||||
talk_file,
|
talk_file,
|
||||||
talk_file_or_spell,
|
talk_file_or_spell,
|
||||||
talk_dir_or_spell,
|
talk_dir_or_spell,
|
||||||
|
@ -546,6 +548,7 @@ static const struct plugin_api rockbox_api = {
|
||||||
/* strings and memory */
|
/* strings and memory */
|
||||||
snprintf,
|
snprintf,
|
||||||
vsnprintf,
|
vsnprintf,
|
||||||
|
vuprintf,
|
||||||
strcpy,
|
strcpy,
|
||||||
strlcpy,
|
strlcpy,
|
||||||
strlen,
|
strlen,
|
||||||
|
@ -568,6 +571,7 @@ static const struct plugin_api rockbox_api = {
|
||||||
memcmp,
|
memcmp,
|
||||||
strcasestr,
|
strcasestr,
|
||||||
strtok_r,
|
strtok_r,
|
||||||
|
output_dyn_value,
|
||||||
/* unicode stuff */
|
/* unicode stuff */
|
||||||
utf8decode,
|
utf8decode,
|
||||||
iso_decode,
|
iso_decode,
|
||||||
|
@ -687,6 +691,8 @@ static const struct plugin_api rockbox_api = {
|
||||||
|
|
||||||
/* playback control */
|
/* playback control */
|
||||||
playlist_get_current,
|
playlist_get_current,
|
||||||
|
playlist_get_resume_info,
|
||||||
|
playlist_get_track_info,
|
||||||
playlist_amount,
|
playlist_amount,
|
||||||
playlist_resume,
|
playlist_resume,
|
||||||
playlist_resume_track,
|
playlist_resume_track,
|
||||||
|
@ -769,7 +775,7 @@ static const struct plugin_api rockbox_api = {
|
||||||
#if CONFIG_RTC
|
#if CONFIG_RTC
|
||||||
mktime,
|
mktime,
|
||||||
#endif
|
#endif
|
||||||
|
format_time_auto,
|
||||||
#if defined(DEBUG) || defined(SIMULATOR)
|
#if defined(DEBUG) || defined(SIMULATOR)
|
||||||
debugf,
|
debugf,
|
||||||
#endif
|
#endif
|
||||||
|
@ -827,13 +833,6 @@ static const struct plugin_api rockbox_api = {
|
||||||
/* new stuff at the end, sort into place next time
|
/* new stuff at the end, sort into place next time
|
||||||
the API gets incompatible */
|
the API gets incompatible */
|
||||||
|
|
||||||
format_time_auto,
|
|
||||||
output_dyn_value,
|
|
||||||
playlist_get_resume_info,
|
|
||||||
playlist_get_track_info,
|
|
||||||
list_do_action,
|
|
||||||
talk_idarray,
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static int plugin_buffer_handle;
|
static int plugin_buffer_handle;
|
||||||
|
|
|
@ -114,6 +114,7 @@ int plugin_open(const char *plugin, const char *parameter);
|
||||||
#include "screen_access.h"
|
#include "screen_access.h"
|
||||||
#include "onplay.h"
|
#include "onplay.h"
|
||||||
#include "screens.h"
|
#include "screens.h"
|
||||||
|
#include "vuprintf.h"
|
||||||
|
|
||||||
#ifdef HAVE_ALBUMART
|
#ifdef HAVE_ALBUMART
|
||||||
#include "albumart.h"
|
#include "albumart.h"
|
||||||
|
@ -162,7 +163,7 @@ int plugin_open(const char *plugin, const char *parameter);
|
||||||
* when this happens please take the opportunity to sort in
|
* when this happens please take the opportunity to sort in
|
||||||
* any new functions "waiting" at the end of the list.
|
* any new functions "waiting" at the end of the list.
|
||||||
*/
|
*/
|
||||||
#define PLUGIN_API_VERSION 269
|
#define PLUGIN_API_VERSION 270
|
||||||
|
|
||||||
/* 239 Marks the removal of ARCHOS HWCODEC and CHARCELL */
|
/* 239 Marks the removal of ARCHOS HWCODEC and CHARCELL */
|
||||||
|
|
||||||
|
@ -404,6 +405,8 @@ struct plugin_api {
|
||||||
bool (*yesno_pop)(const char* text);
|
bool (*yesno_pop)(const char* text);
|
||||||
|
|
||||||
/* action handling */
|
/* action handling */
|
||||||
|
bool (*list_do_action)(int context, int timeout,
|
||||||
|
struct gui_synclist *lists, int *action);
|
||||||
int (*get_custom_action)(int context,int timeout,
|
int (*get_custom_action)(int context,int timeout,
|
||||||
const struct button_mapping* (*get_context_map)(int));
|
const struct button_mapping* (*get_context_map)(int));
|
||||||
int (*get_action)(int context, int timeout);
|
int (*get_action)(int context, int timeout);
|
||||||
|
@ -504,6 +507,7 @@ struct plugin_api {
|
||||||
|
|
||||||
/* talking */
|
/* talking */
|
||||||
int (*talk_id)(int32_t id, bool enqueue);
|
int (*talk_id)(int32_t id, bool enqueue);
|
||||||
|
int (*talk_idarray)(const long *idarray, bool enqueue);
|
||||||
int (*talk_file)(const char *root, const char *dir, const char *file,
|
int (*talk_file)(const char *root, const char *dir, const char *file,
|
||||||
const char *ext, const long *prefix_ids, bool enqueue);
|
const char *ext, const long *prefix_ids, bool enqueue);
|
||||||
int (*talk_file_or_spell)(const char *dirname, const char* filename,
|
int (*talk_file_or_spell)(const char *dirname, const char* filename,
|
||||||
|
@ -623,6 +627,7 @@ struct plugin_api {
|
||||||
int (*snprintf)(char *buf, size_t size, const char *fmt, ...)
|
int (*snprintf)(char *buf, size_t size, const char *fmt, ...)
|
||||||
ATTRIBUTE_PRINTF(3, 4);
|
ATTRIBUTE_PRINTF(3, 4);
|
||||||
int (*vsnprintf)(char *buf, size_t size, const char *fmt, va_list ap);
|
int (*vsnprintf)(char *buf, size_t size, const char *fmt, va_list ap);
|
||||||
|
int (*vuprintf)(vuprintf_push_cb push, void *userp, const char *fmt, va_list ap);
|
||||||
char* (*strcpy)(char *dst, const char *src);
|
char* (*strcpy)(char *dst, const char *src);
|
||||||
size_t (*strlcpy)(char *dst, const char *src, size_t length);
|
size_t (*strlcpy)(char *dst, const char *src, size_t length);
|
||||||
size_t (*strlen)(const char *str);
|
size_t (*strlen)(const char *str);
|
||||||
|
@ -645,6 +650,9 @@ struct plugin_api {
|
||||||
int (*memcmp)(const void *s1, const void *s2, size_t n);
|
int (*memcmp)(const void *s1, const void *s2, size_t n);
|
||||||
char *(*strcasestr) (const char* phaystack, const char* pneedle);
|
char *(*strcasestr) (const char* phaystack, const char* pneedle);
|
||||||
char* (*strtok_r)(char *ptr, const char *sep, char **end);
|
char* (*strtok_r)(char *ptr, const char *sep, char **end);
|
||||||
|
char* (*output_dyn_value)(char *buf, int buf_size, int value,
|
||||||
|
const unsigned char * const *units,
|
||||||
|
unsigned int unit_count, bool binary_scale);
|
||||||
/* unicode stuff */
|
/* unicode stuff */
|
||||||
const unsigned char* (*utf8decode)(const unsigned char *utf8, unsigned short *ucs);
|
const unsigned char* (*utf8decode)(const unsigned char *utf8, unsigned short *ucs);
|
||||||
unsigned char* (*iso_decode)(const unsigned char *iso, unsigned char *utf8, int cp, int count);
|
unsigned char* (*iso_decode)(const unsigned char *iso, unsigned char *utf8, int cp, int count);
|
||||||
|
@ -768,7 +776,7 @@ struct plugin_api {
|
||||||
void *buffer, long length);
|
void *buffer, long length);
|
||||||
bool (*tagcache_search_add_filter)(struct tagcache_search *tcs,
|
bool (*tagcache_search_add_filter)(struct tagcache_search *tcs,
|
||||||
int tag, int seek);
|
int tag, int seek);
|
||||||
bool (*tagcache_get_next)(struct tagcache_search *tcs);
|
bool (*tagcache_get_next)(struct tagcache_search *tcs, char *buf, long size);
|
||||||
bool (*tagcache_retrieve)(struct tagcache_search *tcs, int idxid,
|
bool (*tagcache_retrieve)(struct tagcache_search *tcs, int idxid,
|
||||||
int tag, char *buf, long size);
|
int tag, char *buf, long size);
|
||||||
void (*tagcache_search_finish)(struct tagcache_search *tcs);
|
void (*tagcache_search_finish)(struct tagcache_search *tcs);
|
||||||
|
@ -790,6 +798,9 @@ struct plugin_api {
|
||||||
|
|
||||||
/* playback control */
|
/* playback control */
|
||||||
struct playlist_info* (*playlist_get_current)(void);
|
struct playlist_info* (*playlist_get_current)(void);
|
||||||
|
int (*playlist_get_resume_info)(int *resume_index);
|
||||||
|
int (*playlist_get_track_info)(struct playlist_info* playlist, int index,
|
||||||
|
struct playlist_track_info* info);
|
||||||
int (*playlist_amount)(void);
|
int (*playlist_amount)(void);
|
||||||
int (*playlist_resume)(void);
|
int (*playlist_resume)(void);
|
||||||
void (*playlist_resume_track)(int start_index, unsigned int crc,
|
void (*playlist_resume_track)(int start_index, unsigned int crc,
|
||||||
|
@ -896,7 +907,8 @@ struct plugin_api {
|
||||||
#if CONFIG_RTC
|
#if CONFIG_RTC
|
||||||
time_t (*mktime)(struct tm *t);
|
time_t (*mktime)(struct tm *t);
|
||||||
#endif
|
#endif
|
||||||
|
const char* (*format_time_auto)(char *buffer, int buf_len, long value,
|
||||||
|
int unit_idx, bool supress_unit);
|
||||||
#if defined(DEBUG) || defined(SIMULATOR)
|
#if defined(DEBUG) || defined(SIMULATOR)
|
||||||
void (*debugf)(const char *fmt, ...) ATTRIBUTE_PRINTF(1, 2);
|
void (*debugf)(const char *fmt, ...) ATTRIBUTE_PRINTF(1, 2);
|
||||||
#endif
|
#endif
|
||||||
|
@ -958,17 +970,6 @@ struct plugin_api {
|
||||||
/* new stuff at the end, sort into place next time
|
/* new stuff at the end, sort into place next time
|
||||||
the API gets incompatible */
|
the API gets incompatible */
|
||||||
|
|
||||||
const char* (*format_time_auto)(char *buffer, int buf_len, long value,
|
|
||||||
int unit_idx, bool supress_unit);
|
|
||||||
char* (*output_dyn_value)(char *buf, int buf_size, int value,
|
|
||||||
const unsigned char * const *units,
|
|
||||||
unsigned int unit_count, bool binary_scale);
|
|
||||||
int (*playlist_get_resume_info)(int *resume_index);
|
|
||||||
int (*playlist_get_track_info)(struct playlist_info* playlist, int index,
|
|
||||||
struct playlist_track_info* info);
|
|
||||||
bool (*list_do_action)(int context, int timeout,
|
|
||||||
struct gui_synclist *lists, int *action);
|
|
||||||
int (*talk_idarray)(const long *idarray, bool enqueue);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/* plugin header */
|
/* plugin header */
|
||||||
|
|
|
@ -1141,6 +1141,8 @@ static void write_artist_entry(struct tagcache_search *tcs,
|
||||||
static int get_tcs_search_res(int type, struct tagcache_search *tcs,
|
static int get_tcs_search_res(int type, struct tagcache_search *tcs,
|
||||||
void **buf, size_t *bufsz)
|
void **buf, size_t *bufsz)
|
||||||
{
|
{
|
||||||
|
char tcs_buf[TAGCACHE_BUFSZ];
|
||||||
|
const long tcs_bufsz = sizeof(tcs_buf);
|
||||||
int ret = SUCCESS;
|
int ret = SUCCESS;
|
||||||
unsigned int l, name_idx = 0;
|
unsigned int l, name_idx = 0;
|
||||||
void (*writefn)(struct tagcache_search *, int, unsigned int);
|
void (*writefn)(struct tagcache_search *, int, unsigned int);
|
||||||
|
@ -1156,7 +1158,7 @@ static int get_tcs_search_res(int type, struct tagcache_search *tcs,
|
||||||
data_size = sizeof(struct album_data);
|
data_size = sizeof(struct album_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
while (rb->tagcache_get_next(tcs))
|
while (rb->tagcache_get_next(tcs, tcs_buf, tcs_bufsz))
|
||||||
{
|
{
|
||||||
if (rb->button_get(false) > BUTTON_NONE)
|
if (rb->button_get(false) > BUTTON_NONE)
|
||||||
{
|
{
|
||||||
|
@ -1196,6 +1198,8 @@ static int get_tcs_search_res(int type, struct tagcache_search *tcs,
|
||||||
static int create_album_untagged(struct tagcache_search *tcs,
|
static int create_album_untagged(struct tagcache_search *tcs,
|
||||||
void **buf, size_t *bufsz)
|
void **buf, size_t *bufsz)
|
||||||
{
|
{
|
||||||
|
static char tcs_buf[TAGCACHE_BUFSZ];
|
||||||
|
const long tcs_bufsz = sizeof(tcs_buf);
|
||||||
int ret = SUCCESS;
|
int ret = SUCCESS;
|
||||||
int album_count = pf_idx.album_ct; /* store existing count */
|
int album_count = pf_idx.album_ct; /* store existing count */
|
||||||
int total_count = pf_idx.album_ct + pf_idx.artist_ct * 2;
|
int total_count = pf_idx.album_ct + pf_idx.artist_ct * 2;
|
||||||
|
@ -1210,7 +1214,7 @@ static int create_album_untagged(struct tagcache_search *tcs,
|
||||||
{
|
{
|
||||||
rb->tagcache_search_add_filter(tcs, tag_album, pf_idx.album_untagged_seek);
|
rb->tagcache_search_add_filter(tcs, tag_album, pf_idx.album_untagged_seek);
|
||||||
|
|
||||||
while (rb->tagcache_get_next(tcs))
|
while (rb->tagcache_get_next(tcs, tcs_buf, tcs_bufsz))
|
||||||
{
|
{
|
||||||
if (rb->button_get(false) > BUTTON_NONE) {
|
if (rb->button_get(false) > BUTTON_NONE) {
|
||||||
if (confirm_quit())
|
if (confirm_quit())
|
||||||
|
@ -1339,6 +1343,8 @@ static int build_artist_index(struct tagcache_search *tcs,
|
||||||
|
|
||||||
static int assign_album_year(void)
|
static int assign_album_year(void)
|
||||||
{
|
{
|
||||||
|
char tcs_buf[TAGCACHE_BUFSZ];
|
||||||
|
const long tcs_bufsz = sizeof(tcs_buf);
|
||||||
draw_progressbar(0, pf_idx.album_ct, "Assigning Album Year");
|
draw_progressbar(0, pf_idx.album_ct, "Assigning Album Year");
|
||||||
for (int album_idx = 0; album_idx < pf_idx.album_ct; album_idx++)
|
for (int album_idx = 0; album_idx < pf_idx.album_ct; album_idx++)
|
||||||
{
|
{
|
||||||
|
@ -1367,7 +1373,7 @@ static int assign_album_year(void)
|
||||||
rb->tagcache_search_add_filter(&tcs, tag_albumartist,
|
rb->tagcache_search_add_filter(&tcs, tag_albumartist,
|
||||||
pf_idx.album_index[album_idx].artist_seek);
|
pf_idx.album_index[album_idx].artist_seek);
|
||||||
|
|
||||||
while (rb->tagcache_get_next(&tcs)) {
|
while (rb->tagcache_get_next(&tcs, tcs_buf, tcs_bufsz)) {
|
||||||
int track_year = rb->tagcache_get_numeric(&tcs, tag_year);
|
int track_year = rb->tagcache_get_numeric(&tcs, tag_year);
|
||||||
if (track_year > album_year)
|
if (track_year > album_year)
|
||||||
album_year = track_year;
|
album_year = track_year;
|
||||||
|
@ -1386,6 +1392,8 @@ static int assign_album_year(void)
|
||||||
*/
|
*/
|
||||||
static int create_album_index(void)
|
static int create_album_index(void)
|
||||||
{
|
{
|
||||||
|
static char tcs_buf[TAGCACHE_BUFSZ];
|
||||||
|
const long tcs_bufsz = sizeof(tcs_buf);
|
||||||
void *buf = pf_idx.buf;
|
void *buf = pf_idx.buf;
|
||||||
size_t buf_size = pf_idx.buf_sz;
|
size_t buf_size = pf_idx.buf_sz;
|
||||||
|
|
||||||
|
@ -1463,7 +1471,7 @@ static int create_album_index(void)
|
||||||
last = 0;
|
last = 0;
|
||||||
final = pf_idx.artist_ct;
|
final = pf_idx.artist_ct;
|
||||||
retry = 0;
|
retry = 0;
|
||||||
if (rb->tagcache_get_next(&tcs))
|
if (rb->tagcache_get_next(&tcs, tcs_buf, tcs_bufsz))
|
||||||
{
|
{
|
||||||
|
|
||||||
retry_artist_lookup:
|
retry_artist_lookup:
|
||||||
|
@ -1981,6 +1989,8 @@ static int pf_tcs_retrieve_file_name(int fn_idx)
|
||||||
*/
|
*/
|
||||||
static void create_track_index(const int slide_index)
|
static void create_track_index(const int slide_index)
|
||||||
{
|
{
|
||||||
|
char tcs_buf[TAGCACHE_BUFSZ];
|
||||||
|
const long tcs_bufsz = sizeof(tcs_buf);
|
||||||
buf_ctx_lock();
|
buf_ctx_lock();
|
||||||
if ( slide_index == pf_tracks.cur_idx )
|
if ( slide_index == pf_tracks.cur_idx )
|
||||||
return;
|
return;
|
||||||
|
@ -1998,7 +2008,7 @@ static void create_track_index(const int slide_index)
|
||||||
int string_index = 0;
|
int string_index = 0;
|
||||||
pf_tracks.count = 0;
|
pf_tracks.count = 0;
|
||||||
|
|
||||||
while (rb->tagcache_get_next(&tcs))
|
while (rb->tagcache_get_next(&tcs, tcs_buf, tcs_bufsz))
|
||||||
{
|
{
|
||||||
int disc_num = rb->tagcache_get_numeric(&tcs, tag_discnumber);
|
int disc_num = rb->tagcache_get_numeric(&tcs, tag_discnumber);
|
||||||
int track_num = rb->tagcache_get_numeric(&tcs, tag_tracknumber);
|
int track_num = rb->tagcache_get_numeric(&tcs, tag_tracknumber);
|
||||||
|
@ -2073,7 +2083,8 @@ static bool get_albumart_for_index_from_db(const int slide_index, char *buf,
|
||||||
int buflen)
|
int buflen)
|
||||||
{
|
{
|
||||||
bool ret;
|
bool ret;
|
||||||
|
char tcs_buf[TAGCACHE_BUFSZ];
|
||||||
|
const long tcs_bufsz = sizeof(tcs_buf);
|
||||||
if (tcs.valid || !rb->tagcache_search(&tcs, tag_filename))
|
if (tcs.valid || !rb->tagcache_search(&tcs, tag_filename))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
@ -2084,7 +2095,7 @@ static bool get_albumart_for_index_from_db(const int slide_index, char *buf,
|
||||||
rb->tagcache_search_add_filter(&tcs, tag_albumartist,
|
rb->tagcache_search_add_filter(&tcs, tag_albumartist,
|
||||||
pf_idx.album_index[slide_index].artist_seek);
|
pf_idx.album_index[slide_index].artist_seek);
|
||||||
|
|
||||||
ret = rb->tagcache_get_next(&tcs) &&
|
ret = rb->tagcache_get_next(&tcs, tcs_buf, tcs_bufsz) &&
|
||||||
retrieve_id3(&id3, tcs.result) &&
|
retrieve_id3(&id3, tcs.result) &&
|
||||||
search_albumart_files(&id3, ":", buf, buflen);
|
search_albumart_files(&id3, ":", buf, buflen);
|
||||||
|
|
||||||
|
|
|
@ -102,9 +102,6 @@
|
||||||
*/
|
*/
|
||||||
#define TAGCACHE_SUPPORT_FOREIGN_ENDIAN
|
#define TAGCACHE_SUPPORT_FOREIGN_ENDIAN
|
||||||
|
|
||||||
/* Maximum length of a single tag. */
|
|
||||||
#define TAG_MAXLEN (MAX_PATH*2)
|
|
||||||
|
|
||||||
/* Allow a little drift to the filename ordering (should not be too high/low). */
|
/* Allow a little drift to the filename ordering (should not be too high/low). */
|
||||||
#define POS_HISTORY_COUNT 4
|
#define POS_HISTORY_COUNT 4
|
||||||
|
|
||||||
|
@ -169,9 +166,6 @@ static struct event_queue tagcache_queue SHAREDBSS_ATTR;
|
||||||
static long tagcache_stack[(DEFAULT_STACK_SIZE + 0x4000)/sizeof(long)];
|
static long tagcache_stack[(DEFAULT_STACK_SIZE + 0x4000)/sizeof(long)];
|
||||||
static const char tagcache_thread_name[] = "tagcache";
|
static const char tagcache_thread_name[] = "tagcache";
|
||||||
#endif
|
#endif
|
||||||
/* buffer size for all the (stack allocated & static) buffers handling tc data */
|
|
||||||
#define TAGCACHE_BUFSZ (TAG_MAXLEN+32)
|
|
||||||
|
|
||||||
|
|
||||||
/* Previous path when scanning directory tree recursively. */
|
/* Previous path when scanning directory tree recursively. */
|
||||||
static char curpath[TAGCACHE_BUFSZ];
|
static char curpath[TAGCACHE_BUFSZ];
|
||||||
|
@ -1849,11 +1843,8 @@ bool tagcache_search_add_clause(struct tagcache_search *tcs,
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool get_next(struct tagcache_search *tcs, bool is_numeric)
|
static bool get_next(struct tagcache_search *tcs, bool is_numeric, char *buf, long bufsz)
|
||||||
{
|
{
|
||||||
/* WARNING pointers into buf are used in outside functions */
|
|
||||||
static char buf[TAGCACHE_BUFSZ];
|
|
||||||
const int bufsz = sizeof(buf);
|
|
||||||
struct tagfile_entry entry;
|
struct tagfile_entry entry;
|
||||||
#if defined(HAVE_TC_RAMCACHE) && defined(HAVE_DIRCACHE)
|
#if defined(HAVE_TC_RAMCACHE) && defined(HAVE_DIRCACHE)
|
||||||
long flag = 0;
|
long flag = 0;
|
||||||
|
@ -2001,12 +1992,12 @@ static bool get_next(struct tagcache_search *tcs, bool is_numeric)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool tagcache_get_next(struct tagcache_search *tcs)
|
bool tagcache_get_next(struct tagcache_search *tcs, char *buf, long size)
|
||||||
{
|
{
|
||||||
if (tcs->valid && tagcache_is_usable())
|
if (tcs->valid && tagcache_is_usable())
|
||||||
{
|
{
|
||||||
bool is_numeric = TAGCACHE_IS_NUMERIC(tcs->type);
|
bool is_numeric = TAGCACHE_IS_NUMERIC(tcs->type);
|
||||||
while (get_next(tcs, is_numeric))
|
while (get_next(tcs, is_numeric, buf, size))
|
||||||
{
|
{
|
||||||
if (tcs->result_len > 1)
|
if (tcs->result_len > 1)
|
||||||
return true;
|
return true;
|
||||||
|
@ -3971,8 +3962,6 @@ static bool delete_entry(long idx_id)
|
||||||
int tag, i;
|
int tag, i;
|
||||||
struct index_entry idx, myidx;
|
struct index_entry idx, myidx;
|
||||||
struct master_header myhdr;
|
struct master_header myhdr;
|
||||||
char buf[TAGCACHE_BUFSZ];
|
|
||||||
const int bufsz = sizeof(buf);
|
|
||||||
int in_use[TAG_COUNT];
|
int in_use[TAG_COUNT];
|
||||||
|
|
||||||
logf("delete_entry(): %ld", idx_id);
|
logf("delete_entry(): %ld", idx_id);
|
||||||
|
@ -4081,7 +4070,8 @@ static bool delete_entry(long idx_id)
|
||||||
/* Skip the header block */
|
/* Skip the header block */
|
||||||
lseek(fd, myidx.tag_seek[tag], SEEK_SET);
|
lseek(fd, myidx.tag_seek[tag], SEEK_SET);
|
||||||
|
|
||||||
switch (read_tagfile_entry_and_tag(fd, &tfe, buf, bufsz))
|
switch (read_tagfile_entry_and_tag(fd, &tfe,
|
||||||
|
build_idx_buf, build_idx_bufsz))
|
||||||
{
|
{
|
||||||
case e_SUCCESS_LEN_ZERO:
|
case e_SUCCESS_LEN_ZERO:
|
||||||
logf("deleted_entry(): SUCCESS");
|
logf("deleted_entry(): SUCCESS");
|
||||||
|
@ -4099,7 +4089,8 @@ static bool delete_entry(long idx_id)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
myidx.tag_seek[tag] = crc_32(buf, strlen(buf), 0xffffffff);
|
myidx.tag_seek[tag] = crc_32(build_idx_buf,
|
||||||
|
strlen(build_idx_buf), 0xffffffff);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (in_use[tag])
|
if (in_use[tag])
|
||||||
|
|
|
@ -53,6 +53,10 @@ enum tag_type { tag_artist = 0, tag_album, tag_genre, tag_title,
|
||||||
|
|
||||||
/* Tag to be used on untagged files. */
|
/* Tag to be used on untagged files. */
|
||||||
#define UNTAGGED "<Untagged>"
|
#define UNTAGGED "<Untagged>"
|
||||||
|
/* Maximum length of a single tag. */
|
||||||
|
#define TAG_MAXLEN (MAX_PATH*2)
|
||||||
|
/* buffer size for all the (stack allocated & static) buffers handling tc data */
|
||||||
|
#define TAGCACHE_BUFSZ (TAG_MAXLEN+32)
|
||||||
|
|
||||||
/* Numeric tags (we can use these tags with conditional clauses). */
|
/* Numeric tags (we can use these tags with conditional clauses). */
|
||||||
#define TAGCACHE_NUMERIC_TAGS ((1LU << tag_year) | (1LU << tag_discnumber) | \
|
#define TAGCACHE_NUMERIC_TAGS ((1LU << tag_year) | (1LU << tag_discnumber) | \
|
||||||
|
@ -172,7 +176,7 @@ bool tagcache_search_add_filter(struct tagcache_search *tcs,
|
||||||
int tag, int seek);
|
int tag, int seek);
|
||||||
bool tagcache_search_add_clause(struct tagcache_search *tcs,
|
bool tagcache_search_add_clause(struct tagcache_search *tcs,
|
||||||
struct tagcache_search_clause *clause);
|
struct tagcache_search_clause *clause);
|
||||||
bool tagcache_get_next(struct tagcache_search *tcs);
|
bool tagcache_get_next(struct tagcache_search *tcs, char *buf, long size);
|
||||||
bool tagcache_retrieve(struct tagcache_search *tcs, int idxid,
|
bool tagcache_retrieve(struct tagcache_search *tcs, int idxid,
|
||||||
int tag, char *buf, long size);
|
int tag, char *buf, long size);
|
||||||
void tagcache_search_finish(struct tagcache_search *tcs);
|
void tagcache_search_finish(struct tagcache_search *tcs);
|
||||||
|
|
|
@ -1448,6 +1448,8 @@ static void tcs_get_basename(struct tagcache_search *tcs, bool is_basename)
|
||||||
|
|
||||||
static int retrieve_entries(struct tree_context *c, int offset, bool init)
|
static int retrieve_entries(struct tree_context *c, int offset, bool init)
|
||||||
{
|
{
|
||||||
|
char tcs_buf[TAGCACHE_BUFSZ];
|
||||||
|
const long tcs_bufsz = sizeof(tcs_buf);
|
||||||
struct tagcache_search tcs;
|
struct tagcache_search tcs;
|
||||||
struct display_format *fmt;
|
struct display_format *fmt;
|
||||||
int i;
|
int i;
|
||||||
|
@ -1584,7 +1586,7 @@ static int retrieve_entries(struct tree_context *c, int offset, bool init)
|
||||||
total_count += 2;
|
total_count += 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (tagcache_get_next(&tcs))
|
while (tagcache_get_next(&tcs, tcs_buf, tcs_bufsz))
|
||||||
{
|
{
|
||||||
if (total_count++ < offset)
|
if (total_count++ < offset)
|
||||||
continue;
|
continue;
|
||||||
|
@ -1729,7 +1731,7 @@ entry_skip_formatter:
|
||||||
return current_entry_count;
|
return current_entry_count;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (tagcache_get_next(&tcs))
|
while (tagcache_get_next(&tcs, tcs_buf, tcs_bufsz))
|
||||||
{
|
{
|
||||||
if (!show_search_progress(false, total_count))
|
if (!show_search_progress(false, total_count))
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue