splash_progress add delay function
I figure this is a better way to allow a delay before showing the progress meter Change-Id: I909902a52619023b0b87635d2eb94ed00cb4bcec
This commit is contained in:
parent
c607bfac6f
commit
f9ea1fc79d
4 changed files with 28 additions and 23 deletions
|
@ -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 */
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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'))
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in a new issue