From 4ad76652ef19daf6404e8a97eb73aeadfe1e66fb Mon Sep 17 00:00:00 2001 From: Solomon Peachy Date: Sat, 20 Jul 2019 17:32:49 -0400 Subject: Speech feedback in mpegplayer menus Patch by Igor Poretsky Change-Id: Idc6920e17be6537557f2b1cf00f7e559e30b45e8 --- apps/plugins/mpegplayer/mpegplayer.c | 67 ++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) (limited to 'apps/plugins/mpegplayer/mpegplayer.c') 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 -- cgit v1.2.3