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 "strtok_r.h"
|
||||||
#include "scrollbar.h"
|
#include "scrollbar.h"
|
||||||
|
|
||||||
|
static long progress_next_tick = 0;
|
||||||
|
|
||||||
#define MAXLINES (LCD_HEIGHT/6)
|
#define MAXLINES (LCD_HEIGHT/6)
|
||||||
#define MAXBUFFER 512
|
#define MAXBUFFER 512
|
||||||
#define RECT_SPACING 2
|
#define RECT_SPACING 2
|
||||||
|
@ -194,21 +196,26 @@ void splash(int ticks, const char *str)
|
||||||
splashf(ticks, "%s", P2STR((const unsigned 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 */
|
/* splash a progress meter */
|
||||||
void splash_progress(int current, int total, const char *fmt, ...)
|
void splash_progress(int current, int total, const char *fmt, ...)
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
int vp_flag = VP_FLAG_VP_DIRTY;
|
int vp_flag = VP_FLAG_VP_DIRTY;
|
||||||
/* progress update tick */
|
/* progress update tick */
|
||||||
static long next_tick = 0;
|
|
||||||
long now = current_tick;
|
long now = current_tick;
|
||||||
|
|
||||||
if (current < total)
|
if (current < total)
|
||||||
{
|
{
|
||||||
if(TIME_BEFORE(now, next_tick))
|
if(TIME_BEFORE(now, progress_next_tick))
|
||||||
return;
|
return;
|
||||||
/* limit to 20fps */
|
/* 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 */
|
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);
|
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
|
* Puts a splash message centered on all the screens with a progressbar
|
||||||
* - current : current progress increment
|
* - current : current progress increment
|
||||||
|
|
|
@ -2196,14 +2196,13 @@ int playlist_resume(void)
|
||||||
char *str1 = NULL;
|
char *str1 = NULL;
|
||||||
char *str2 = NULL;
|
char *str2 = NULL;
|
||||||
char *str3 = 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;
|
bool useraborted = false;
|
||||||
|
|
||||||
for(count=0; count<nread && !exit_loop && !useraborted; count++,p++)
|
for(count=0; count<nread && !exit_loop && !useraborted; count++,p++)
|
||||||
{
|
{
|
||||||
/* Show a splash while we are loading. */
|
/* Show a splash while we are loading. */
|
||||||
if (TIME_AFTER(current_tick, last_tick - 1))
|
|
||||||
{
|
|
||||||
splash_progress((total_read + count), control_file_size,
|
splash_progress((total_read + count), control_file_size,
|
||||||
"%s (%s)", str(LANG_WAIT), str(LANG_OFF_ABORT));
|
"%s (%s)", str(LANG_WAIT), str(LANG_OFF_ABORT));
|
||||||
if (TIME_AFTER(current_tick, last_tick + HZ/4))
|
if (TIME_AFTER(current_tick, last_tick + HZ/4))
|
||||||
|
@ -2215,7 +2214,6 @@ int playlist_resume(void)
|
||||||
}
|
}
|
||||||
last_tick = current_tick;
|
last_tick = current_tick;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
/* Are we on a new line? */
|
/* Are we on a new line? */
|
||||||
if((*p == '\n') || (*p == '\r'))
|
if((*p == '\n') || (*p == '\r'))
|
||||||
{
|
{
|
||||||
|
|
|
@ -2063,20 +2063,18 @@ 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 */
|
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;
|
n = c->filesindir;
|
||||||
for (i = 0; i < n; i++)
|
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));
|
splash_progress(i, n, "%s (%s)", str(LANG_WAIT), str(LANG_OFF_ABORT));
|
||||||
if (TIME_AFTER(current_tick, last_tick + HZ/10))
|
if (TIME_AFTER(current_tick, last_tick + HZ/4))
|
||||||
{
|
{
|
||||||
if (action_userabort(TIMEOUT_NOBLOCK))
|
if (action_userabort(TIMEOUT_NOBLOCK))
|
||||||
break;
|
break;
|
||||||
last_tick = current_tick;
|
last_tick = current_tick;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (!tagcache_retrieve(&tcs, tagtree_get_entry(c, i)->extraseek,
|
if (!tagcache_retrieve(&tcs, tagtree_get_entry(c, i)->extraseek,
|
||||||
tcs.type, buf, sizeof buf))
|
tcs.type, buf, sizeof buf))
|
||||||
|
|
Loading…
Reference in a new issue