summaryrefslogtreecommitdiffstats
path: root/apps/plugins/mpegplayer/mpegplayer.c
diff options
context:
space:
mode:
authorSolomon Peachy <pizza@shaftnet.org>2019-07-20 17:32:49 -0400
committerSolomon Peachy <pizza@shaftnet.org>2019-08-04 22:47:00 +0200
commit4ad76652ef19daf6404e8a97eb73aeadfe1e66fb (patch)
treeb54be971440fcd96879973f088bd20e00e687c7f /apps/plugins/mpegplayer/mpegplayer.c
parent7234de58ae69b4ecbd97efd77a61bf0cfc1737bf (diff)
downloadrockbox-4ad76652ef19daf6404e8a97eb73aeadfe1e66fb.tar.gz
rockbox-4ad76652ef19daf6404e8a97eb73aeadfe1e66fb.tar.bz2
rockbox-4ad76652ef19daf6404e8a97eb73aeadfe1e66fb.zip
Speech feedback in mpegplayer menus
Patch by Igor Poretsky Change-Id: Idc6920e17be6537557f2b1cf00f7e559e30b45e8
Diffstat (limited to 'apps/plugins/mpegplayer/mpegplayer.c')
-rw-r--r--apps/plugins/mpegplayer/mpegplayer.c67
1 files changed, 67 insertions, 0 deletions
diff --git a/apps/plugins/mpegplayer/mpegplayer.c b/apps/plugins/mpegplayer/mpegplayer.c
index 6a33a544db..39ea484ff2 100644
--- a/apps/plugins/mpegplayer/mpegplayer.c
+++ b/apps/plugins/mpegplayer/mpegplayer.c
@@ -634,6 +634,54 @@ static unsigned draw_blendcolor(unsigned c1, unsigned c2, unsigned char amount)
}
#endif
+#ifdef PLUGIN_USE_IRAM
+/* IRAM preserving mechanism to enable talking menus */
+static char *iram_saved_copy;
+extern char iramstart[], iramend[];
+
+static void iram_saving_init(void)
+{
+#ifndef SIMULATOR
+ size_t size;
+ iram_saved_copy = (char *)rb->plugin_get_buffer(&size);
+
+ if (size >= (size_t)(iramend-iramstart))
+ iram_saved_copy += size - (size_t)(iramend - iramstart);
+ else
+#endif
+ iram_saved_copy = NULL;
+
+ return;
+}
+
+void mpegplayer_iram_preserve(void)
+{
+ if (iram_saved_copy)
+ {
+ rb->memcpy(iram_saved_copy, iramstart, iramend-iramstart);
+#ifdef HAVE_CPUCACHE_INVALIDATE
+ /* make the icache (if it exists) up to date with the new code */
+ rb->cpucache_invalidate();
+#endif /* HAVE_CPUCACHE_INVALIDATE */
+ }
+ return;
+}
+
+void mpegplayer_iram_restore(void)
+{
+ if (iram_saved_copy)
+ {
+ rb->audio_hard_stop();
+ rb->memcpy(iramstart, iram_saved_copy, iramend-iramstart);
+#ifdef HAVE_CPUCACHE_INVALIDATE
+ /* make the icache (if it exists) up to date with the new code */
+ rb->cpucache_invalidate();
+#endif /* HAVE_CPUCACHE_INVALIDATE */
+ }
+ return;
+}
+#endif
+
/* Drawing functions that operate rotated on LCD_PORTRAIT displays -
* most are just wrappers of lcd_* functions with transforms applied.
* The origin is the upper-left corner of the OSD area */
@@ -2369,6 +2417,10 @@ enum plugin_status plugin_start(const void* parameter)
int status = PLUGIN_OK; /* assume success */
bool quit = false;
+#if defined(PLUGIN_USE_IRAM) && !defined(SIMULATOR)
+ bool preserved_talk_state;
+#endif
+
if (parameter == NULL) {
/* No file = GTFO */
rb->splash(HZ*2, "No File");
@@ -2378,6 +2430,16 @@ enum plugin_status plugin_start(const void* parameter)
/* Disable all talking before initializing IRAM */
rb->talk_disable(true);
+#ifdef PLUGIN_USE_IRAM
+ iram_saving_init();
+
+#ifndef SIMULATOR
+ preserved_talk_state = rb->global_settings->talk_menu;
+ if (!iram_saved_copy)
+ rb->global_settings->talk_menu = false;
+#endif
+#endif
+
#ifdef HAVE_LCD_COLOR
rb->lcd_set_backdrop(NULL);
rb->lcd_set_foreground(LCD_WHITE);
@@ -2528,6 +2590,11 @@ enum plugin_status plugin_start(const void* parameter)
stream_exit();
+#if defined(PLUGIN_USE_IRAM) && !defined(SIMULATOR)
+ if (!iram_saved_copy)
+ rb->global_settings->talk_menu = preserved_talk_state;
+#endif
+
rb->talk_disable(false);
/* Actually handle delayed processing of system events of interest