summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
Diffstat (limited to 'apps')
-rw-r--r--apps/gui/splash.c13
-rw-r--r--apps/gui/splash.h2
-rw-r--r--apps/playlist.c20
-rw-r--r--apps/tagtree.c16
4 files changed, 28 insertions, 23 deletions
diff --git a/apps/gui/splash.c b/apps/gui/splash.c
index 5bb8514d30..efb4b1cda2 100644
--- a/apps/gui/splash.c
+++ b/apps/gui/splash.c
@@ -32,6 +32,8 @@
32#include "strtok_r.h" 32#include "strtok_r.h"
33#include "scrollbar.h" 33#include "scrollbar.h"
34 34
35static long progress_next_tick = 0;
36
35#define MAXLINES (LCD_HEIGHT/6) 37#define MAXLINES (LCD_HEIGHT/6)
36#define MAXBUFFER 512 38#define MAXBUFFER 512
37#define RECT_SPACING 2 39#define RECT_SPACING 2
@@ -194,21 +196,26 @@ void splash(int ticks, const char *str)
194 splashf(ticks, "%s", P2STR((const unsigned char*)str)); 196 splashf(ticks, "%s", P2STR((const unsigned char*)str));
195} 197}
196 198
199/* set delay before progress meter is shown */
200void splash_progress_set_delay(long delay_ticks)
201{
202 progress_next_tick = current_tick + delay_ticks;
203}
204
197/* splash a progress meter */ 205/* splash a progress meter */
198void splash_progress(int current, int total, const char *fmt, ...) 206void splash_progress(int current, int total, const char *fmt, ...)
199{ 207{
200 va_list ap; 208 va_list ap;
201 int vp_flag = VP_FLAG_VP_DIRTY; 209 int vp_flag = VP_FLAG_VP_DIRTY;
202 /* progress update tick */ 210 /* progress update tick */
203 static long next_tick = 0;
204 long now = current_tick; 211 long now = current_tick;
205 212
206 if (current < total) 213 if (current < total)
207 { 214 {
208 if(TIME_BEFORE(now, next_tick)) 215 if(TIME_BEFORE(now, progress_next_tick))
209 return; 216 return;
210 /* limit to 20fps */ 217 /* limit to 20fps */
211 next_tick = now + HZ/20; 218 progress_next_tick = now + HZ/20;
212 vp_flag = 0; /* don't mark vp dirty to prevent flashing */ 219 vp_flag = 0; /* don't mark vp dirty to prevent flashing */
213 } 220 }
214 221
diff --git a/apps/gui/splash.h b/apps/gui/splash.h
index 4002af5296..f7ff44e00b 100644
--- a/apps/gui/splash.h
+++ b/apps/gui/splash.h
@@ -40,6 +40,8 @@ extern void splashf(int ticks, const char *fmt, ...) ATTRIBUTE_PRINTF(2, 3);
40 */ 40 */
41extern void splash(int ticks, const char *str); 41extern void splash(int ticks, const char *str);
42 42
43/* set a delay before displaying the progress meter the first time */
44extern void splash_progress_set_delay(long delay_ticks);
43/* 45/*
44 * Puts a splash message centered on all the screens with a progressbar 46 * Puts a splash message centered on all the screens with a progressbar
45 * - current : current progress increment 47 * - current : current progress increment
diff --git a/apps/playlist.c b/apps/playlist.c
index e54918f4f7..888b53d282 100644
--- a/apps/playlist.c
+++ b/apps/playlist.c
@@ -2196,25 +2196,23 @@ int playlist_resume(void)
2196 char *str1 = NULL; 2196 char *str1 = NULL;
2197 char *str2 = NULL; 2197 char *str2 = NULL;
2198 char *str3 = NULL; 2198 char *str3 = NULL;
2199 unsigned long last_tick = current_tick + HZ / 2; /* wait 1/2 sec before progress */ 2199 unsigned long last_tick = current_tick;
2200 splash_progress_set_delay(HZ / 2); /* wait 1/2 sec before progress */
2200 bool useraborted = false; 2201 bool useraborted = false;
2201 2202
2202 for(count=0; count<nread && !exit_loop && !useraborted; count++,p++) 2203 for(count=0; count<nread && !exit_loop && !useraborted; count++,p++)
2203 { 2204 {
2204 /* Show a splash while we are loading. */ 2205 /* Show a splash while we are loading. */
2205 if (TIME_AFTER(current_tick, last_tick - 1)) 2206 splash_progress((total_read + count), control_file_size,
2207 "%s (%s)", str(LANG_WAIT), str(LANG_OFF_ABORT));
2208 if (TIME_AFTER(current_tick, last_tick + HZ/4))
2206 { 2209 {
2207 splash_progress((total_read + count), control_file_size, 2210 if (action_userabort(TIMEOUT_NOBLOCK))
2208 "%s (%s)", str(LANG_WAIT), str(LANG_OFF_ABORT));
2209 if (TIME_AFTER(current_tick, last_tick + HZ/4))
2210 { 2211 {
2211 if (action_userabort(TIMEOUT_NOBLOCK)) 2212 useraborted = true;
2212 { 2213 break;
2213 useraborted = true;
2214 break;
2215 }
2216 last_tick = current_tick;
2217 } 2214 }
2215 last_tick = current_tick;
2218 } 2216 }
2219 /* Are we on a new line? */ 2217 /* Are we on a new line? */
2220 if((*p == '\n') || (*p == '\r')) 2218 if((*p == '\n') || (*p == '\r'))
diff --git a/apps/tagtree.c b/apps/tagtree.c
index d354d7c2a1..39bc0ab37c 100644
--- a/apps/tagtree.c
+++ b/apps/tagtree.c
@@ -2063,19 +2063,17 @@ static bool insert_all_playlist(struct tree_context *c, int position, bool queue
2063 } 2063 }
2064 2064
2065 last_tick = current_tick + HZ/2; /* Show splash after 0.5 seconds have passed */ 2065 last_tick = current_tick + HZ/2; /* Show splash after 0.5 seconds have passed */
2066 2066 splash_progress_set_delay(HZ / 2); /* wait 1/2 sec before progress */
2067 n = c->filesindir; 2067 n = c->filesindir;
2068 for (i = 0; i < n; i++) 2068 for (i = 0; i < n; i++)
2069 { 2069 {
2070 if (TIME_AFTER(current_tick, last_tick - 1)) 2070
2071 splash_progress(i, n, "%s (%s)", str(LANG_WAIT), str(LANG_OFF_ABORT));
2072 if (TIME_AFTER(current_tick, last_tick + HZ/4))
2071 { 2073 {
2072 splash_progress(i, n, "%s (%s)", str(LANG_WAIT), str(LANG_OFF_ABORT)); 2074 if (action_userabort(TIMEOUT_NOBLOCK))
2073 if (TIME_AFTER(current_tick, last_tick + HZ/10)) 2075 break;
2074 { 2076 last_tick = current_tick;
2075 if (action_userabort(TIMEOUT_NOBLOCK))
2076 break;
2077 last_tick = current_tick;
2078 }
2079 } 2077 }
2080 2078
2081 if (!tagcache_retrieve(&tcs, tagtree_get_entry(c, i)->extraseek, 2079 if (!tagcache_retrieve(&tcs, tagtree_get_entry(c, i)->extraseek,