Index: apps/playlist.c =================================================================== --- apps/playlist.c (revision 15201) +++ apps/playlist.c (working copy) @@ -1664,7 +1664,7 @@ { static long talked_tick = 0; long id = P2ID(fmt); - if(talk_menus_enabled() && id>=0) + if(global_settings.talk_menu && id>=0) { if(final || (count && (talked_tick == 0 || TIME_AFTER(current_tick, talked_tick+5*HZ)))) Index: apps/screens.c =================================================================== --- apps/screens.c (revision 15201) +++ apps/screens.c (working copy) @@ -158,7 +158,7 @@ FOR_NB_SCREENS(i) screens[i].clear_display(); gui_syncsplash(1, str(LANG_REMOVE_MMC)); - if (talk_menus_enabled()) + if (global_settings.talk_menu) talk_id(LANG_REMOVE_MMC, false); while (1) @@ -822,7 +822,7 @@ static const int unit[] = { UNIT_HOUR, UNIT_MIN, UNIT_SEC, 0, 0, 0 }; int value = 0; - if (!talk_menus_enabled()) + if (!global_settings.talk_menu) return; switch(cursorpos) Index: apps/recorder/keyboard.c =================================================================== --- apps/recorder/keyboard.c (revision 15201) +++ apps/recorder/keyboard.c (working copy) @@ -191,7 +191,7 @@ /* helper function to spell a char if voice UI is enabled */ static void kbd_spellchar(unsigned short c) { - if (talk_menus_enabled()) /* voice UI? */ + if (global_settings.talk_menu) /* voice UI? */ { unsigned char tmp[5]; /* store char to pass to talk_spell */ @@ -208,7 +208,7 @@ #ifdef KBD_MODES static void say_edit(void) { - if(talk_menus_enabled()) + if(global_settings.talk_menu) talk_id(VOICE_EDIT, false); } #endif @@ -527,7 +527,7 @@ /* Initial edit position is after last character */ editpos = utf8length(text); - if (talk_menus_enabled()) /* voice UI? */ + if (global_settings.talk_menu) /* voice UI? */ talk_spell(text, true); /* spell initial text */ @@ -832,7 +832,7 @@ kbd_spellchar(text[c]); } #if CONFIG_CODEC == SWCODEC - else if (talk_menus_enabled()) + else if (global_settings.talk_menu) pcmbuf_beep(1000, 150, 1500); #endif } @@ -877,7 +877,7 @@ kbd_spellchar(text[c]); } #if CONFIG_CODEC == SWCODEC - else if (talk_menus_enabled()) + else if (global_settings.talk_menu) pcmbuf_beep(1000, 150, 1500); #endif } @@ -1124,7 +1124,7 @@ kbd_inschar(text, buflen, &editpos, ch); } - if (talk_menus_enabled()) /* voice UI? */ + if (global_settings.talk_menu) /* voice UI? */ talk_spell(text, false); /* speak revised text */ @@ -1153,7 +1153,7 @@ kbd_inschar(text, buflen, &editpos, ch); } - if (talk_menus_enabled()) /* voice UI? */ + if (global_settings.talk_menu) /* voice UI? */ talk_spell(text, false); /* speak revised text */ break; @@ -1166,7 +1166,7 @@ kbd_spellchar(text[c]); } #if CONFIG_CODEC == SWCODEC - else if (talk_menus_enabled()) + else if (global_settings.talk_menu) pcmbuf_beep(1000, 150, 1500); #endif break; @@ -1180,7 +1180,7 @@ kbd_spellchar(text[c]); } #if CONFIG_CODEC == SWCODEC - else if (talk_menus_enabled()) + else if (global_settings.talk_menu) pcmbuf_beep(1000, 150, 1500); #endif break; @@ -1212,7 +1212,7 @@ param[l].hangul = false; kbd_inschar(text, buflen, &editpos, morse_alphabets[j]); - if (talk_menus_enabled()) /* voice UI? */ + if (global_settings.talk_menu) /* voice UI? */ talk_spell(text, false); /* speak revised text */ } #endif /* KBD_MORSE_INPUT */ Index: apps/recorder/recording.c =================================================================== --- apps/recorder/recording.c (revision 15201) +++ apps/recorder/recording.c (working copy) @@ -889,7 +889,7 @@ #if CONFIG_CODEC == SWCODEC /* recording_menu gets messed up: so prevent manus talking */ - talk_disable_menus(); + talk_disable(true); /* audio_init_recording stops anything playing when it takes the audio buffer */ #else @@ -1873,8 +1873,8 @@ /* Go back to playback mode */ rec_set_source(AUDIO_SRC_PLAYBACK, SRCF_PLAYBACK); - /* restore talk_menu setting */ - talk_enable_menus(); + /* restore talking */ + talk_disable(false); #else /* !SWCODEC */ audio_init_playback(); #endif /* CONFIG_CODEC == SWCODEC */ Index: apps/settings.c =================================================================== --- apps/settings.c (revision 15201) +++ apps/settings.c (working copy) @@ -949,7 +949,7 @@ void talk_setting(void *global_settings_variable) { const struct settings_list *setting; - if (!talk_menus_enabled()) + if (!global_settings.talk_menu) return; setting = find_setting(global_settings_variable, NULL); if (setting == NULL) Index: apps/plugins/mpegplayer/mpegplayer.c =================================================================== --- apps/plugins/mpegplayer/mpegplayer.c (revision 15201) +++ apps/plugins/mpegplayer/mpegplayer.c (working copy) @@ -2218,21 +2218,23 @@ int grayscales; #endif - audio_sync_start = 0; - audio_sync_time = 0; - video_sync_start = 0; + rb = api; + /* Initialize IRAM - stops audio and voice as well */ + rb->talk_disable(true); + PLUGIN_IRAM_INIT(api) + if (parameter == NULL) { - api->splash(HZ*2, "No File"); + rb->splash(HZ*2, "No File"); return PLUGIN_ERROR; } + rb->splash(0, "Loading..."); - /* Initialize IRAM - stops audio and voice as well */ - PLUGIN_IRAM_INIT(api) - rb = api; - rb->splash(0, "Loading..."); + audio_sync_start = 0; + audio_sync_time = 0; + video_sync_start = 0; /* sets audiosize and returns buffer pointer */ audiobuf = rb->plugin_get_audio_buffer(&audiosize); @@ -2336,7 +2338,6 @@ /* Turn off backlight timeout */ backlight_force_on(rb); /* backlight control in lib/helper.c */ - rb->talk_disable_menus(); #ifdef HAVE_ADJUSTABLE_CPU_FREQ rb->cpu_boost(true); @@ -2531,7 +2532,7 @@ /* Turn on backlight timeout (revert to settings) */ backlight_use_settings(rb); /* backlight control in lib/helper.c */ - rb->talk_enable_menus(); + rb->talk_disable(false); return status; } Index: apps/gui/option_select.c =================================================================== --- apps/gui/option_select.c (revision 15201) +++ apps/gui/option_select.c (working copy) @@ -133,7 +133,7 @@ static void option_talk(struct settings_list *setting, int temp_var) { - if (!talk_menus_enabled()) + if (!global_settings.talk_menu) return; if ((setting->flags & F_BOOL_SETTING) == F_BOOL_SETTING) { Index: apps/gui/yesno.c =================================================================== --- apps/gui/yesno.c (revision 15201) +++ apps/gui/yesno.c (working copy) @@ -145,7 +145,7 @@ while (result==-1) { /* Repeat the question every 5secs (more or less) */ - if (talk_menus_enabled() + if (global_settings.talk_menu && (talked_tick==0 || TIME_AFTER(current_tick, talked_tick+HZ*5))) { talked_tick = current_tick; @@ -175,7 +175,7 @@ FOR_NB_SCREENS(i) result_displayed=gui_yesno_draw_result(&(yn[i]), result); - if (talk_menus_enabled()) + if (global_settings.talk_menu) { talk_idarray(voice_ids, false); talk_force_enqueue_next(); Index: apps/menu.c =================================================================== --- apps/menu.c (revision 15201) +++ apps/menu.c (working copy) @@ -225,7 +225,7 @@ unsigned char *str; int sel; - if (talk_menus_enabled()) + if (global_settings.talk_menu) { sel = get_menu_selection(gui_synclist_get_sel_pos(lists),menu); if ((menu->flags&MENU_TYPE_MASK) == MT_MENU) Index: apps/menus/main_menu.c =================================================================== --- apps/menus/main_menu.c (revision 15201) +++ apps/menus/main_menu.c (working copy) @@ -161,7 +161,7 @@ size2 = 0; #endif - if (talk_menus_enabled()) + if (global_settings.talk_menu) { /* say whatever is reasonable, no real connection to the screen */ bool enqueue = false; /* enqueue all but the first */ Index: apps/alarm_menu.c =================================================================== --- apps/alarm_menu.c (revision 15201) +++ apps/alarm_menu.c (working copy) @@ -44,7 +44,7 @@ static void speak_time(int hours, int minutes, bool speak_hours) { - if (talk_menus_enabled()){ + if (global_settings.talk_menu){ if(speak_hours) { talk_value(hours, UNIT_HOUR, false); talk_value(minutes, UNIT_MIN, true); @@ -86,7 +86,7 @@ screens[i].puts(0, 3, str(LANG_ALARM_MOD_KEYS)); } /* Talk when entering the wakeup screen */ - if (talk_menus_enabled()) + if (global_settings.talk_menu) { talk_value(h, UNIT_HOUR, true); talk_value(m, UNIT_MIN, true); @@ -113,7 +113,7 @@ rtc_init(); rtc_set_alarm(h,m); rtc_enable_alarm(true); - if (talk_menus_enabled()) + if (global_settings.talk_menu) { talk_id(LANG_ALARM_MOD_TIME_TO_GO, true); talk_value(togo / 60, UNIT_HOUR, true); @@ -164,7 +164,7 @@ case ACTION_STD_NEXTREPEAT: h = (h+1) % 24; - if (talk_menus_enabled()) + if (global_settings.talk_menu) talk_value(h, UNIT_HOUR, false); break; @@ -173,7 +173,7 @@ case ACTION_STD_PREVREPEAT: h = (h+23) % 24; - if (talk_menus_enabled()) + if (global_settings.talk_menu) talk_value(h, UNIT_HOUR, false); break; Index: apps/talk.c =================================================================== --- apps/talk.c (revision 15201) +++ apps/talk.c (working copy) @@ -131,7 +131,7 @@ static unsigned long voicefile_size = 0; /* size of the loaded voice file */ static unsigned char last_lang[MAX_FILENAME+1]; /* name of last used lang file (in talk_init) */ static bool talk_initialized; /* true if talk_init has been called */ -static int talk_menu_disable; /* if non-zero, temporarily disable voice UI (not saved) */ +static int talk_temp_disable_count; /* if non-zero, temporarily disable voice UI (not saved) */ /***************** Private prototypes *****************/ @@ -504,7 +504,7 @@ void talk_init(void) { - talk_menu_disable = 0; + talk_temp_disable_count = 0; if (talk_initialized && !strcasecmp(last_lang, global_settings.lang_file)) { /* not a new file, nothing to do */ @@ -583,6 +583,8 @@ unsigned char* clipbuf; int unit; + if (talk_temp_disable_count != 0) + return -1; /* talking has been disabled */ #if CONFIG_CODEC != SWCODEC if (audio_status()) /* busy, buffer in use */ return -1; @@ -644,6 +646,8 @@ int size; struct mp3entry info; + if (talk_temp_disable_count != 0) + return -1; /* talking has been disabled */ #if CONFIG_CODEC != SWCODEC if (audio_status()) /* busy, buffer in use */ return -1; @@ -689,6 +693,8 @@ int level = 2; /* mille count */ long mil = 1000000000; /* highest possible "-illion" */ + if (talk_temp_disable_count != 0) + return -1; /* talking has been disabled */ #if CONFIG_CODEC != SWCODEC if (audio_status()) /* busy, buffer in use */ return -1; @@ -785,6 +791,8 @@ = VOICE_PM_UNITS_PER_TICK, }; + if (talk_temp_disable_count != 0) + return -1; /* talking has been disabled */ #if CONFIG_CODEC != SWCODEC if (audio_status()) /* busy, buffer in use */ return -1; @@ -819,6 +827,8 @@ { char c; /* currently processed char */ + if (talk_temp_disable_count != 0) + return -1; /* talking has been disabled */ #if CONFIG_CODEC != SWCODEC if (audio_status()) /* busy, buffer in use */ return -1; @@ -849,26 +859,18 @@ return 0; } -bool talk_menus_enabled(void) +void talk_disable(bool disable) { - return (global_settings.talk_menu && talk_menu_disable == 0); + if (disable) + talk_temp_disable_count++; + else + talk_temp_disable_count--; } - -void talk_disable_menus(void) -{ - talk_menu_disable++; -} - -void talk_enable_menus(void) -{ - talk_menu_disable--; -} - #if CONFIG_RTC void talk_date_time(struct tm *tm, bool speak_current_time_string) { - if(talk_menus_enabled ()) + if(global_settings.talk_menu) { if(speak_current_time_string) talk_id(VOICE_CURRENT_TIME, true); Index: apps/talk.h =================================================================== --- apps/talk.h (revision 15201) +++ apps/talk.h (working copy) @@ -74,9 +74,7 @@ int talk_number(long n, bool enqueue); /* say a number */ int talk_value(long n, int unit, bool enqueue); /* say a numeric value */ int talk_spell(const char* spell, bool enqueue); /* spell a string */ -bool talk_menus_enabled(void); /* returns true if menus should be voiced */ -void talk_disable_menus(void); /* disable voice menus (temporarily, not persisted) */ -void talk_enable_menus(void); /* re-enable voice menus */ +void talk_disable(bool disable); /* temporarily disable (or re-enable) talking (temporarily, not persisted) */ int do_shutup(void); /* kill voice unconditionally */ int shutup(void); /* Interrupt voice, as when enqueue is false */ @@ -116,18 +114,18 @@ /* This version talks only if talking menus are enabled, and does not enqueue the initial id. */ #define cond_talk_ids(ids...) do { \ - if (talk_menus_enabled()) \ + if (global_settings.talk_menu) \ talk_ids(false, ids); \ } while(0) /* And a version that takes the array parameter... */ #define cond_talk_idarray(idarray) do { \ - if (talk_menus_enabled() \ + if (global_settings.talk_menu \ talk_idarray(idarray, false); \ } while(0) /* Convenience macro to conditionally speak something and not have it interrupted. */ #define cond_talk_ids_fq(ids...) do { \ - if (talk_menus_enabled()) { \ + if (global_settings.talk_menu) { \ talk_ids(false, ids); \ talk_force_enqueue_next(); \ } \ Index: apps/player/keyboard.c =================================================================== --- apps/player/keyboard.c (revision 15201) +++ apps/player/keyboard.c (working copy) @@ -74,7 +74,7 @@ /* helper function to spell a char if voice UI is enabled */ static void kbd_spellchar(char c) { - if (talk_menus_enabled()) /* voice UI? */ + if (global_settings.talk_menu) /* voice UI? */ { unsigned char tmp[5]; /* store char to pass to talk_spell */ @@ -90,7 +90,7 @@ static void say_edit(void) { - if (talk_menus_enabled()) + if (global_settings.talk_menu) talk_id(VOICE_EDIT, false); } @@ -112,7 +112,7 @@ editpos = utf8length(text); - if (talk_menus_enabled()) /* voice UI? */ + if (global_settings.talk_menu) /* voice UI? */ talk_spell(text, true); /* spell initial text */ while (!done) @@ -284,7 +284,7 @@ editpos++; } } - if (talk_menus_enabled()) /* voice UI? */ + if (global_settings.talk_menu) /* voice UI? */ talk_spell(text, false); /* speak revised text */ break; Index: apps/plugin.c =================================================================== --- apps/plugin.c (revision 15201) +++ apps/plugin.c (working copy) @@ -468,8 +468,7 @@ #endif &global_settings, &global_status, - talk_disable_menus, - talk_enable_menus, + talk_disable, #if CONFIG_CODEC == SWCODEC codec_load_file, get_codec_filename, Index: apps/plugin.h =================================================================== --- apps/plugin.h (revision 15201) +++ apps/plugin.h (working copy) @@ -112,12 +112,12 @@ #define PLUGIN_MAGIC 0x526F634B /* RocK */ /* increase this every time the api struct changes */ -#define PLUGIN_API_VERSION 83 +#define PLUGIN_API_VERSION 84 /* update this to latest version if a change to the api struct breaks backwards compatibility (and please take the opportunity to sort in any new function which are "waiting" at the end of the function table) */ -#define PLUGIN_MIN_API_VERSION 83 +#define PLUGIN_MIN_API_VERSION 84 /* plugin return codes */ enum plugin_status { @@ -579,8 +579,7 @@ #endif struct user_settings* global_settings; struct system_status *global_status; - void (*talk_disable_menus)(void); - void (*talk_enable_menus)(void); + void (*talk_disable)(bool disable); #if CONFIG_CODEC == SWCODEC int (*codec_load_file)(const char* codec, struct codec_api *api); const char *(*get_codec_filename)(int cod_spec); Index: apps/bookmark.c =================================================================== --- apps/bookmark.c (revision 15201) +++ apps/bookmark.c (working copy) @@ -667,7 +667,7 @@ item--; } - if (item != last_item && talk_menus_enabled()) + if (item != last_item && global_settings.talk_menu) { last_item = item; Index: apps/root_menu.c =================================================================== --- apps/root_menu.c (revision 15201) +++ apps/root_menu.c (working copy) @@ -160,7 +160,7 @@ /* Display building progress */ static long talked_tick = 0; - if(talk_menus_enabled() && + if(global_settings.talk_menu && (talked_tick == 0 || TIME_AFTER(current_tick, talked_tick+7*HZ))) { Index: apps/main.c =================================================================== --- apps/main.c (revision 15201) +++ apps/main.c (working copy) @@ -225,7 +225,7 @@ /* hwcodec can't use voice here, as the database commit * uses the audio buffer. */ static long talked_tick = 0; - if(talk_menus_enabled() + if(global_settings.talk_menu && (talked_tick == 0 || TIME_AFTER(current_tick, talked_tick+7*HZ))) { Index: apps/misc.c =================================================================== --- apps/misc.c (revision 15201) +++ apps/misc.c (working copy) @@ -685,7 +685,7 @@ audio_close_recording(); #endif - if(talk_menus_enabled()) + if(global_settings.talk_menu) { bool enqueue = false; if(msg_id != -1) Index: uisimulator/common/stubs.c =================================================================== --- uisimulator/common/stubs.c (revision 15201) +++ uisimulator/common/stubs.c (working copy) @@ -347,19 +347,11 @@ return 0; } -bool talk_menus_enabled(void) +void talk_disable(bool disable) { - return false; + (void) disable; } -void talk_enable_menus(void) -{ -} - -void talk_disable_menus(void) -{ -} - const char* const dir_thumbnail_name = "_dirname.talk"; const char* const file_thumbnail_ext = ".talk"; #endif