diff options
-rw-r--r-- | apps/plugin.c | 15 | ||||
-rw-r--r-- | apps/plugin.h | 29 | ||||
-rw-r--r-- | apps/plugins/pictureflow/pictureflow.c | 25 | ||||
-rw-r--r-- | apps/tagcache.c | 23 | ||||
-rw-r--r-- | apps/tagcache.h | 6 | ||||
-rw-r--r-- | apps/tagtree.c | 6 |
6 files changed, 56 insertions, 48 deletions
diff --git a/apps/plugin.c b/apps/plugin.c index da4d3432f5..b1188fc183 100644 --- a/apps/plugin.c +++ b/apps/plugin.c | |||
@@ -351,6 +351,7 @@ static const struct plugin_api rockbox_api = { | |||
351 | yesno_pop, | 351 | yesno_pop, |
352 | 352 | ||
353 | /* action handling */ | 353 | /* action handling */ |
354 | list_do_action, | ||
354 | get_custom_action, | 355 | get_custom_action, |
355 | get_action, | 356 | get_action, |
356 | #ifdef HAVE_TOUCHSCREEN | 357 | #ifdef HAVE_TOUCHSCREEN |
@@ -443,6 +444,7 @@ static const struct plugin_api rockbox_api = { | |||
443 | 444 | ||
444 | /* talking */ | 445 | /* talking */ |
445 | talk_id, | 446 | talk_id, |
447 | talk_idarray, | ||
446 | talk_file, | 448 | talk_file, |
447 | talk_file_or_spell, | 449 | talk_file_or_spell, |
448 | talk_dir_or_spell, | 450 | talk_dir_or_spell, |
@@ -546,6 +548,7 @@ static const struct plugin_api rockbox_api = { | |||
546 | /* strings and memory */ | 548 | /* strings and memory */ |
547 | snprintf, | 549 | snprintf, |
548 | vsnprintf, | 550 | vsnprintf, |
551 | vuprintf, | ||
549 | strcpy, | 552 | strcpy, |
550 | strlcpy, | 553 | strlcpy, |
551 | strlen, | 554 | strlen, |
@@ -568,6 +571,7 @@ static const struct plugin_api rockbox_api = { | |||
568 | memcmp, | 571 | memcmp, |
569 | strcasestr, | 572 | strcasestr, |
570 | strtok_r, | 573 | strtok_r, |
574 | output_dyn_value, | ||
571 | /* unicode stuff */ | 575 | /* unicode stuff */ |
572 | utf8decode, | 576 | utf8decode, |
573 | iso_decode, | 577 | iso_decode, |
@@ -687,6 +691,8 @@ static const struct plugin_api rockbox_api = { | |||
687 | 691 | ||
688 | /* playback control */ | 692 | /* playback control */ |
689 | playlist_get_current, | 693 | playlist_get_current, |
694 | playlist_get_resume_info, | ||
695 | playlist_get_track_info, | ||
690 | playlist_amount, | 696 | playlist_amount, |
691 | playlist_resume, | 697 | playlist_resume, |
692 | playlist_resume_track, | 698 | playlist_resume_track, |
@@ -769,7 +775,7 @@ static const struct plugin_api rockbox_api = { | |||
769 | #if CONFIG_RTC | 775 | #if CONFIG_RTC |
770 | mktime, | 776 | mktime, |
771 | #endif | 777 | #endif |
772 | 778 | format_time_auto, | |
773 | #if defined(DEBUG) || defined(SIMULATOR) | 779 | #if defined(DEBUG) || defined(SIMULATOR) |
774 | debugf, | 780 | debugf, |
775 | #endif | 781 | #endif |
@@ -827,13 +833,6 @@ static const struct plugin_api rockbox_api = { | |||
827 | /* new stuff at the end, sort into place next time | 833 | /* new stuff at the end, sort into place next time |
828 | the API gets incompatible */ | 834 | the API gets incompatible */ |
829 | 835 | ||
830 | format_time_auto, | ||
831 | output_dyn_value, | ||
832 | playlist_get_resume_info, | ||
833 | playlist_get_track_info, | ||
834 | list_do_action, | ||
835 | talk_idarray, | ||
836 | |||
837 | }; | 836 | }; |
838 | 837 | ||
839 | static int plugin_buffer_handle; | 838 | static int plugin_buffer_handle; |
diff --git a/apps/plugin.h b/apps/plugin.h index b6dff14b1f..11adf61e9c 100644 --- a/apps/plugin.h +++ b/apps/plugin.h | |||
@@ -114,6 +114,7 @@ int plugin_open(const char *plugin, const char *parameter); | |||
114 | #include "screen_access.h" | 114 | #include "screen_access.h" |
115 | #include "onplay.h" | 115 | #include "onplay.h" |
116 | #include "screens.h" | 116 | #include "screens.h" |
117 | #include "vuprintf.h" | ||
117 | 118 | ||
118 | #ifdef HAVE_ALBUMART | 119 | #ifdef HAVE_ALBUMART |
119 | #include "albumart.h" | 120 | #include "albumart.h" |
@@ -162,7 +163,7 @@ int plugin_open(const char *plugin, const char *parameter); | |||
162 | * when this happens please take the opportunity to sort in | 163 | * when this happens please take the opportunity to sort in |
163 | * any new functions "waiting" at the end of the list. | 164 | * any new functions "waiting" at the end of the list. |
164 | */ | 165 | */ |
165 | #define PLUGIN_API_VERSION 269 | 166 | #define PLUGIN_API_VERSION 270 |
166 | 167 | ||
167 | /* 239 Marks the removal of ARCHOS HWCODEC and CHARCELL */ | 168 | /* 239 Marks the removal of ARCHOS HWCODEC and CHARCELL */ |
168 | 169 | ||
@@ -404,6 +405,8 @@ struct plugin_api { | |||
404 | bool (*yesno_pop)(const char* text); | 405 | bool (*yesno_pop)(const char* text); |
405 | 406 | ||
406 | /* action handling */ | 407 | /* action handling */ |
408 | bool (*list_do_action)(int context, int timeout, | ||
409 | struct gui_synclist *lists, int *action); | ||
407 | int (*get_custom_action)(int context,int timeout, | 410 | int (*get_custom_action)(int context,int timeout, |
408 | const struct button_mapping* (*get_context_map)(int)); | 411 | const struct button_mapping* (*get_context_map)(int)); |
409 | int (*get_action)(int context, int timeout); | 412 | int (*get_action)(int context, int timeout); |
@@ -504,6 +507,7 @@ struct plugin_api { | |||
504 | 507 | ||
505 | /* talking */ | 508 | /* talking */ |
506 | int (*talk_id)(int32_t id, bool enqueue); | 509 | int (*talk_id)(int32_t id, bool enqueue); |
510 | int (*talk_idarray)(const long *idarray, bool enqueue); | ||
507 | int (*talk_file)(const char *root, const char *dir, const char *file, | 511 | int (*talk_file)(const char *root, const char *dir, const char *file, |
508 | const char *ext, const long *prefix_ids, bool enqueue); | 512 | const char *ext, const long *prefix_ids, bool enqueue); |
509 | int (*talk_file_or_spell)(const char *dirname, const char* filename, | 513 | int (*talk_file_or_spell)(const char *dirname, const char* filename, |
@@ -623,6 +627,7 @@ struct plugin_api { | |||
623 | int (*snprintf)(char *buf, size_t size, const char *fmt, ...) | 627 | int (*snprintf)(char *buf, size_t size, const char *fmt, ...) |
624 | ATTRIBUTE_PRINTF(3, 4); | 628 | ATTRIBUTE_PRINTF(3, 4); |
625 | int (*vsnprintf)(char *buf, size_t size, const char *fmt, va_list ap); | 629 | int (*vsnprintf)(char *buf, size_t size, const char *fmt, va_list ap); |
630 | int (*vuprintf)(vuprintf_push_cb push, void *userp, const char *fmt, va_list ap); | ||
626 | char* (*strcpy)(char *dst, const char *src); | 631 | char* (*strcpy)(char *dst, const char *src); |
627 | size_t (*strlcpy)(char *dst, const char *src, size_t length); | 632 | size_t (*strlcpy)(char *dst, const char *src, size_t length); |
628 | size_t (*strlen)(const char *str); | 633 | size_t (*strlen)(const char *str); |
@@ -645,6 +650,9 @@ struct plugin_api { | |||
645 | int (*memcmp)(const void *s1, const void *s2, size_t n); | 650 | int (*memcmp)(const void *s1, const void *s2, size_t n); |
646 | char *(*strcasestr) (const char* phaystack, const char* pneedle); | 651 | char *(*strcasestr) (const char* phaystack, const char* pneedle); |
647 | char* (*strtok_r)(char *ptr, const char *sep, char **end); | 652 | char* (*strtok_r)(char *ptr, const char *sep, char **end); |
653 | char* (*output_dyn_value)(char *buf, int buf_size, int value, | ||
654 | const unsigned char * const *units, | ||
655 | unsigned int unit_count, bool binary_scale); | ||
648 | /* unicode stuff */ | 656 | /* unicode stuff */ |
649 | const unsigned char* (*utf8decode)(const unsigned char *utf8, unsigned short *ucs); | 657 | const unsigned char* (*utf8decode)(const unsigned char *utf8, unsigned short *ucs); |
650 | unsigned char* (*iso_decode)(const unsigned char *iso, unsigned char *utf8, int cp, int count); | 658 | unsigned char* (*iso_decode)(const unsigned char *iso, unsigned char *utf8, int cp, int count); |
@@ -768,7 +776,7 @@ struct plugin_api { | |||
768 | void *buffer, long length); | 776 | void *buffer, long length); |
769 | bool (*tagcache_search_add_filter)(struct tagcache_search *tcs, | 777 | bool (*tagcache_search_add_filter)(struct tagcache_search *tcs, |
770 | int tag, int seek); | 778 | int tag, int seek); |
771 | bool (*tagcache_get_next)(struct tagcache_search *tcs); | 779 | bool (*tagcache_get_next)(struct tagcache_search *tcs, char *buf, long size); |
772 | bool (*tagcache_retrieve)(struct tagcache_search *tcs, int idxid, | 780 | bool (*tagcache_retrieve)(struct tagcache_search *tcs, int idxid, |
773 | int tag, char *buf, long size); | 781 | int tag, char *buf, long size); |
774 | void (*tagcache_search_finish)(struct tagcache_search *tcs); | 782 | void (*tagcache_search_finish)(struct tagcache_search *tcs); |
@@ -790,6 +798,9 @@ struct plugin_api { | |||
790 | 798 | ||
791 | /* playback control */ | 799 | /* playback control */ |
792 | struct playlist_info* (*playlist_get_current)(void); | 800 | struct playlist_info* (*playlist_get_current)(void); |
801 | int (*playlist_get_resume_info)(int *resume_index); | ||
802 | int (*playlist_get_track_info)(struct playlist_info* playlist, int index, | ||
803 | struct playlist_track_info* info); | ||
793 | int (*playlist_amount)(void); | 804 | int (*playlist_amount)(void); |
794 | int (*playlist_resume)(void); | 805 | int (*playlist_resume)(void); |
795 | void (*playlist_resume_track)(int start_index, unsigned int crc, | 806 | void (*playlist_resume_track)(int start_index, unsigned int crc, |
@@ -896,7 +907,8 @@ struct plugin_api { | |||
896 | #if CONFIG_RTC | 907 | #if CONFIG_RTC |
897 | time_t (*mktime)(struct tm *t); | 908 | time_t (*mktime)(struct tm *t); |
898 | #endif | 909 | #endif |
899 | 910 | const char* (*format_time_auto)(char *buffer, int buf_len, long value, | |
911 | int unit_idx, bool supress_unit); | ||
900 | #if defined(DEBUG) || defined(SIMULATOR) | 912 | #if defined(DEBUG) || defined(SIMULATOR) |
901 | void (*debugf)(const char *fmt, ...) ATTRIBUTE_PRINTF(1, 2); | 913 | void (*debugf)(const char *fmt, ...) ATTRIBUTE_PRINTF(1, 2); |
902 | #endif | 914 | #endif |
@@ -958,17 +970,6 @@ struct plugin_api { | |||
958 | /* new stuff at the end, sort into place next time | 970 | /* new stuff at the end, sort into place next time |
959 | the API gets incompatible */ | 971 | the API gets incompatible */ |
960 | 972 | ||
961 | const char* (*format_time_auto)(char *buffer, int buf_len, long value, | ||
962 | int unit_idx, bool supress_unit); | ||
963 | char* (*output_dyn_value)(char *buf, int buf_size, int value, | ||
964 | const unsigned char * const *units, | ||
965 | unsigned int unit_count, bool binary_scale); | ||
966 | int (*playlist_get_resume_info)(int *resume_index); | ||
967 | int (*playlist_get_track_info)(struct playlist_info* playlist, int index, | ||
968 | struct playlist_track_info* info); | ||
969 | bool (*list_do_action)(int context, int timeout, | ||
970 | struct gui_synclist *lists, int *action); | ||
971 | int (*talk_idarray)(const long *idarray, bool enqueue); | ||
972 | }; | 973 | }; |
973 | 974 | ||
974 | /* plugin header */ | 975 | /* plugin header */ |
diff --git a/apps/plugins/pictureflow/pictureflow.c b/apps/plugins/pictureflow/pictureflow.c index 1c380c7f28..87ad1a403f 100644 --- a/apps/plugins/pictureflow/pictureflow.c +++ b/apps/plugins/pictureflow/pictureflow.c | |||
@@ -1141,6 +1141,8 @@ static void write_artist_entry(struct tagcache_search *tcs, | |||
1141 | static int get_tcs_search_res(int type, struct tagcache_search *tcs, | 1141 | static int get_tcs_search_res(int type, struct tagcache_search *tcs, |
1142 | void **buf, size_t *bufsz) | 1142 | void **buf, size_t *bufsz) |
1143 | { | 1143 | { |
1144 | char tcs_buf[TAGCACHE_BUFSZ]; | ||
1145 | const long tcs_bufsz = sizeof(tcs_buf); | ||
1144 | int ret = SUCCESS; | 1146 | int ret = SUCCESS; |
1145 | unsigned int l, name_idx = 0; | 1147 | unsigned int l, name_idx = 0; |
1146 | void (*writefn)(struct tagcache_search *, int, unsigned int); | 1148 | void (*writefn)(struct tagcache_search *, int, unsigned int); |
@@ -1156,7 +1158,7 @@ static int get_tcs_search_res(int type, struct tagcache_search *tcs, | |||
1156 | data_size = sizeof(struct album_data); | 1158 | data_size = sizeof(struct album_data); |
1157 | } | 1159 | } |
1158 | 1160 | ||
1159 | while (rb->tagcache_get_next(tcs)) | 1161 | while (rb->tagcache_get_next(tcs, tcs_buf, tcs_bufsz)) |
1160 | { | 1162 | { |
1161 | if (rb->button_get(false) > BUTTON_NONE) | 1163 | if (rb->button_get(false) > BUTTON_NONE) |
1162 | { | 1164 | { |
@@ -1196,6 +1198,8 @@ static int get_tcs_search_res(int type, struct tagcache_search *tcs, | |||
1196 | static int create_album_untagged(struct tagcache_search *tcs, | 1198 | static int create_album_untagged(struct tagcache_search *tcs, |
1197 | void **buf, size_t *bufsz) | 1199 | void **buf, size_t *bufsz) |
1198 | { | 1200 | { |
1201 | static char tcs_buf[TAGCACHE_BUFSZ]; | ||
1202 | const long tcs_bufsz = sizeof(tcs_buf); | ||
1199 | int ret = SUCCESS; | 1203 | int ret = SUCCESS; |
1200 | int album_count = pf_idx.album_ct; /* store existing count */ | 1204 | int album_count = pf_idx.album_ct; /* store existing count */ |
1201 | int total_count = pf_idx.album_ct + pf_idx.artist_ct * 2; | 1205 | 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, | |||
1210 | { | 1214 | { |
1211 | rb->tagcache_search_add_filter(tcs, tag_album, pf_idx.album_untagged_seek); | 1215 | rb->tagcache_search_add_filter(tcs, tag_album, pf_idx.album_untagged_seek); |
1212 | 1216 | ||
1213 | while (rb->tagcache_get_next(tcs)) | 1217 | while (rb->tagcache_get_next(tcs, tcs_buf, tcs_bufsz)) |
1214 | { | 1218 | { |
1215 | if (rb->button_get(false) > BUTTON_NONE) { | 1219 | if (rb->button_get(false) > BUTTON_NONE) { |
1216 | if (confirm_quit()) | 1220 | if (confirm_quit()) |
@@ -1339,6 +1343,8 @@ static int build_artist_index(struct tagcache_search *tcs, | |||
1339 | 1343 | ||
1340 | static int assign_album_year(void) | 1344 | static int assign_album_year(void) |
1341 | { | 1345 | { |
1346 | char tcs_buf[TAGCACHE_BUFSZ]; | ||
1347 | const long tcs_bufsz = sizeof(tcs_buf); | ||
1342 | draw_progressbar(0, pf_idx.album_ct, "Assigning Album Year"); | 1348 | draw_progressbar(0, pf_idx.album_ct, "Assigning Album Year"); |
1343 | for (int album_idx = 0; album_idx < pf_idx.album_ct; album_idx++) | 1349 | for (int album_idx = 0; album_idx < pf_idx.album_ct; album_idx++) |
1344 | { | 1350 | { |
@@ -1367,7 +1373,7 @@ static int assign_album_year(void) | |||
1367 | rb->tagcache_search_add_filter(&tcs, tag_albumartist, | 1373 | rb->tagcache_search_add_filter(&tcs, tag_albumartist, |
1368 | pf_idx.album_index[album_idx].artist_seek); | 1374 | pf_idx.album_index[album_idx].artist_seek); |
1369 | 1375 | ||
1370 | while (rb->tagcache_get_next(&tcs)) { | 1376 | while (rb->tagcache_get_next(&tcs, tcs_buf, tcs_bufsz)) { |
1371 | int track_year = rb->tagcache_get_numeric(&tcs, tag_year); | 1377 | int track_year = rb->tagcache_get_numeric(&tcs, tag_year); |
1372 | if (track_year > album_year) | 1378 | if (track_year > album_year) |
1373 | album_year = track_year; | 1379 | album_year = track_year; |
@@ -1386,6 +1392,8 @@ static int assign_album_year(void) | |||
1386 | */ | 1392 | */ |
1387 | static int create_album_index(void) | 1393 | static int create_album_index(void) |
1388 | { | 1394 | { |
1395 | static char tcs_buf[TAGCACHE_BUFSZ]; | ||
1396 | const long tcs_bufsz = sizeof(tcs_buf); | ||
1389 | void *buf = pf_idx.buf; | 1397 | void *buf = pf_idx.buf; |
1390 | size_t buf_size = pf_idx.buf_sz; | 1398 | size_t buf_size = pf_idx.buf_sz; |
1391 | 1399 | ||
@@ -1463,7 +1471,7 @@ static int create_album_index(void) | |||
1463 | last = 0; | 1471 | last = 0; |
1464 | final = pf_idx.artist_ct; | 1472 | final = pf_idx.artist_ct; |
1465 | retry = 0; | 1473 | retry = 0; |
1466 | if (rb->tagcache_get_next(&tcs)) | 1474 | if (rb->tagcache_get_next(&tcs, tcs_buf, tcs_bufsz)) |
1467 | { | 1475 | { |
1468 | 1476 | ||
1469 | retry_artist_lookup: | 1477 | retry_artist_lookup: |
@@ -1981,6 +1989,8 @@ static int pf_tcs_retrieve_file_name(int fn_idx) | |||
1981 | */ | 1989 | */ |
1982 | static void create_track_index(const int slide_index) | 1990 | static void create_track_index(const int slide_index) |
1983 | { | 1991 | { |
1992 | char tcs_buf[TAGCACHE_BUFSZ]; | ||
1993 | const long tcs_bufsz = sizeof(tcs_buf); | ||
1984 | buf_ctx_lock(); | 1994 | buf_ctx_lock(); |
1985 | if ( slide_index == pf_tracks.cur_idx ) | 1995 | if ( slide_index == pf_tracks.cur_idx ) |
1986 | return; | 1996 | return; |
@@ -1998,7 +2008,7 @@ static void create_track_index(const int slide_index) | |||
1998 | int string_index = 0; | 2008 | int string_index = 0; |
1999 | pf_tracks.count = 0; | 2009 | pf_tracks.count = 0; |
2000 | 2010 | ||
2001 | while (rb->tagcache_get_next(&tcs)) | 2011 | while (rb->tagcache_get_next(&tcs, tcs_buf, tcs_bufsz)) |
2002 | { | 2012 | { |
2003 | int disc_num = rb->tagcache_get_numeric(&tcs, tag_discnumber); | 2013 | int disc_num = rb->tagcache_get_numeric(&tcs, tag_discnumber); |
2004 | int track_num = rb->tagcache_get_numeric(&tcs, tag_tracknumber); | 2014 | 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, | |||
2073 | int buflen) | 2083 | int buflen) |
2074 | { | 2084 | { |
2075 | bool ret; | 2085 | bool ret; |
2076 | 2086 | char tcs_buf[TAGCACHE_BUFSZ]; | |
2087 | const long tcs_bufsz = sizeof(tcs_buf); | ||
2077 | if (tcs.valid || !rb->tagcache_search(&tcs, tag_filename)) | 2088 | if (tcs.valid || !rb->tagcache_search(&tcs, tag_filename)) |
2078 | return false; | 2089 | return false; |
2079 | 2090 | ||
@@ -2084,7 +2095,7 @@ static bool get_albumart_for_index_from_db(const int slide_index, char *buf, | |||
2084 | rb->tagcache_search_add_filter(&tcs, tag_albumartist, | 2095 | rb->tagcache_search_add_filter(&tcs, tag_albumartist, |
2085 | pf_idx.album_index[slide_index].artist_seek); | 2096 | pf_idx.album_index[slide_index].artist_seek); |
2086 | 2097 | ||
2087 | ret = rb->tagcache_get_next(&tcs) && | 2098 | ret = rb->tagcache_get_next(&tcs, tcs_buf, tcs_bufsz) && |
2088 | retrieve_id3(&id3, tcs.result) && | 2099 | retrieve_id3(&id3, tcs.result) && |
2089 | search_albumart_files(&id3, ":", buf, buflen); | 2100 | search_albumart_files(&id3, ":", buf, buflen); |
2090 | 2101 | ||
diff --git a/apps/tagcache.c b/apps/tagcache.c index e60732fb65..170a066a36 100644 --- a/apps/tagcache.c +++ b/apps/tagcache.c | |||
@@ -102,9 +102,6 @@ | |||
102 | */ | 102 | */ |
103 | #define TAGCACHE_SUPPORT_FOREIGN_ENDIAN | 103 | #define TAGCACHE_SUPPORT_FOREIGN_ENDIAN |
104 | 104 | ||
105 | /* Maximum length of a single tag. */ | ||
106 | #define TAG_MAXLEN (MAX_PATH*2) | ||
107 | |||
108 | /* Allow a little drift to the filename ordering (should not be too high/low). */ | 105 | /* Allow a little drift to the filename ordering (should not be too high/low). */ |
109 | #define POS_HISTORY_COUNT 4 | 106 | #define POS_HISTORY_COUNT 4 |
110 | 107 | ||
@@ -169,9 +166,6 @@ static struct event_queue tagcache_queue SHAREDBSS_ATTR; | |||
169 | static long tagcache_stack[(DEFAULT_STACK_SIZE + 0x4000)/sizeof(long)]; | 166 | static long tagcache_stack[(DEFAULT_STACK_SIZE + 0x4000)/sizeof(long)]; |
170 | static const char tagcache_thread_name[] = "tagcache"; | 167 | static const char tagcache_thread_name[] = "tagcache"; |
171 | #endif | 168 | #endif |
172 | /* buffer size for all the (stack allocated & static) buffers handling tc data */ | ||
173 | #define TAGCACHE_BUFSZ (TAG_MAXLEN+32) | ||
174 | |||
175 | 169 | ||
176 | /* Previous path when scanning directory tree recursively. */ | 170 | /* Previous path when scanning directory tree recursively. */ |
177 | static char curpath[TAGCACHE_BUFSZ]; | 171 | static char curpath[TAGCACHE_BUFSZ]; |
@@ -1849,11 +1843,8 @@ bool tagcache_search_add_clause(struct tagcache_search *tcs, | |||
1849 | return true; | 1843 | return true; |
1850 | } | 1844 | } |
1851 | 1845 | ||
1852 | static bool get_next(struct tagcache_search *tcs, bool is_numeric) | 1846 | static bool get_next(struct tagcache_search *tcs, bool is_numeric, char *buf, long bufsz) |
1853 | { | 1847 | { |
1854 | /* WARNING pointers into buf are used in outside functions */ | ||
1855 | static char buf[TAGCACHE_BUFSZ]; | ||
1856 | const int bufsz = sizeof(buf); | ||
1857 | struct tagfile_entry entry; | 1848 | struct tagfile_entry entry; |
1858 | #if defined(HAVE_TC_RAMCACHE) && defined(HAVE_DIRCACHE) | 1849 | #if defined(HAVE_TC_RAMCACHE) && defined(HAVE_DIRCACHE) |
1859 | long flag = 0; | 1850 | long flag = 0; |
@@ -2001,12 +1992,12 @@ static bool get_next(struct tagcache_search *tcs, bool is_numeric) | |||
2001 | return true; | 1992 | return true; |
2002 | } | 1993 | } |
2003 | 1994 | ||
2004 | bool tagcache_get_next(struct tagcache_search *tcs) | 1995 | bool tagcache_get_next(struct tagcache_search *tcs, char *buf, long size) |
2005 | { | 1996 | { |
2006 | if (tcs->valid && tagcache_is_usable()) | 1997 | if (tcs->valid && tagcache_is_usable()) |
2007 | { | 1998 | { |
2008 | bool is_numeric = TAGCACHE_IS_NUMERIC(tcs->type); | 1999 | bool is_numeric = TAGCACHE_IS_NUMERIC(tcs->type); |
2009 | while (get_next(tcs, is_numeric)) | 2000 | while (get_next(tcs, is_numeric, buf, size)) |
2010 | { | 2001 | { |
2011 | if (tcs->result_len > 1) | 2002 | if (tcs->result_len > 1) |
2012 | return true; | 2003 | return true; |
@@ -3971,8 +3962,6 @@ static bool delete_entry(long idx_id) | |||
3971 | int tag, i; | 3962 | int tag, i; |
3972 | struct index_entry idx, myidx; | 3963 | struct index_entry idx, myidx; |
3973 | struct master_header myhdr; | 3964 | struct master_header myhdr; |
3974 | char buf[TAGCACHE_BUFSZ]; | ||
3975 | const int bufsz = sizeof(buf); | ||
3976 | int in_use[TAG_COUNT]; | 3965 | int in_use[TAG_COUNT]; |
3977 | 3966 | ||
3978 | logf("delete_entry(): %ld", idx_id); | 3967 | logf("delete_entry(): %ld", idx_id); |
@@ -4081,7 +4070,8 @@ static bool delete_entry(long idx_id) | |||
4081 | /* Skip the header block */ | 4070 | /* Skip the header block */ |
4082 | lseek(fd, myidx.tag_seek[tag], SEEK_SET); | 4071 | lseek(fd, myidx.tag_seek[tag], SEEK_SET); |
4083 | 4072 | ||
4084 | switch (read_tagfile_entry_and_tag(fd, &tfe, buf, bufsz)) | 4073 | switch (read_tagfile_entry_and_tag(fd, &tfe, |
4074 | build_idx_buf, build_idx_bufsz)) | ||
4085 | { | 4075 | { |
4086 | case e_SUCCESS_LEN_ZERO: | 4076 | case e_SUCCESS_LEN_ZERO: |
4087 | logf("deleted_entry(): SUCCESS"); | 4077 | logf("deleted_entry(): SUCCESS"); |
@@ -4099,7 +4089,8 @@ static bool delete_entry(long idx_id) | |||
4099 | goto cleanup; | 4089 | goto cleanup; |
4100 | } | 4090 | } |
4101 | 4091 | ||
4102 | myidx.tag_seek[tag] = crc_32(buf, strlen(buf), 0xffffffff); | 4092 | myidx.tag_seek[tag] = crc_32(build_idx_buf, |
4093 | strlen(build_idx_buf), 0xffffffff); | ||
4103 | } | 4094 | } |
4104 | 4095 | ||
4105 | if (in_use[tag]) | 4096 | if (in_use[tag]) |
diff --git a/apps/tagcache.h b/apps/tagcache.h index 3b4df999b9..9cf796fafd 100644 --- a/apps/tagcache.h +++ b/apps/tagcache.h | |||
@@ -53,6 +53,10 @@ enum tag_type { tag_artist = 0, tag_album, tag_genre, tag_title, | |||
53 | 53 | ||
54 | /* Tag to be used on untagged files. */ | 54 | /* Tag to be used on untagged files. */ |
55 | #define UNTAGGED "<Untagged>" | 55 | #define UNTAGGED "<Untagged>" |
56 | /* Maximum length of a single tag. */ | ||
57 | #define TAG_MAXLEN (MAX_PATH*2) | ||
58 | /* buffer size for all the (stack allocated & static) buffers handling tc data */ | ||
59 | #define TAGCACHE_BUFSZ (TAG_MAXLEN+32) | ||
56 | 60 | ||
57 | /* Numeric tags (we can use these tags with conditional clauses). */ | 61 | /* Numeric tags (we can use these tags with conditional clauses). */ |
58 | #define TAGCACHE_NUMERIC_TAGS ((1LU << tag_year) | (1LU << tag_discnumber) | \ | 62 | #define TAGCACHE_NUMERIC_TAGS ((1LU << tag_year) | (1LU << tag_discnumber) | \ |
@@ -172,7 +176,7 @@ bool tagcache_search_add_filter(struct tagcache_search *tcs, | |||
172 | int tag, int seek); | 176 | int tag, int seek); |
173 | bool tagcache_search_add_clause(struct tagcache_search *tcs, | 177 | bool tagcache_search_add_clause(struct tagcache_search *tcs, |
174 | struct tagcache_search_clause *clause); | 178 | struct tagcache_search_clause *clause); |
175 | bool tagcache_get_next(struct tagcache_search *tcs); | 179 | bool tagcache_get_next(struct tagcache_search *tcs, char *buf, long size); |
176 | bool tagcache_retrieve(struct tagcache_search *tcs, int idxid, | 180 | bool tagcache_retrieve(struct tagcache_search *tcs, int idxid, |
177 | int tag, char *buf, long size); | 181 | int tag, char *buf, long size); |
178 | void tagcache_search_finish(struct tagcache_search *tcs); | 182 | void tagcache_search_finish(struct tagcache_search *tcs); |
diff --git a/apps/tagtree.c b/apps/tagtree.c index 78bf6bf255..542b0bb120 100644 --- a/apps/tagtree.c +++ b/apps/tagtree.c | |||
@@ -1448,6 +1448,8 @@ static void tcs_get_basename(struct tagcache_search *tcs, bool is_basename) | |||
1448 | 1448 | ||
1449 | static int retrieve_entries(struct tree_context *c, int offset, bool init) | 1449 | static int retrieve_entries(struct tree_context *c, int offset, bool init) |
1450 | { | 1450 | { |
1451 | char tcs_buf[TAGCACHE_BUFSZ]; | ||
1452 | const long tcs_bufsz = sizeof(tcs_buf); | ||
1451 | struct tagcache_search tcs; | 1453 | struct tagcache_search tcs; |
1452 | struct display_format *fmt; | 1454 | struct display_format *fmt; |
1453 | int i; | 1455 | int i; |
@@ -1584,7 +1586,7 @@ static int retrieve_entries(struct tree_context *c, int offset, bool init) | |||
1584 | total_count += 2; | 1586 | total_count += 2; |
1585 | } | 1587 | } |
1586 | 1588 | ||
1587 | while (tagcache_get_next(&tcs)) | 1589 | while (tagcache_get_next(&tcs, tcs_buf, tcs_bufsz)) |
1588 | { | 1590 | { |
1589 | if (total_count++ < offset) | 1591 | if (total_count++ < offset) |
1590 | continue; | 1592 | continue; |
@@ -1729,7 +1731,7 @@ entry_skip_formatter: | |||
1729 | return current_entry_count; | 1731 | return current_entry_count; |
1730 | } | 1732 | } |
1731 | 1733 | ||
1732 | while (tagcache_get_next(&tcs)) | 1734 | while (tagcache_get_next(&tcs, tcs_buf, tcs_bufsz)) |
1733 | { | 1735 | { |
1734 | if (!show_search_progress(false, total_count)) | 1736 | if (!show_search_progress(false, total_count)) |
1735 | break; | 1737 | break; |