Show progress while committing tagcache.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@9637 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
44d9576ff5
commit
1b18dd0f17
3 changed files with 61 additions and 20 deletions
31
apps/main.c
31
apps/main.c
|
@ -144,15 +144,32 @@ void init_tagcache(void)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_LCD_BITMAP
|
#ifdef HAVE_LCD_BITMAP
|
||||||
int font_w, font_h;
|
int font_w, font_h;
|
||||||
|
|
||||||
/* Print "Scanning disk..." to the display. */
|
|
||||||
lcd_getstringsize("A", &font_w, &font_h);
|
|
||||||
lcd_putsxy((LCD_WIDTH/2) - ((strlen(str(LANG_TAGCACHE_INIT))*font_w)/2),
|
|
||||||
LCD_HEIGHT-font_h*3, str(LANG_TAGCACHE_INIT));
|
|
||||||
lcd_update();
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
tagcache_init();
|
tagcache_init();
|
||||||
|
|
||||||
|
while (!tagcache_is_initialized())
|
||||||
|
{
|
||||||
|
#ifdef HAVE_LCD_BITMAP
|
||||||
|
char buf[64];
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
ret = tagcache_get_commit_step();
|
||||||
|
if (ret > 0)
|
||||||
|
{
|
||||||
|
snprintf(buf, sizeof buf, "%s [%d/%d]",
|
||||||
|
str(LANG_TAGCACHE_INIT), ret, TAG_COUNT);
|
||||||
|
|
||||||
|
/* Print "Scanning disk..." to the display. */
|
||||||
|
lcd_getstringsize("A", &font_w, &font_h);
|
||||||
|
lcd_putsxy((LCD_WIDTH/2) - ((strlen(buf)*font_w)/2),
|
||||||
|
LCD_HEIGHT-font_h*3, buf);
|
||||||
|
lcd_update();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
sleep(HZ/4);
|
||||||
|
}
|
||||||
|
|
||||||
tagtree_init();
|
tagtree_init();
|
||||||
|
|
||||||
#ifdef HAVE_LCD_BITMAP
|
#ifdef HAVE_LCD_BITMAP
|
||||||
|
@ -377,9 +394,9 @@ void init(void)
|
||||||
|
|
||||||
|
|
||||||
init_dircache();
|
init_dircache();
|
||||||
init_tagcache();
|
|
||||||
gui_sync_wps_init();
|
gui_sync_wps_init();
|
||||||
settings_apply();
|
settings_apply();
|
||||||
|
init_tagcache();
|
||||||
|
|
||||||
status_init();
|
status_init();
|
||||||
playlist_init();
|
playlist_init();
|
||||||
|
|
|
@ -59,6 +59,12 @@ static const int unique_tags[] = { tag_artist, tag_album, tag_genre, tag_compose
|
||||||
/* Numeric tags (we can use these tags with conditional clauses). */
|
/* Numeric tags (we can use these tags with conditional clauses). */
|
||||||
static const int numeric_tags[] = { tag_year, tag_tracknumber, tag_length, tag_bitrate };
|
static const int numeric_tags[] = { tag_year, tag_tracknumber, tag_length, tag_bitrate };
|
||||||
|
|
||||||
|
/* When thread initialization and memory allocation has been made. */
|
||||||
|
static bool tagcache_init_done = false;
|
||||||
|
|
||||||
|
/* Progress indicator while committing the cache. */
|
||||||
|
static int init_step;
|
||||||
|
|
||||||
/* Queue commands. */
|
/* Queue commands. */
|
||||||
#define Q_STOP_SCAN 0
|
#define Q_STOP_SCAN 0
|
||||||
#define Q_START_SCAN 1
|
#define Q_START_SCAN 1
|
||||||
|
@ -1780,8 +1786,10 @@ static bool commit(void)
|
||||||
logf("commit %d entries...", header.entry_count);
|
logf("commit %d entries...", header.entry_count);
|
||||||
|
|
||||||
/* Now create the index files. */
|
/* Now create the index files. */
|
||||||
|
init_step = 0;
|
||||||
for (i = 0; i < TAG_COUNT; i++)
|
for (i = 0; i < TAG_COUNT; i++)
|
||||||
{
|
{
|
||||||
|
init_step++;
|
||||||
if (tagcache_is_numeric_tag(i))
|
if (tagcache_is_numeric_tag(i))
|
||||||
{
|
{
|
||||||
build_numeric_index(i, &header, tmpfd);
|
build_numeric_index(i, &header, tmpfd);
|
||||||
|
@ -1791,11 +1799,13 @@ static bool commit(void)
|
||||||
{
|
{
|
||||||
logf("tagcache failed init");
|
logf("tagcache failed init");
|
||||||
remove_files();
|
remove_files();
|
||||||
|
init_step = 0;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
close(tmpfd);
|
close(tmpfd);
|
||||||
|
init_step = 0;
|
||||||
|
|
||||||
/* Update the master index headers. */
|
/* Update the master index headers. */
|
||||||
masterfd = open(TAGCACHE_FILE_MASTER, O_RDWR);
|
masterfd = open(TAGCACHE_FILE_MASTER, O_RDWR);
|
||||||
|
@ -2221,6 +2231,20 @@ static void tagcache_thread(void)
|
||||||
struct event ev;
|
struct event ev;
|
||||||
bool check_done = false;
|
bool check_done = false;
|
||||||
|
|
||||||
|
/* If the previous cache build/update was interrupted, commit
|
||||||
|
* the changes first. */
|
||||||
|
cpu_boost(true);
|
||||||
|
allocate_tempbuf();
|
||||||
|
commit();
|
||||||
|
free_tempbuf();
|
||||||
|
cpu_boost(false);
|
||||||
|
|
||||||
|
#ifdef HAVE_TC_RAMCACHE
|
||||||
|
/* Allocate space for the tagcache if found on disk. */
|
||||||
|
allocate_tagcache();
|
||||||
|
#endif
|
||||||
|
tagcache_init_done = true;
|
||||||
|
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
queue_wait_w_tmo(&tagcache_queue, &ev, HZ);
|
queue_wait_w_tmo(&tagcache_queue, &ev, HZ);
|
||||||
|
@ -2316,22 +2340,20 @@ bool tagcache_is_ramcache(void)
|
||||||
|
|
||||||
void tagcache_init(void)
|
void tagcache_init(void)
|
||||||
{
|
{
|
||||||
/* If the previous cache build/update was interrupted, commit
|
tagcache_init_done = false;
|
||||||
* the changes first. */
|
init_step = 0;
|
||||||
cpu_boost(true);
|
|
||||||
allocate_tempbuf();
|
|
||||||
commit();
|
|
||||||
free_tempbuf();
|
|
||||||
cpu_boost(false);
|
|
||||||
|
|
||||||
#ifdef HAVE_TC_RAMCACHE
|
|
||||||
/* Allocate space for the tagcache if found on disk. */
|
|
||||||
allocate_tagcache();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
queue_init(&tagcache_queue);
|
queue_init(&tagcache_queue);
|
||||||
create_thread(tagcache_thread, tagcache_stack,
|
create_thread(tagcache_thread, tagcache_stack,
|
||||||
sizeof(tagcache_stack), tagcache_thread_name);
|
sizeof(tagcache_stack), tagcache_thread_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool tagcache_is_initialized(void)
|
||||||
|
{
|
||||||
|
return tagcache_init_done;
|
||||||
|
}
|
||||||
|
|
||||||
|
int tagcache_get_commit_step(void)
|
||||||
|
{
|
||||||
|
return init_step;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -100,6 +100,8 @@ bool tagcache_is_ramcache(void);
|
||||||
bool tagcache_fill_tags(struct mp3entry *id3, const char *filename);
|
bool tagcache_fill_tags(struct mp3entry *id3, const char *filename);
|
||||||
#endif
|
#endif
|
||||||
void tagcache_init(void);
|
void tagcache_init(void);
|
||||||
|
bool tagcache_is_initialized(void);
|
||||||
|
int tagcache_get_commit_step(void);
|
||||||
void tagcache_start_scan(void);
|
void tagcache_start_scan(void);
|
||||||
void tagcache_stop_scan(void);
|
void tagcache_stop_scan(void);
|
||||||
bool tagcache_force_update(void);
|
bool tagcache_force_update(void);
|
||||||
|
|
Loading…
Reference in a new issue