summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apps/misc.c12
-rw-r--r--apps/misc.h2
-rw-r--r--apps/playlist.c15
-rw-r--r--apps/tagtree.c8
4 files changed, 24 insertions, 13 deletions
diff --git a/apps/misc.c b/apps/misc.c
index d8caabd397..bd7aa9485b 100644
--- a/apps/misc.c
+++ b/apps/misc.c
@@ -200,7 +200,7 @@ bool warn_on_pl_erase(void)
200 return true; 200 return true;
201} 201}
202 202
203bool show_search_progress(bool init, int count) 203bool show_search_progress(bool init, int display_count, int current, int total)
204{ 204{
205 static int last_tick = 0; 205 static int last_tick = 0;
206 206
@@ -214,7 +214,15 @@ bool show_search_progress(bool init, int count)
214 /* Update progress every 1/10 of a second */ 214 /* Update progress every 1/10 of a second */
215 if (TIME_AFTER(current_tick, last_tick + HZ/10)) 215 if (TIME_AFTER(current_tick, last_tick + HZ/10))
216 { 216 {
217 splashf(0, str(LANG_PLAYLIST_SEARCH_MSG), count, str(LANG_OFF_ABORT)); 217 if (total != current)
218 {
219 splash_progress(current, total, str(LANG_PLAYLIST_SEARCH_MSG),
220 display_count, str(LANG_OFF_ABORT));
221 }
222 else
223 splashf(0, str(LANG_PLAYLIST_SEARCH_MSG),
224 display_count, str(LANG_OFF_ABORT));
225
218 if (action_userabort(TIMEOUT_NOBLOCK)) 226 if (action_userabort(TIMEOUT_NOBLOCK))
219 return false; 227 return false;
220 last_tick = current_tick; 228 last_tick = current_tick;
diff --git a/apps/misc.h b/apps/misc.h
index e5fb7a3d1f..3b7ce89d22 100644
--- a/apps/misc.h
+++ b/apps/misc.h
@@ -110,7 +110,7 @@ void talk_timedate(void);
110 * returns true if the playlist should be replaced */ 110 * returns true if the playlist should be replaced */
111bool warn_on_pl_erase(void); 111bool warn_on_pl_erase(void);
112 112
113bool show_search_progress(bool init, int count); 113bool show_search_progress(bool init, int count, int current, int total);
114 114
115/* Read (up to) a line of text from fd into buffer and return number of bytes 115/* Read (up to) a line of text from fd into buffer and return number of bytes
116 * read (which may be larger than the number of bytes stored in buffer). If 116 * read (which may be larger than the number of bytes stored in buffer). If
diff --git a/apps/playlist.c b/apps/playlist.c
index 70637b39a2..d23f3ec0d1 100644
--- a/apps/playlist.c
+++ b/apps/playlist.c
@@ -2519,6 +2519,7 @@ bool playlist_entries_iterate(const char *filename,
2519 bool ret = false; 2519 bool ret = false;
2520 int max; 2520 int max;
2521 char *dir; 2521 char *dir;
2522 off_t filesize;
2522 2523
2523 char temp_buf[MAX_PATH+1]; 2524 char temp_buf[MAX_PATH+1];
2524 char trackname[MAX_PATH+1]; 2525 char trackname[MAX_PATH+1];
@@ -2533,14 +2534,16 @@ bool playlist_entries_iterate(const char *filename,
2533 notify_access_error(); 2534 notify_access_error();
2534 goto out; 2535 goto out;
2535 } 2536 }
2536 2537 off_t start = lseek(fd, 0, SEEK_CUR);
2538 filesize = lseek(fd, 0, SEEK_END);
2539 lseek(fd, start, SEEK_SET);
2537 /* we need the directory name for formatting purposes */ 2540 /* we need the directory name for formatting purposes */
2538 size_t dirlen = path_dirname(filename, (const char **)&dir); 2541 size_t dirlen = path_dirname(filename, (const char **)&dir);
2539 //dir = strmemdupa(dir, dirlen); 2542 //dir = strmemdupa(dir, dirlen);
2540 2543
2541 2544
2542 if (action_cb) 2545 if (action_cb)
2543 show_search_progress(true, 0); 2546 show_search_progress(true, 0, 0, 0);
2544 2547
2545 while ((max = read_line(fd, temp_buf, sizeof(temp_buf))) > 0) 2548 while ((max = read_line(fd, temp_buf, sizeof(temp_buf))) > 0)
2546 { 2549 {
@@ -2561,17 +2564,17 @@ bool playlist_entries_iterate(const char *filename,
2561 2564
2562 /* we need to format so that relative paths are correctly 2565 /* we need to format so that relative paths are correctly
2563 handled */ 2566 handled */
2564 if (format_track_path(trackname, temp_buf, 2567 if ((max = format_track_path(trackname, temp_buf,
2565 sizeof(trackname), dir, dirlen) < 0) 2568 sizeof(trackname), dir, dirlen)) < 0)
2566 { 2569 {
2567 goto out; 2570 goto out;
2568 } 2571 }
2569 2572 start += max;
2570 if (action_cb) 2573 if (action_cb)
2571 { 2574 {
2572 if (!action_cb(trackname)) 2575 if (!action_cb(trackname))
2573 goto out; 2576 goto out;
2574 else if (!show_search_progress(false, i)) 2577 else if (!show_search_progress(false, i, start, filesize))
2575 break; 2578 break;
2576 } 2579 }
2577 else if (playlist_insert_context_add(pl_context, trackname) < 0) 2580 else if (playlist_insert_context_add(pl_context, trackname) < 0)
diff --git a/apps/tagtree.c b/apps/tagtree.c
index ea2a756a46..d2e27a3e58 100644
--- a/apps/tagtree.c
+++ b/apps/tagtree.c
@@ -1452,7 +1452,7 @@ static int retrieve_entries(struct tree_context *c, int offset, bool init)
1452#else 1452#else
1453 true 1453 true
1454#endif 1454#endif
1455 , 0); 1455 , 0, 0, 0);
1456 1456
1457 if (c->currtable == ALLSUBENTRIES) 1457 if (c->currtable == ALLSUBENTRIES)
1458 { 1458 {
@@ -1676,7 +1676,7 @@ entry_skip_formatter:
1676 1676
1677 if (init) 1677 if (init)
1678 { 1678 {
1679 if (!show_search_progress(false, total_count)) 1679 if (!show_search_progress(false, total_count, 0, 0))
1680 { /* user aborted */ 1680 { /* user aborted */
1681 tagcache_search_finish(&tcs); 1681 tagcache_search_finish(&tcs);
1682 tree_unlock_cache(c); 1682 tree_unlock_cache(c);
@@ -1710,7 +1710,7 @@ entry_skip_formatter:
1710 1710
1711 while (tagcache_get_next(&tcs, tcs_buf, tcs_bufsz)) 1711 while (tagcache_get_next(&tcs, tcs_buf, tcs_bufsz))
1712 { 1712 {
1713 if (!show_search_progress(false, total_count)) 1713 if (!show_search_progress(false, total_count, 0, 0))
1714 break; 1714 break;
1715 total_count++; 1715 total_count++;
1716 } 1716 }
@@ -2229,7 +2229,7 @@ static bool tagtree_insert_selection(int position, bool queue,
2229#else 2229#else
2230 true 2230 true
2231#endif 2231#endif
2232 , 0); 2232 , 0, 0, 0);
2233 2233
2234 newtable = tagtree_get_entry(tc, tc->selected_item)->newtable; 2234 newtable = tagtree_get_entry(tc, tc->selected_item)->newtable;
2235 2235