forked from len0rd/rockbox
Commit tagcache in background when possible (at least dircache enabled).
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@9686 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
caec58bc0f
commit
3b31346103
8 changed files with 165 additions and 47 deletions
|
|
@ -567,6 +567,7 @@ static int dircache_do_rebuild(void)
|
|||
audiobuf += (long)((dircache_size & ~0x03) + 0x04);
|
||||
audiobuf += DIRCACHE_RESERVE;
|
||||
allocated_size = dircache_size + DIRCACHE_RESERVE;
|
||||
reserve_used = 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
|
|
@ -612,27 +613,20 @@ static void dircache_thread(void)
|
|||
*/
|
||||
int dircache_build(int last_size)
|
||||
{
|
||||
if (dircache_initialized)
|
||||
if (dircache_initialized || thread_enabled)
|
||||
return -3;
|
||||
|
||||
while (thread_enabled)
|
||||
sleep(1);
|
||||
|
||||
logf("Building directory cache");
|
||||
if (dircache_size > 0)
|
||||
{
|
||||
allocated_size = dircache_size + (DIRCACHE_RESERVE-reserve_used);
|
||||
thread_enabled = true;
|
||||
queue_post(&dircache_queue, DIRCACHE_BUILD, 0);
|
||||
return 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
dircache_root = (struct dircache_entry *)(((long)audiobuf & ~0x03) + 0x04);
|
||||
dircache_size = 0;
|
||||
}
|
||||
|
||||
dircache_root = (struct dircache_entry *)(((long)audiobuf & ~0x03) + 0x04);
|
||||
|
||||
if (last_size > DIRCACHE_RESERVE && last_size < DIRCACHE_LIMIT)
|
||||
if (last_size > DIRCACHE_RESERVE && last_size < DIRCACHE_LIMIT )
|
||||
{
|
||||
allocated_size = last_size + DIRCACHE_RESERVE;
|
||||
|
||||
|
|
@ -649,6 +643,23 @@ int dircache_build(int last_size)
|
|||
return dircache_do_rebuild();
|
||||
}
|
||||
|
||||
/**
|
||||
* Steal the allocated dircache buffer and disable dircache.
|
||||
*/
|
||||
void* dircache_steal_buffer(long *size)
|
||||
{
|
||||
dircache_disable();
|
||||
if (dircache_size == 0)
|
||||
{
|
||||
*size = 0;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
*size = dircache_size + (DIRCACHE_RESERVE-reserve_used);
|
||||
|
||||
return dircache_root;
|
||||
}
|
||||
|
||||
/**
|
||||
* Main initialization function that must be called before any other
|
||||
* operations within the dircache.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue