summaryrefslogtreecommitdiffstats
path: root/firmware
diff options
context:
space:
mode:
Diffstat (limited to 'firmware')
-rw-r--r--firmware/common/dircache.c33
-rw-r--r--firmware/export/powermgmt.h1
-rw-r--r--firmware/include/dircache.h1
-rw-r--r--firmware/powermgmt.c6
4 files changed, 30 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.
*/
diff --git a/firmware/export/powermgmt.h b/firmware/export/powermgmt.h
index da78857072..6c31aeec52 100644
--- a/firmware/export/powermgmt.h
+++ b/firmware/export/powermgmt.h
@@ -139,6 +139,7 @@ void set_sleep_timer(int seconds);
int get_sleep_timer(void);
void set_car_adapter_mode(bool setting);
void reset_poweroff_timer(void);
+void cancel_shutdown(void);
void shutdown_hw(void);
void sys_poweroff(void);
diff --git a/firmware/include/dircache.h b/firmware/include/dircache.h
index bd7308da68..6c214a9073 100644
--- a/firmware/include/dircache.h
+++ b/firmware/include/dircache.h
@@ -83,6 +83,7 @@ void dircache_init(void);
int dircache_load(const char *path);
int dircache_save(const char *path);
int dircache_build(int last_size);
+void* dircache_steal_buffer(long *size);
bool dircache_is_enabled(void);
int dircache_get_entry_count(void);
int dircache_get_cache_size(void);
diff --git a/firmware/powermgmt.c b/firmware/powermgmt.c
index 4c6db6d44c..15977caed6 100644
--- a/firmware/powermgmt.c
+++ b/firmware/powermgmt.c
@@ -1019,6 +1019,12 @@ void sys_poweroff(void)
queue_post(&button_queue, SYS_POWEROFF, NULL);
}
+void cancel_shutdown(void)
+{
+ logf("sys_cancel_shutdown()");
+ shutdown_timeout = 0;
+}
+
/* Various hardware housekeeping tasks relating to shutting down the jukebox */
void shutdown_hw(void)
{