summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWilliam Wilgus <wilgus.william@gmail.com>2022-10-13 00:05:34 -0400
committerWilliam Wilgus <wilgus.william@gmail.com>2022-10-13 00:10:25 -0400
commitf9ea1fc79d6aaff9949a5b11ae011b4e04e0e9d9 (patch)
treeacef9a442d685e930b9d7435c72d634c841dc795
parentc607bfac6feb6bb915f3133a5c70ba871f5112ed (diff)
downloadrockbox-f9ea1fc79d.tar.gz
rockbox-f9ea1fc79d.zip
splash_progress add delay function
I figure this is a better way to allow a delay before showing the progress meter Change-Id: I909902a52619023b0b87635d2eb94ed00cb4bcec
-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 @@
#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; count<nread && !exit_loop && !useraborted; count++,p++)
{
/* Show a splash while we are loading. */
- if (TIME_AFTER(current_tick, last_tick - 1))
+ splash_progress((total_read + count), control_file_size,
+ "%s (%s)", str(LANG_WAIT), str(LANG_OFF_ABORT));
+ if (TIME_AFTER(current_tick, last_tick + HZ/4))
{
- splash_progress((total_read + count), control_file_size,
- "%s (%s)", str(LANG_WAIT), str(LANG_OFF_ABORT));
- if (TIME_AFTER(current_tick, last_tick + HZ/4))
+ if (action_userabort(TIMEOUT_NOBLOCK))
{
- if (action_userabort(TIMEOUT_NOBLOCK))
- {
- useraborted = true;
- break;
- }
- last_tick = current_tick;
+ useraborted = true;
+ break;
}
+ last_tick = current_tick;
}
/* Are we on a new line? */
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
}
last_tick = current_tick + HZ/2; /* Show splash after 0.5 seconds have passed */
-
+ splash_progress_set_delay(HZ / 2); /* wait 1/2 sec before progress */
n = c->filesindir;
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,