diff options
author | Miika Pekkarinen <miipekk@ihme.org> | 2006-04-16 17:32:54 +0000 |
---|---|---|
committer | Miika Pekkarinen <miipekk@ihme.org> | 2006-04-16 17:32:54 +0000 |
commit | 3b3134610348a56bbf25cfd256b0f36908d0d752 (patch) | |
tree | 5c6d01c180ba7ecfc33816655c60943fcf287558 /firmware/common | |
parent | caec58bc0fff3672180a1f643be1cbbe09bc008b (diff) |
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
Diffstat (limited to 'firmware/common')
-rw-r--r-- | firmware/common/dircache.c | 33 |
1 files changed, 22 insertions, 11 deletions
diff --git a/firmware/common/dircache.c b/firmware/common/dircache.c index 9a0bcb631f..e5ee77c311 100644 --- a/firmware/common/dircache.c +++ b/firmware/common/dircache.c @@ -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; @@ -650,6 +644,23 @@ int dircache_build(int last_size) } /** + * 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. */ |