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 @@ #include "strtok_r.h" #include "scrollbar.h" +static long progress_next_tick = 0; + #define MAXLINES (LCD_HEIGHT/6) #define MAXBUFFER 512 #define RECT_SPACING 2 @@ -194,21 +196,26 @@ void splash(int ticks, const char *str) splashf(ticks, "%s", P2STR((const unsigned char*)str)); } +/* set delay before progress meter is shown */ +void splash_progress_set_delay(long delay_ticks) +{ + progress_next_tick = current_tick + delay_ticks; +} + /* splash a progress meter */ void splash_progress(int current, int total, const char *fmt, ...) { va_list ap; int vp_flag = VP_FLAG_VP_DIRTY; /* progress update tick */ - static long next_tick = 0; long now = current_tick; if (current < total) { - if(TIME_BEFORE(now, next_tick)) + if(TIME_BEFORE(now, progress_next_tick)) return; /* limit to 20fps */ - next_tick = now + HZ/20; + progress_next_tick = now + HZ/20; vp_flag = 0; /* don't mark vp dirty to prevent flashing */ } 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); */ extern void splash(int ticks, const char *str); +/* set a delay before displaying the progress meter the first time */ +extern void splash_progress_set_delay(long delay_ticks); /* * Puts a splash message centered on all the screens with a progressbar * - 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) char *str1 = NULL; char *str2 = NULL; char *str3 = NULL; - unsigned long last_tick = current_tick + HZ / 2; /* wait 1/2 sec before progress */ + unsigned long last_tick = current_tick; + splash_progress_set_delay(HZ / 2); /* wait 1/2 sec before progress */ bool useraborted = false; for(count=0; countfilesindir; for (i = 0; i < n; i++) { - if (TIME_AFTER(current_tick, last_tick - 1)) + + splash_progress(i, n, "%s (%s)", str(LANG_WAIT), str(LANG_OFF_ABORT)); + if (TIME_AFTER(current_tick, last_tick + HZ/4)) { - splash_progress(i, n, "%s (%s)", str(LANG_WAIT), str(LANG_OFF_ABORT)); - if (TIME_AFTER(current_tick, last_tick + HZ/10)) - { - if (action_userabort(TIMEOUT_NOBLOCK)) - break; - last_tick = current_tick; - } + if (action_userabort(TIMEOUT_NOBLOCK)) + break; + last_tick = current_tick; } if (!tagcache_retrieve(&tcs, tagtree_get_entry(c, i)->extraseek,