1
0
Fork 0
forked from len0rd/rockbox

When recording, disable voice menus without actually modifying user settings. Patch FS#7272, fixes bug FS #6163

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@13615 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Steve Bavin 2007-06-11 08:28:38 +00:00
parent 0fba85fe9e
commit 24d9f59c78
9 changed files with 48 additions and 26 deletions

View file

@ -671,7 +671,7 @@ static char* select_bookmark(const char* bookmark_file_name, bool show_dont_resu
item--; item--;
} }
if (item != last_item && global_settings.talk_menu) if (item != last_item && talk_menus_enabled())
{ {
last_item = item; last_item = item;

View file

@ -224,7 +224,7 @@ static void talk_menu_item(const struct menu_item_ex *menu,
unsigned char *str; unsigned char *str;
int sel; int sel;
if (global_settings.talk_menu) if (talk_menus_enabled())
{ {
sel = get_menu_selection(gui_synclist_get_sel_pos(lists),menu); sel = get_menu_selection(gui_synclist_get_sel_pos(lists),menu);
if ((menu->flags&MENU_TYPE_MASK) == MT_MENU) if ((menu->flags&MENU_TYPE_MASK) == MT_MENU)

View file

@ -177,8 +177,9 @@ static bool show_info(void)
size2 = 0; size2 = 0;
#endif #endif
if (global_settings.talk_menu) if (talk_menus_enabled())
{ /* say whatever is reasonable, no real connection to the screen */ {
/* say whatever is reasonable, no real connection to the screen */
bool enqueue = false; /* enqueue all but the first */ bool enqueue = false; /* enqueue all but the first */
if (battery_level() >= 0) if (battery_level() >= 0)
{ {

View file

@ -190,7 +190,7 @@ static void kbd_spellchar(unsigned short c)
{ {
static char spell_char[2] = "\0\0"; /* store char to pass to talk_spell */ static char spell_char[2] = "\0\0"; /* store char to pass to talk_spell */
if (global_settings.talk_menu && c < 128) /* voice UI? */ if (talk_menus_enabled() && c < 128) /* voice UI? */
{ {
spell_char[0] = (char)c; spell_char[0] = (char)c;
talk_spell(spell_char, false); talk_spell(spell_char, false);
@ -510,7 +510,7 @@ int kbd_input(char* text, int buflen)
/* Initial edit position is after last character */ /* Initial edit position is after last character */
editpos = utf8length(text); editpos = utf8length(text);
if (global_settings.talk_menu) /* voice UI? */ if (talk_menus_enabled()) /* voice UI? */
talk_spell(text, true); /* spell initial text */ talk_spell(text, true); /* spell initial text */
action_signalscreenchange(); action_signalscreenchange();
@ -1087,7 +1087,7 @@ int kbd_input(char* text, int buflen)
kbd_inschar(text, buflen, &editpos, ch); kbd_inschar(text, buflen, &editpos, ch);
} }
if (global_settings.talk_menu) /* voice UI? */ if (talk_menus_enabled()) /* voice UI? */
talk_spell(text, false); talk_spell(text, false);
/* speak revised text */ /* speak revised text */
@ -1116,7 +1116,7 @@ int kbd_input(char* text, int buflen)
kbd_inschar(text, buflen, &editpos, ch); kbd_inschar(text, buflen, &editpos, ch);
} }
if (global_settings.talk_menu) /* voice UI? */ if (talk_menus_enabled()) /* voice UI? */
talk_spell(text, false); /* speak revised text */ talk_spell(text, false); /* speak revised text */
break; break;
@ -1167,7 +1167,7 @@ int kbd_input(char* text, int buflen)
param[l].hangul = false; param[l].hangul = false;
kbd_inschar(text, buflen, &editpos, morse_alphabets[j]); kbd_inschar(text, buflen, &editpos, morse_alphabets[j]);
if (global_settings.talk_menu) /* voice UI? */ if (talk_menus_enabled()) /* voice UI? */
talk_spell(text, false); /* speak revised text */ talk_spell(text, false); /* speak revised text */
} }
#endif /* KBD_MORSE_INPUT */ #endif /* KBD_MORSE_INPUT */

View file

@ -705,7 +705,6 @@ bool recording_screen(bool no_source)
int radio_status = (global_settings.rec_source != AUDIO_SRC_FMRADIO) ? int radio_status = (global_settings.rec_source != AUDIO_SRC_FMRADIO) ?
FMRADIO_OFF : get_radio_status(); FMRADIO_OFF : get_radio_status();
#endif #endif
int talk_menu = global_settings.talk_menu;
#if (CONFIG_LED == LED_REAL) #if (CONFIG_LED == LED_REAL)
bool led_state = false; bool led_state = false;
int led_countdown = 2; int led_countdown = 2;
@ -741,9 +740,8 @@ bool recording_screen(bool no_source)
#endif #endif
#if CONFIG_CODEC == SWCODEC #if CONFIG_CODEC == SWCODEC
/* recording_menu gets messed up: so reset talk_menu */ /* recording_menu gets messed up: so prevent manus talking */
talk_menu = global_settings.talk_menu; talk_disable_menus();
global_settings.talk_menu = 0;
/* audio_init_recording stops anything playing when it takes the audio /* audio_init_recording stops anything playing when it takes the audio
buffer */ buffer */
#else #else
@ -931,8 +929,9 @@ bool recording_screen(bool no_source)
have_recorded = true; have_recorded = true;
rec_record(); rec_record();
last_seconds = 0; last_seconds = 0;
if (talk_menu) if (global_settings.talk_menu)
{ /* no voice possible here, but a beep */ {
/* no voice possible here, but a beep */
audio_beep(HZ/2); /* longer beep on start */ audio_beep(HZ/2); /* longer beep on start */
} }
} }
@ -960,8 +959,9 @@ bool recording_screen(bool no_source)
if(audio_stat & AUDIO_STATUS_PAUSE) if(audio_stat & AUDIO_STATUS_PAUSE)
{ {
audio_resume_recording(); audio_resume_recording();
if (talk_menu) if (global_settings.talk_menu)
{ /* no voice possible here, but a beep */ {
/* no voice possible here, but a beep */
audio_beep(HZ/4); /* short beep on resume */ audio_beep(HZ/4); /* short beep on resume */
} }
} }
@ -1695,7 +1695,7 @@ bool recording_screen(bool no_source)
rec_set_source(AUDIO_SRC_PLAYBACK, SRCF_PLAYBACK); rec_set_source(AUDIO_SRC_PLAYBACK, SRCF_PLAYBACK);
/* restore talk_menu setting */ /* restore talk_menu setting */
global_settings.talk_menu = talk_menu; talk_enable_menus();
#else /* !SWCODEC */ #else /* !SWCODEC */
audio_init_playback(); audio_init_playback();
#endif /* CONFIG_CODEC == SWCODEC */ #endif /* CONFIG_CODEC == SWCODEC */

View file

@ -155,7 +155,7 @@ int mmc_remove_request(void)
FOR_NB_SCREENS(i) FOR_NB_SCREENS(i)
screens[i].clear_display(); screens[i].clear_display();
gui_syncsplash(1, str(LANG_REMOVE_MMC)); gui_syncsplash(1, str(LANG_REMOVE_MMC));
if (global_settings.talk_menu) if (talk_menus_enabled())
talk_id(LANG_REMOVE_MMC, false); talk_id(LANG_REMOVE_MMC, false);
while (1) while (1)
@ -821,7 +821,7 @@ static void say_time(int cursorpos, const struct tm *tm)
static const int unit[] = { UNIT_HOUR, UNIT_MIN, UNIT_SEC, 0, 0, 0 }; static const int unit[] = { UNIT_HOUR, UNIT_MIN, UNIT_SEC, 0, 0, 0 };
int value = 0; int value = 0;
if (!global_settings.talk_menu) if (!talk_menus_enabled())
return; return;
switch(cursorpos) switch(cursorpos)

View file

@ -952,7 +952,7 @@ const struct settings_list* find_setting(void* variable, int *id)
void talk_setting(void *global_settings_variable) void talk_setting(void *global_settings_variable)
{ {
const struct settings_list *setting; const struct settings_list *setting;
if (global_settings.talk_menu == 0) if (!talk_menus_enabled())
return; return;
setting = find_setting(global_settings_variable, NULL); setting = find_setting(global_settings_variable, NULL);
if (setting == NULL) if (setting == NULL)
@ -1043,7 +1043,7 @@ bool set_bool_options(const char* string, bool* variable,
static void talk_unit(int unit, int value, long (*get_talk_id)(int value)) static void talk_unit(int unit, int value, long (*get_talk_id)(int value))
{ {
if (global_settings.talk_menu) if (talk_menus_enabled())
{ {
if (get_talk_id) if (get_talk_id)
{ {
@ -1121,11 +1121,12 @@ static bool do_set_setting(const unsigned char* string, void *variable,
gui_synclist_limit_scroll(&lists,true); gui_synclist_limit_scroll(&lists,true);
gui_synclist_select_item(&lists, selected); gui_synclist_select_item(&lists, selected);
if (global_settings.talk_menu) if (talk_menus_enabled())
{ {
if (cb_data->type == INT && !cb_data->options) if (cb_data->type == INT && !cb_data->options)
talk_unit(cb_data->voice_unit, *(int*)variable, cb_data->get_talk_id); talk_unit(cb_data->voice_unit, *(int*)variable, cb_data->get_talk_id);
else talk_id(cb_data->options[selected].voice_id, false); else
talk_id(cb_data->options[selected].voice_id, false);
} }
gui_synclist_draw(&lists); gui_synclist_draw(&lists);
@ -1139,7 +1140,7 @@ static bool do_set_setting(const unsigned char* string, void *variable,
if (gui_synclist_do_button(&lists,action, if (gui_synclist_do_button(&lists,action,
allow_wrap?LIST_WRAP_UNLESS_HELD:LIST_WRAP_OFF)) allow_wrap?LIST_WRAP_UNLESS_HELD:LIST_WRAP_OFF))
{ {
if (global_settings.talk_menu) if (talk_menus_enabled())
{ {
int value; int value;
if (cb_data->type == INT && !cb_data->options) if (cb_data->type == INT && !cb_data->options)

View file

@ -127,6 +127,7 @@ static unsigned char* p_lastclip; /* address of latest clip, for silence add */
static unsigned long voicefile_size = 0; /* size of the loaded voice file */ 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 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 bool talk_initialized; /* true if talk_init has been called */
static int talk_menu_disable; /* if non-zero, temporarily disable voice UI (not saved) */
/***************** Private prototypes *****************/ /***************** Private prototypes *****************/
@ -498,6 +499,7 @@ static void reset_state(void)
void talk_init(void) void talk_init(void)
{ {
talk_menu_disable = 0;
if (talk_initialized && !strcasecmp(last_lang, global_settings.lang_file)) if (talk_initialized && !strcasecmp(last_lang, global_settings.lang_file))
{ {
/* not a new file, nothing to do */ /* not a new file, nothing to do */
@ -819,3 +821,19 @@ int talk_spell(const char* spell, bool enqueue)
return 0; return 0;
} }
bool talk_menus_enabled(void)
{
return (global_settings.talk_menu && talk_menu_disable == 0);
}
void talk_disable_menus(void)
{
talk_menu_disable++;
}
void talk_enable_menus(void)
{
talk_menu_disable--;
}

View file

@ -71,5 +71,7 @@ int talk_file(const char* filename, bool enqueue); /* play a thumbnail from file
int talk_number(long n, bool enqueue); /* say a number */ 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_value(long n, int unit, bool enqueue); /* say a numeric value */
int talk_spell(const char* spell, bool enqueue); /* spell a string */ 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);
void talk_enable_menus(void);
#endif /* __TALK_H__ */ #endif /* __TALK_H__ */