diff options
author | Steve Bavin <pondlife@pondlife.me> | 2007-10-19 15:31:42 +0000 |
---|---|---|
committer | Steve Bavin <pondlife@pondlife.me> | 2007-10-19 15:31:42 +0000 |
commit | 32a95751301a4aa5f51ea76b7eb3764d197dd6e3 (patch) | |
tree | 860d5e0c767cc53d038bb72ff19c237215dd3eee | |
parent | 877ea486bad40bde6f8b969acc8af50f244884c0 (diff) | |
download | rockbox-32a95751301a4aa5f51ea76b7eb3764d197dd6e3.tar.gz rockbox-32a95751301a4aa5f51ea76b7eb3764d197dd6e3.zip |
FS#7994 - Rename talk.c API, make talk_disable() affect all talking (not just menus), hopefully save some space.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@15206 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r-- | apps/alarm_menu.c | 10 | ||||
-rw-r--r-- | apps/bookmark.c | 2 | ||||
-rw-r--r-- | apps/gui/option_select.c | 2 | ||||
-rw-r--r-- | apps/gui/yesno.c | 4 | ||||
-rw-r--r-- | apps/main.c | 2 | ||||
-rw-r--r-- | apps/menu.c | 2 | ||||
-rw-r--r-- | apps/menus/main_menu.c | 2 | ||||
-rw-r--r-- | apps/misc.c | 2 | ||||
-rw-r--r-- | apps/playback.c | 4 | ||||
-rw-r--r-- | apps/player/keyboard.c | 8 | ||||
-rw-r--r-- | apps/playlist.c | 2 | ||||
-rw-r--r-- | apps/plugin.c | 3 | ||||
-rw-r--r-- | apps/plugin.h | 7 | ||||
-rw-r--r-- | apps/plugins/mpegplayer/mpegplayer.c | 26 | ||||
-rw-r--r-- | apps/recorder/keyboard.c | 20 | ||||
-rw-r--r-- | apps/recorder/recording.c | 6 | ||||
-rw-r--r-- | apps/root_menu.c | 4 | ||||
-rw-r--r-- | apps/screens.c | 4 | ||||
-rw-r--r-- | apps/settings.c | 2 | ||||
-rw-r--r-- | apps/talk.c | 194 | ||||
-rw-r--r-- | apps/talk.h | 21 | ||||
-rw-r--r-- | uisimulator/common/stubs.c | 20 |
22 files changed, 161 insertions, 186 deletions
diff --git a/apps/alarm_menu.c b/apps/alarm_menu.c index 5709c5ad4a..391558a34e 100644 --- a/apps/alarm_menu.c +++ b/apps/alarm_menu.c | |||
@@ -44,7 +44,7 @@ | |||
44 | 44 | ||
45 | static void speak_time(int hours, int minutes, bool speak_hours) | 45 | static void speak_time(int hours, int minutes, bool speak_hours) |
46 | { | 46 | { |
47 | if (talk_menus_enabled()){ | 47 | if (global_settings.talk_menu){ |
48 | if(speak_hours) { | 48 | if(speak_hours) { |
49 | talk_value(hours, UNIT_HOUR, false); | 49 | talk_value(hours, UNIT_HOUR, false); |
50 | talk_value(minutes, UNIT_MIN, true); | 50 | talk_value(minutes, UNIT_MIN, true); |
@@ -86,7 +86,7 @@ bool alarm_screen(void) | |||
86 | screens[i].puts(0, 3, str(LANG_ALARM_MOD_KEYS)); | 86 | screens[i].puts(0, 3, str(LANG_ALARM_MOD_KEYS)); |
87 | } | 87 | } |
88 | /* Talk when entering the wakeup screen */ | 88 | /* Talk when entering the wakeup screen */ |
89 | if (talk_menus_enabled()) | 89 | if (global_settings.talk_menu) |
90 | { | 90 | { |
91 | talk_value(h, UNIT_HOUR, true); | 91 | talk_value(h, UNIT_HOUR, true); |
92 | talk_value(m, UNIT_MIN, true); | 92 | talk_value(m, UNIT_MIN, true); |
@@ -113,7 +113,7 @@ bool alarm_screen(void) | |||
113 | rtc_init(); | 113 | rtc_init(); |
114 | rtc_set_alarm(h,m); | 114 | rtc_set_alarm(h,m); |
115 | rtc_enable_alarm(true); | 115 | rtc_enable_alarm(true); |
116 | if (talk_menus_enabled()) | 116 | if (global_settings.talk_menu) |
117 | { | 117 | { |
118 | talk_id(LANG_ALARM_MOD_TIME_TO_GO, true); | 118 | talk_id(LANG_ALARM_MOD_TIME_TO_GO, true); |
119 | talk_value(togo / 60, UNIT_HOUR, true); | 119 | talk_value(togo / 60, UNIT_HOUR, true); |
@@ -164,7 +164,7 @@ bool alarm_screen(void) | |||
164 | case ACTION_STD_NEXTREPEAT: | 164 | case ACTION_STD_NEXTREPEAT: |
165 | h = (h+1) % 24; | 165 | h = (h+1) % 24; |
166 | 166 | ||
167 | if (talk_menus_enabled()) | 167 | if (global_settings.talk_menu) |
168 | talk_value(h, UNIT_HOUR, false); | 168 | talk_value(h, UNIT_HOUR, false); |
169 | break; | 169 | break; |
170 | 170 | ||
@@ -173,7 +173,7 @@ bool alarm_screen(void) | |||
173 | case ACTION_STD_PREVREPEAT: | 173 | case ACTION_STD_PREVREPEAT: |
174 | h = (h+23) % 24; | 174 | h = (h+23) % 24; |
175 | 175 | ||
176 | if (talk_menus_enabled()) | 176 | if (global_settings.talk_menu) |
177 | talk_value(h, UNIT_HOUR, false); | 177 | talk_value(h, UNIT_HOUR, false); |
178 | break; | 178 | break; |
179 | 179 | ||
diff --git a/apps/bookmark.c b/apps/bookmark.c index 4522859f57..184281ba87 100644 --- a/apps/bookmark.c +++ b/apps/bookmark.c | |||
@@ -667,7 +667,7 @@ static char* select_bookmark(const char* bookmark_file_name, bool show_dont_resu | |||
667 | item--; | 667 | item--; |
668 | } | 668 | } |
669 | 669 | ||
670 | if (item != last_item && talk_menus_enabled()) | 670 | if (item != last_item && global_settings.talk_menu) |
671 | { | 671 | { |
672 | last_item = item; | 672 | last_item = item; |
673 | 673 | ||
diff --git a/apps/gui/option_select.c b/apps/gui/option_select.c index 4f446fc8de..3b26ab12d2 100644 --- a/apps/gui/option_select.c +++ b/apps/gui/option_select.c | |||
@@ -133,7 +133,7 @@ static char *option_get_valuestring(struct settings_list *setting, | |||
133 | 133 | ||
134 | static void option_talk(struct settings_list *setting, int temp_var) | 134 | static void option_talk(struct settings_list *setting, int temp_var) |
135 | { | 135 | { |
136 | if (!talk_menus_enabled()) | 136 | if (!global_settings.talk_menu) |
137 | return; | 137 | return; |
138 | if ((setting->flags & F_BOOL_SETTING) == F_BOOL_SETTING) | 138 | if ((setting->flags & F_BOOL_SETTING) == F_BOOL_SETTING) |
139 | { | 139 | { |
diff --git a/apps/gui/yesno.c b/apps/gui/yesno.c index 7c8afb3245..4e86b017ca 100644 --- a/apps/gui/yesno.c +++ b/apps/gui/yesno.c | |||
@@ -145,7 +145,7 @@ enum yesno_res gui_syncyesno_run(struct text_message * main_message, | |||
145 | while (result==-1) | 145 | while (result==-1) |
146 | { | 146 | { |
147 | /* Repeat the question every 5secs (more or less) */ | 147 | /* Repeat the question every 5secs (more or less) */ |
148 | if (talk_menus_enabled() | 148 | if (global_settings.talk_menu |
149 | && (talked_tick==0 || TIME_AFTER(current_tick, talked_tick+HZ*5))) | 149 | && (talked_tick==0 || TIME_AFTER(current_tick, talked_tick+HZ*5))) |
150 | { | 150 | { |
151 | talked_tick = current_tick; | 151 | talked_tick = current_tick; |
@@ -175,7 +175,7 @@ enum yesno_res gui_syncyesno_run(struct text_message * main_message, | |||
175 | FOR_NB_SCREENS(i) | 175 | FOR_NB_SCREENS(i) |
176 | result_displayed=gui_yesno_draw_result(&(yn[i]), result); | 176 | result_displayed=gui_yesno_draw_result(&(yn[i]), result); |
177 | 177 | ||
178 | if (talk_menus_enabled()) | 178 | if (global_settings.talk_menu) |
179 | { | 179 | { |
180 | talk_idarray(voice_ids, false); | 180 | talk_idarray(voice_ids, false); |
181 | talk_force_enqueue_next(); | 181 | talk_force_enqueue_next(); |
diff --git a/apps/main.c b/apps/main.c index e4fd6bc614..366fed9585 100644 --- a/apps/main.c +++ b/apps/main.c | |||
@@ -225,7 +225,7 @@ static void init_tagcache(void) | |||
225 | /* hwcodec can't use voice here, as the database commit | 225 | /* hwcodec can't use voice here, as the database commit |
226 | * uses the audio buffer. */ | 226 | * uses the audio buffer. */ |
227 | static long talked_tick = 0; | 227 | static long talked_tick = 0; |
228 | if(talk_menus_enabled() | 228 | if(global_settings.talk_menu |
229 | && (talked_tick == 0 | 229 | && (talked_tick == 0 |
230 | || TIME_AFTER(current_tick, talked_tick+7*HZ))) | 230 | || TIME_AFTER(current_tick, talked_tick+7*HZ))) |
231 | { | 231 | { |
diff --git a/apps/menu.c b/apps/menu.c index 1dedc42a5c..55f1938b80 100644 --- a/apps/menu.c +++ b/apps/menu.c | |||
@@ -225,7 +225,7 @@ static void talk_menu_item(const struct menu_item_ex *menu, | |||
225 | unsigned char *str; | 225 | unsigned char *str; |
226 | int sel; | 226 | int sel; |
227 | 227 | ||
228 | if (talk_menus_enabled()) | 228 | if (global_settings.talk_menu) |
229 | { | 229 | { |
230 | sel = get_menu_selection(gui_synclist_get_sel_pos(lists),menu); | 230 | sel = get_menu_selection(gui_synclist_get_sel_pos(lists),menu); |
231 | if ((menu->flags&MENU_TYPE_MASK) == MT_MENU) | 231 | if ((menu->flags&MENU_TYPE_MASK) == MT_MENU) |
diff --git a/apps/menus/main_menu.c b/apps/menus/main_menu.c index 2e9d0d08d9..1940c14511 100644 --- a/apps/menus/main_menu.c +++ b/apps/menus/main_menu.c | |||
@@ -161,7 +161,7 @@ static bool show_info(void) | |||
161 | size2 = 0; | 161 | size2 = 0; |
162 | #endif | 162 | #endif |
163 | 163 | ||
164 | if (talk_menus_enabled()) | 164 | if (global_settings.talk_menu) |
165 | { | 165 | { |
166 | /* say whatever is reasonable, no real connection to the screen */ | 166 | /* say whatever is reasonable, no real connection to the screen */ |
167 | bool enqueue = false; /* enqueue all but the first */ | 167 | bool enqueue = false; /* enqueue all but the first */ |
diff --git a/apps/misc.c b/apps/misc.c index 3a47d2f1c9..3c6ffd3032 100644 --- a/apps/misc.c +++ b/apps/misc.c | |||
@@ -685,7 +685,7 @@ static bool clean_shutdown(void (*callback)(void *), void *parameter) | |||
685 | audio_close_recording(); | 685 | audio_close_recording(); |
686 | #endif | 686 | #endif |
687 | 687 | ||
688 | if(talk_menus_enabled()) | 688 | if(global_settings.talk_menu) |
689 | { | 689 | { |
690 | bool enqueue = false; | 690 | bool enqueue = false; |
691 | if(msg_id != -1) | 691 | if(msg_id != -1) |
diff --git a/apps/playback.c b/apps/playback.c index c0a8c5ade0..5443ef5b24 100644 --- a/apps/playback.c +++ b/apps/playback.c | |||
@@ -677,7 +677,7 @@ void audio_play(long offset) | |||
677 | #ifdef PLAYBACK_VOICE | 677 | #ifdef PLAYBACK_VOICE |
678 | /* Truncate any existing voice output so we don't have spelling | 678 | /* Truncate any existing voice output so we don't have spelling |
679 | * etc. over the first part of the played track */ | 679 | * etc. over the first part of the played track */ |
680 | do_shutup(); | 680 | talk_force_shutup(); |
681 | #endif | 681 | #endif |
682 | 682 | ||
683 | /* Start playback */ | 683 | /* Start playback */ |
@@ -960,7 +960,7 @@ static void voice_stop(void) | |||
960 | if (!voice_codec_loaded) | 960 | if (!voice_codec_loaded) |
961 | return; | 961 | return; |
962 | 962 | ||
963 | do_shutup(); | 963 | talk_force_shutup(); |
964 | 964 | ||
965 | /* Loop until voice empties it's queue, stops and picks up on the new | 965 | /* Loop until voice empties it's queue, stops and picks up on the new |
966 | track; the voice thread must be stopped and waiting for messages | 966 | track; the voice thread must be stopped and waiting for messages |
diff --git a/apps/player/keyboard.c b/apps/player/keyboard.c index c89161c8ca..dad8fc0f55 100644 --- a/apps/player/keyboard.c +++ b/apps/player/keyboard.c | |||
@@ -74,7 +74,7 @@ static unsigned short *kbd_setupkeys(int page, int* len) | |||
74 | /* helper function to spell a char if voice UI is enabled */ | 74 | /* helper function to spell a char if voice UI is enabled */ |
75 | static void kbd_spellchar(char c) | 75 | static void kbd_spellchar(char c) |
76 | { | 76 | { |
77 | if (talk_menus_enabled()) /* voice UI? */ | 77 | if (global_settings.talk_menu) /* voice UI? */ |
78 | { | 78 | { |
79 | unsigned char tmp[5]; | 79 | unsigned char tmp[5]; |
80 | /* store char to pass to talk_spell */ | 80 | /* store char to pass to talk_spell */ |
@@ -90,7 +90,7 @@ static void kbd_spellchar(char c) | |||
90 | 90 | ||
91 | static void say_edit(void) | 91 | static void say_edit(void) |
92 | { | 92 | { |
93 | if (talk_menus_enabled()) | 93 | if (global_settings.talk_menu) |
94 | talk_id(VOICE_EDIT, false); | 94 | talk_id(VOICE_EDIT, false); |
95 | } | 95 | } |
96 | 96 | ||
@@ -112,7 +112,7 @@ int kbd_input(char* text, int buflen) | |||
112 | 112 | ||
113 | editpos = utf8length(text); | 113 | editpos = utf8length(text); |
114 | 114 | ||
115 | if (talk_menus_enabled()) /* voice UI? */ | 115 | if (global_settings.talk_menu) /* voice UI? */ |
116 | talk_spell(text, true); /* spell initial text */ | 116 | talk_spell(text, true); /* spell initial text */ |
117 | 117 | ||
118 | while (!done) | 118 | while (!done) |
@@ -284,7 +284,7 @@ int kbd_input(char* text, int buflen) | |||
284 | editpos++; | 284 | editpos++; |
285 | } | 285 | } |
286 | } | 286 | } |
287 | if (talk_menus_enabled()) /* voice UI? */ | 287 | if (global_settings.talk_menu) /* voice UI? */ |
288 | talk_spell(text, false); /* speak revised text */ | 288 | talk_spell(text, false); /* speak revised text */ |
289 | break; | 289 | break; |
290 | 290 | ||
diff --git a/apps/playlist.c b/apps/playlist.c index 025e07d8a7..ad60c84d38 100644 --- a/apps/playlist.c +++ b/apps/playlist.c | |||
@@ -1664,7 +1664,7 @@ static void display_playlist_count(int count, const unsigned char *fmt, | |||
1664 | { | 1664 | { |
1665 | static long talked_tick = 0; | 1665 | static long talked_tick = 0; |
1666 | long id = P2ID(fmt); | 1666 | long id = P2ID(fmt); |
1667 | if(talk_menus_enabled() && id>=0) | 1667 | if(global_settings.talk_menu && id>=0) |
1668 | { | 1668 | { |
1669 | if(final || (count && (talked_tick == 0 | 1669 | if(final || (count && (talked_tick == 0 |
1670 | || TIME_AFTER(current_tick, talked_tick+5*HZ)))) | 1670 | || TIME_AFTER(current_tick, talked_tick+5*HZ)))) |
diff --git a/apps/plugin.c b/apps/plugin.c index c06ae257e4..bbb6d6feb2 100644 --- a/apps/plugin.c +++ b/apps/plugin.c | |||
@@ -468,8 +468,7 @@ static const struct plugin_api rockbox_api = { | |||
468 | #endif | 468 | #endif |
469 | &global_settings, | 469 | &global_settings, |
470 | &global_status, | 470 | &global_status, |
471 | talk_disable_menus, | 471 | talk_disable, |
472 | talk_enable_menus, | ||
473 | #if CONFIG_CODEC == SWCODEC | 472 | #if CONFIG_CODEC == SWCODEC |
474 | codec_load_file, | 473 | codec_load_file, |
475 | get_codec_filename, | 474 | get_codec_filename, |
diff --git a/apps/plugin.h b/apps/plugin.h index e36c99c5fd..ee58687bf0 100644 --- a/apps/plugin.h +++ b/apps/plugin.h | |||
@@ -112,12 +112,12 @@ | |||
112 | #define PLUGIN_MAGIC 0x526F634B /* RocK */ | 112 | #define PLUGIN_MAGIC 0x526F634B /* RocK */ |
113 | 113 | ||
114 | /* increase this every time the api struct changes */ | 114 | /* increase this every time the api struct changes */ |
115 | #define PLUGIN_API_VERSION 83 | 115 | #define PLUGIN_API_VERSION 84 |
116 | 116 | ||
117 | /* update this to latest version if a change to the api struct breaks | 117 | /* update this to latest version if a change to the api struct breaks |
118 | backwards compatibility (and please take the opportunity to sort in any | 118 | backwards compatibility (and please take the opportunity to sort in any |
119 | new function which are "waiting" at the end of the function table) */ | 119 | new function which are "waiting" at the end of the function table) */ |
120 | #define PLUGIN_MIN_API_VERSION 83 | 120 | #define PLUGIN_MIN_API_VERSION 84 |
121 | 121 | ||
122 | /* plugin return codes */ | 122 | /* plugin return codes */ |
123 | enum plugin_status { | 123 | enum plugin_status { |
@@ -579,8 +579,7 @@ struct plugin_api { | |||
579 | #endif | 579 | #endif |
580 | struct user_settings* global_settings; | 580 | struct user_settings* global_settings; |
581 | struct system_status *global_status; | 581 | struct system_status *global_status; |
582 | void (*talk_disable_menus)(void); | 582 | void (*talk_disable)(bool disable); |
583 | void (*talk_enable_menus)(void); | ||
584 | #if CONFIG_CODEC == SWCODEC | 583 | #if CONFIG_CODEC == SWCODEC |
585 | int (*codec_load_file)(const char* codec, struct codec_api *api); | 584 | int (*codec_load_file)(const char* codec, struct codec_api *api); |
586 | const char *(*get_codec_filename)(int cod_spec); | 585 | const char *(*get_codec_filename)(int cod_spec); |
diff --git a/apps/plugins/mpegplayer/mpegplayer.c b/apps/plugins/mpegplayer/mpegplayer.c index 8b6d1e20bd..37ac1fa78c 100644 --- a/apps/plugins/mpegplayer/mpegplayer.c +++ b/apps/plugins/mpegplayer/mpegplayer.c | |||
@@ -1170,7 +1170,7 @@ static int button_loop(void) | |||
1170 | str_send_msg(&video_str, STREAM_QUIT, 0); | 1170 | str_send_msg(&video_str, STREAM_QUIT, 0); |
1171 | audio_str.status = STREAM_STOPPED; | 1171 | audio_str.status = STREAM_STOPPED; |
1172 | } | 1172 | } |
1173 | } | 1173 | } |
1174 | } | 1174 | } |
1175 | quit: | 1175 | quit: |
1176 | return audio_str.status; | 1176 | return audio_str.status; |
@@ -2227,6 +2227,7 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter) | |||
2227 | api->splash(HZ*2, "No File"); | 2227 | api->splash(HZ*2, "No File"); |
2228 | return PLUGIN_ERROR; | 2228 | return PLUGIN_ERROR; |
2229 | } | 2229 | } |
2230 | api->talk_disable(true); | ||
2230 | 2231 | ||
2231 | /* Initialize IRAM - stops audio and voice as well */ | 2232 | /* Initialize IRAM - stops audio and voice as well */ |
2232 | PLUGIN_IRAM_INIT(api) | 2233 | PLUGIN_IRAM_INIT(api) |
@@ -2253,6 +2254,7 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter) | |||
2253 | audiosize -= graysize; | 2254 | audiosize -= graysize; |
2254 | if (grayscales < 33 || audiosize <= 0) | 2255 | if (grayscales < 33 || audiosize <= 0) |
2255 | { | 2256 | { |
2257 | rb->talk_disable(false); | ||
2256 | rb->splash(HZ, "gray buf error"); | 2258 | rb->splash(HZ, "gray buf error"); |
2257 | return PLUGIN_ERROR; | 2259 | return PLUGIN_ERROR; |
2258 | } | 2260 | } |
@@ -2261,7 +2263,10 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter) | |||
2261 | /* Initialise our malloc buffer */ | 2263 | /* Initialise our malloc buffer */ |
2262 | audiosize = mpeg_alloc_init(audiobuf,audiosize, LIBMPEG2BUFFER_SIZE); | 2264 | audiosize = mpeg_alloc_init(audiobuf,audiosize, LIBMPEG2BUFFER_SIZE); |
2263 | if (audiosize == 0) | 2265 | if (audiosize == 0) |
2266 | { | ||
2267 | rb->talk_disable(false); | ||
2264 | return PLUGIN_ERROR; | 2268 | return PLUGIN_ERROR; |
2269 | } | ||
2265 | 2270 | ||
2266 | /* Set disk pointers to NULL */ | 2271 | /* Set disk pointers to NULL */ |
2267 | disk_buf_end = disk_buf_start = NULL; | 2272 | disk_buf_end = disk_buf_start = NULL; |
@@ -2275,13 +2280,21 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter) | |||
2275 | disk_buf_start = mpeg_malloc(disk_buf_size,-1); | 2280 | disk_buf_start = mpeg_malloc(disk_buf_size,-1); |
2276 | 2281 | ||
2277 | if (disk_buf_start == NULL) | 2282 | if (disk_buf_start == NULL) |
2283 | { | ||
2284 | rb->talk_disable(false); | ||
2278 | return PLUGIN_ERROR; | 2285 | return PLUGIN_ERROR; |
2286 | } | ||
2279 | 2287 | ||
2280 | if (!init_mpabuf()) | 2288 | if (!init_mpabuf()) |
2289 | { | ||
2290 | rb->talk_disable(false); | ||
2281 | return PLUGIN_ERROR; | 2291 | return PLUGIN_ERROR; |
2282 | 2292 | } | |
2283 | if (!init_pcmbuf()) | 2293 | if (!init_pcmbuf()) |
2294 | { | ||
2295 | rb->talk_disable(false); | ||
2284 | return PLUGIN_ERROR; | 2296 | return PLUGIN_ERROR; |
2297 | } | ||
2285 | 2298 | ||
2286 | /* The remaining buffer is for use by libmpeg2 */ | 2299 | /* The remaining buffer is for use by libmpeg2 */ |
2287 | 2300 | ||
@@ -2290,6 +2303,7 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter) | |||
2290 | 2303 | ||
2291 | if (in_file < 0){ | 2304 | if (in_file < 0){ |
2292 | DEBUGF("Could not open %s\n",(char*)parameter); | 2305 | DEBUGF("Could not open %s\n",(char*)parameter); |
2306 | rb->talk_disable(false); | ||
2293 | return PLUGIN_ERROR; | 2307 | return PLUGIN_ERROR; |
2294 | } | 2308 | } |
2295 | filename = (char*)parameter; | 2309 | filename = (char*)parameter; |
@@ -2322,6 +2336,7 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter) | |||
2322 | switch (result) | 2336 | switch (result) |
2323 | { | 2337 | { |
2324 | case MPEG_START_QUIT: | 2338 | case MPEG_START_QUIT: |
2339 | rb->talk_disable(false); | ||
2325 | return 0; | 2340 | return 0; |
2326 | default: | 2341 | default: |
2327 | start_time = settings.resume_time; | 2342 | start_time = settings.resume_time; |
@@ -2336,7 +2351,6 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter) | |||
2336 | 2351 | ||
2337 | /* Turn off backlight timeout */ | 2352 | /* Turn off backlight timeout */ |
2338 | backlight_force_on(rb); /* backlight control in lib/helper.c */ | 2353 | backlight_force_on(rb); /* backlight control in lib/helper.c */ |
2339 | rb->talk_disable_menus(); | ||
2340 | 2354 | ||
2341 | #ifdef HAVE_ADJUSTABLE_CPU_FREQ | 2355 | #ifdef HAVE_ADJUSTABLE_CPU_FREQ |
2342 | rb->cpu_boost(true); | 2356 | rb->cpu_boost(true); |
@@ -2463,8 +2477,7 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter) | |||
2463 | n = rb->read(in_file, disk_buf_tail,bytes_to_read); | 2477 | n = rb->read(in_file, disk_buf_tail,bytes_to_read); |
2464 | if (n==0) | 2478 | if (n==0) |
2465 | rb->splash(30,"buffer fill error"); | 2479 | rb->splash(30,"buffer fill error"); |
2466 | } | 2480 | } |
2467 | |||
2468 | 2481 | ||
2469 | bytes_to_read -= n; | 2482 | bytes_to_read -= n; |
2470 | file_remaining -= n; | 2483 | file_remaining -= n; |
@@ -2531,7 +2544,6 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter) | |||
2531 | 2544 | ||
2532 | /* Turn on backlight timeout (revert to settings) */ | 2545 | /* Turn on backlight timeout (revert to settings) */ |
2533 | backlight_use_settings(rb); /* backlight control in lib/helper.c */ | 2546 | backlight_use_settings(rb); /* backlight control in lib/helper.c */ |
2534 | rb->talk_enable_menus(); | 2547 | rb->talk_disable(false); |
2535 | |||
2536 | return status; | 2548 | return status; |
2537 | } | 2549 | } |
diff --git a/apps/recorder/keyboard.c b/apps/recorder/keyboard.c index 9c35f288ff..6c75d07a65 100644 --- a/apps/recorder/keyboard.c +++ b/apps/recorder/keyboard.c | |||
@@ -191,7 +191,7 @@ int load_kbd(unsigned char* filename) | |||
191 | /* helper function to spell a char if voice UI is enabled */ | 191 | /* helper function to spell a char if voice UI is enabled */ |
192 | static void kbd_spellchar(unsigned short c) | 192 | static void kbd_spellchar(unsigned short c) |
193 | { | 193 | { |
194 | if (talk_menus_enabled()) /* voice UI? */ | 194 | if (global_settings.talk_menu) /* voice UI? */ |
195 | { | 195 | { |
196 | unsigned char tmp[5]; | 196 | unsigned char tmp[5]; |
197 | /* store char to pass to talk_spell */ | 197 | /* store char to pass to talk_spell */ |
@@ -208,7 +208,7 @@ static void kbd_spellchar(unsigned short c) | |||
208 | #ifdef KBD_MODES | 208 | #ifdef KBD_MODES |
209 | static void say_edit(void) | 209 | static void say_edit(void) |
210 | { | 210 | { |
211 | if(talk_menus_enabled()) | 211 | if(global_settings.talk_menu) |
212 | talk_id(VOICE_EDIT, false); | 212 | talk_id(VOICE_EDIT, false); |
213 | } | 213 | } |
214 | #endif | 214 | #endif |
@@ -527,7 +527,7 @@ int kbd_input(char* text, int buflen) | |||
527 | /* Initial edit position is after last character */ | 527 | /* Initial edit position is after last character */ |
528 | editpos = utf8length(text); | 528 | editpos = utf8length(text); |
529 | 529 | ||
530 | if (talk_menus_enabled()) /* voice UI? */ | 530 | if (global_settings.talk_menu) /* voice UI? */ |
531 | talk_spell(text, true); /* spell initial text */ | 531 | talk_spell(text, true); /* spell initial text */ |
532 | 532 | ||
533 | 533 | ||
@@ -832,7 +832,7 @@ int kbd_input(char* text, int buflen) | |||
832 | kbd_spellchar(text[c]); | 832 | kbd_spellchar(text[c]); |
833 | } | 833 | } |
834 | #if CONFIG_CODEC == SWCODEC | 834 | #if CONFIG_CODEC == SWCODEC |
835 | else if (talk_menus_enabled()) | 835 | else if (global_settings.talk_menu) |
836 | pcmbuf_beep(1000, 150, 1500); | 836 | pcmbuf_beep(1000, 150, 1500); |
837 | #endif | 837 | #endif |
838 | } | 838 | } |
@@ -877,7 +877,7 @@ int kbd_input(char* text, int buflen) | |||
877 | kbd_spellchar(text[c]); | 877 | kbd_spellchar(text[c]); |
878 | } | 878 | } |
879 | #if CONFIG_CODEC == SWCODEC | 879 | #if CONFIG_CODEC == SWCODEC |
880 | else if (talk_menus_enabled()) | 880 | else if (global_settings.talk_menu) |
881 | pcmbuf_beep(1000, 150, 1500); | 881 | pcmbuf_beep(1000, 150, 1500); |
882 | #endif | 882 | #endif |
883 | } | 883 | } |
@@ -1124,7 +1124,7 @@ int kbd_input(char* text, int buflen) | |||
1124 | kbd_inschar(text, buflen, &editpos, ch); | 1124 | kbd_inschar(text, buflen, &editpos, ch); |
1125 | } | 1125 | } |
1126 | 1126 | ||
1127 | if (talk_menus_enabled()) /* voice UI? */ | 1127 | if (global_settings.talk_menu) /* voice UI? */ |
1128 | talk_spell(text, false); | 1128 | talk_spell(text, false); |
1129 | 1129 | ||
1130 | /* speak revised text */ | 1130 | /* speak revised text */ |
@@ -1153,7 +1153,7 @@ int kbd_input(char* text, int buflen) | |||
1153 | kbd_inschar(text, buflen, &editpos, ch); | 1153 | kbd_inschar(text, buflen, &editpos, ch); |
1154 | } | 1154 | } |
1155 | 1155 | ||
1156 | if (talk_menus_enabled()) /* voice UI? */ | 1156 | if (global_settings.talk_menu) /* voice UI? */ |
1157 | talk_spell(text, false); /* speak revised text */ | 1157 | talk_spell(text, false); /* speak revised text */ |
1158 | break; | 1158 | break; |
1159 | 1159 | ||
@@ -1166,7 +1166,7 @@ int kbd_input(char* text, int buflen) | |||
1166 | kbd_spellchar(text[c]); | 1166 | kbd_spellchar(text[c]); |
1167 | } | 1167 | } |
1168 | #if CONFIG_CODEC == SWCODEC | 1168 | #if CONFIG_CODEC == SWCODEC |
1169 | else if (talk_menus_enabled()) | 1169 | else if (global_settings.talk_menu) |
1170 | pcmbuf_beep(1000, 150, 1500); | 1170 | pcmbuf_beep(1000, 150, 1500); |
1171 | #endif | 1171 | #endif |
1172 | break; | 1172 | break; |
@@ -1180,7 +1180,7 @@ int kbd_input(char* text, int buflen) | |||
1180 | kbd_spellchar(text[c]); | 1180 | kbd_spellchar(text[c]); |
1181 | } | 1181 | } |
1182 | #if CONFIG_CODEC == SWCODEC | 1182 | #if CONFIG_CODEC == SWCODEC |
1183 | else if (talk_menus_enabled()) | 1183 | else if (global_settings.talk_menu) |
1184 | pcmbuf_beep(1000, 150, 1500); | 1184 | pcmbuf_beep(1000, 150, 1500); |
1185 | #endif | 1185 | #endif |
1186 | break; | 1186 | break; |
@@ -1212,7 +1212,7 @@ int kbd_input(char* text, int buflen) | |||
1212 | param[l].hangul = false; | 1212 | param[l].hangul = false; |
1213 | kbd_inschar(text, buflen, &editpos, morse_alphabets[j]); | 1213 | kbd_inschar(text, buflen, &editpos, morse_alphabets[j]); |
1214 | 1214 | ||
1215 | if (talk_menus_enabled()) /* voice UI? */ | 1215 | if (global_settings.talk_menu) /* voice UI? */ |
1216 | talk_spell(text, false); /* speak revised text */ | 1216 | talk_spell(text, false); /* speak revised text */ |
1217 | } | 1217 | } |
1218 | #endif /* KBD_MORSE_INPUT */ | 1218 | #endif /* KBD_MORSE_INPUT */ |
diff --git a/apps/recorder/recording.c b/apps/recorder/recording.c index 3b706e1a6d..84207c77ab 100644 --- a/apps/recorder/recording.c +++ b/apps/recorder/recording.c | |||
@@ -889,7 +889,7 @@ bool recording_screen(bool no_source) | |||
889 | 889 | ||
890 | #if CONFIG_CODEC == SWCODEC | 890 | #if CONFIG_CODEC == SWCODEC |
891 | /* recording_menu gets messed up: so prevent manus talking */ | 891 | /* recording_menu gets messed up: so prevent manus talking */ |
892 | talk_disable_menus(); | 892 | talk_disable(true); |
893 | /* audio_init_recording stops anything playing when it takes the audio | 893 | /* audio_init_recording stops anything playing when it takes the audio |
894 | buffer */ | 894 | buffer */ |
895 | #else | 895 | #else |
@@ -1873,8 +1873,8 @@ bool recording_screen(bool no_source) | |||
1873 | /* Go back to playback mode */ | 1873 | /* Go back to playback mode */ |
1874 | rec_set_source(AUDIO_SRC_PLAYBACK, SRCF_PLAYBACK); | 1874 | rec_set_source(AUDIO_SRC_PLAYBACK, SRCF_PLAYBACK); |
1875 | 1875 | ||
1876 | /* restore talk_menu setting */ | 1876 | /* restore talking */ |
1877 | talk_enable_menus(); | 1877 | talk_disable(false); |
1878 | #else /* !SWCODEC */ | 1878 | #else /* !SWCODEC */ |
1879 | audio_init_playback(); | 1879 | audio_init_playback(); |
1880 | #endif /* CONFIG_CODEC == SWCODEC */ | 1880 | #endif /* CONFIG_CODEC == SWCODEC */ |
diff --git a/apps/root_menu.c b/apps/root_menu.c index 1c6c868bfc..5acaabeec6 100644 --- a/apps/root_menu.c +++ b/apps/root_menu.c | |||
@@ -160,7 +160,7 @@ static int browser(void* param) | |||
160 | 160 | ||
161 | /* Display building progress */ | 161 | /* Display building progress */ |
162 | static long talked_tick = 0; | 162 | static long talked_tick = 0; |
163 | if(talk_menus_enabled() && | 163 | if(global_settings.talk_menu && |
164 | (talked_tick == 0 | 164 | (talked_tick == 0 |
165 | || TIME_AFTER(current_tick, talked_tick+7*HZ))) | 165 | || TIME_AFTER(current_tick, talked_tick+7*HZ))) |
166 | { | 166 | { |
@@ -238,7 +238,7 @@ static int wpsscrn(void* param) | |||
238 | (void)param; | 238 | (void)param; |
239 | if (audio_status()) | 239 | if (audio_status()) |
240 | { | 240 | { |
241 | shutup(); | 241 | talk_shutup(); |
242 | ret_val = gui_wps_show(); | 242 | ret_val = gui_wps_show(); |
243 | } | 243 | } |
244 | else if ( global_status.resume_index != -1 ) | 244 | else if ( global_status.resume_index != -1 ) |
diff --git a/apps/screens.c b/apps/screens.c index ce62911624..8cdacd706f 100644 --- a/apps/screens.c +++ b/apps/screens.c | |||
@@ -158,7 +158,7 @@ int mmc_remove_request(void) | |||
158 | FOR_NB_SCREENS(i) | 158 | FOR_NB_SCREENS(i) |
159 | screens[i].clear_display(); | 159 | screens[i].clear_display(); |
160 | gui_syncsplash(1, str(LANG_REMOVE_MMC)); | 160 | gui_syncsplash(1, str(LANG_REMOVE_MMC)); |
161 | if (talk_menus_enabled()) | 161 | if (global_settings.talk_menu) |
162 | talk_id(LANG_REMOVE_MMC, false); | 162 | talk_id(LANG_REMOVE_MMC, false); |
163 | 163 | ||
164 | while (1) | 164 | while (1) |
@@ -822,7 +822,7 @@ static void say_time(int cursorpos, const struct tm *tm) | |||
822 | static const int unit[] = { UNIT_HOUR, UNIT_MIN, UNIT_SEC, 0, 0, 0 }; | 822 | static const int unit[] = { UNIT_HOUR, UNIT_MIN, UNIT_SEC, 0, 0, 0 }; |
823 | int value = 0; | 823 | int value = 0; |
824 | 824 | ||
825 | if (!talk_menus_enabled()) | 825 | if (!global_settings.talk_menu) |
826 | return; | 826 | return; |
827 | 827 | ||
828 | switch(cursorpos) | 828 | switch(cursorpos) |
diff --git a/apps/settings.c b/apps/settings.c index 6656b84552..add2b24c75 100644 --- a/apps/settings.c +++ b/apps/settings.c | |||
@@ -949,7 +949,7 @@ const struct settings_list* find_setting(void* variable, int *id) | |||
949 | void talk_setting(void *global_settings_variable) | 949 | void talk_setting(void *global_settings_variable) |
950 | { | 950 | { |
951 | const struct settings_list *setting; | 951 | const struct settings_list *setting; |
952 | if (!talk_menus_enabled()) | 952 | if (!global_settings.talk_menu) |
953 | return; | 953 | return; |
954 | setting = find_setting(global_settings_variable, NULL); | 954 | setting = find_setting(global_settings_variable, NULL); |
955 | if (setting == NULL) | 955 | if (setting == NULL) |
diff --git a/apps/talk.c b/apps/talk.c index 47410121ba..ede0aff66b 100644 --- a/apps/talk.c +++ b/apps/talk.c | |||
@@ -80,10 +80,6 @@ const char* const file_thumbnail_ext = ".talk"; | |||
80 | #define MAX_THUMBNAIL_BUFSIZE 0x10000 | 80 | #define MAX_THUMBNAIL_BUFSIZE 0x10000 |
81 | #endif | 81 | #endif |
82 | 82 | ||
83 | #ifndef SIMULATOR | ||
84 | extern bool audio_is_initialized; | ||
85 | #endif | ||
86 | |||
87 | /***************** Data types *****************/ | 83 | /***************** Data types *****************/ |
88 | 84 | ||
89 | struct clip_entry /* one entry of the index table */ | 85 | struct clip_entry /* one entry of the index table */ |
@@ -118,8 +114,7 @@ static long size_for_thumbnail; /* leftover buffer size for it */ | |||
118 | static struct voicefile* p_voicefile; /* loaded voicefile */ | 114 | static struct voicefile* p_voicefile; /* loaded voicefile */ |
119 | static bool has_voicefile; /* a voicefile file is present */ | 115 | static bool has_voicefile; /* a voicefile file is present */ |
120 | static struct queue_entry queue[QUEUE_SIZE]; /* queue of scheduled clips */ | 116 | static struct queue_entry queue[QUEUE_SIZE]; /* queue of scheduled clips */ |
121 | /* enqueue next utterance even if enqueue is false. */ | 117 | static bool force_enqueue_next; /* enqueue next utterance even if enqueue is false */ |
122 | static bool force_enqueue_next; | ||
123 | static int queue_write; /* write index of queue, by application */ | 118 | static int queue_write; /* write index of queue, by application */ |
124 | static int queue_read; /* read index of queue, by ISR context */ | 119 | static int queue_read; /* read index of queue, by ISR context */ |
125 | static int sent; /* how many bytes handed over to playback, owned by ISR */ | 120 | static int sent; /* how many bytes handed over to playback, owned by ISR */ |
@@ -131,16 +126,8 @@ static unsigned char* p_lastclip; /* address of latest clip, for silence add */ | |||
131 | static unsigned long voicefile_size = 0; /* size of the loaded voice file */ | 126 | static unsigned long voicefile_size = 0; /* size of the loaded voice file */ |
132 | static unsigned char last_lang[MAX_FILENAME+1]; /* name of last used lang file (in talk_init) */ | 127 | static unsigned char last_lang[MAX_FILENAME+1]; /* name of last used lang file (in talk_init) */ |
133 | static bool talk_initialized; /* true if talk_init has been called */ | 128 | static bool talk_initialized; /* true if talk_init has been called */ |
134 | static int talk_menu_disable; /* if non-zero, temporarily disable voice UI (not saved) */ | 129 | static int talk_temp_disable_count; /* if positive, temporarily disable voice UI (not saved) */ |
135 | 130 | ||
136 | /***************** Private prototypes *****************/ | ||
137 | |||
138 | static void load_voicefile(void); | ||
139 | static void mp3_callback(unsigned char** start, size_t* size); | ||
140 | static int queue_clip(unsigned char* buf, long size, bool enqueue); | ||
141 | static int open_voicefile(void); | ||
142 | static unsigned char* get_clip(long id, long* p_size); | ||
143 | int shutup(void); /* Interrupt voice, as when enqueue is false */ | ||
144 | 131 | ||
145 | /***************** Private implementation *****************/ | 132 | /***************** Private implementation *****************/ |
146 | 133 | ||
@@ -161,6 +148,50 @@ static int open_voicefile(void) | |||
161 | } | 148 | } |
162 | 149 | ||
163 | 150 | ||
151 | /* fetch a clip from the voice file */ | ||
152 | static unsigned char* get_clip(long id, long* p_size) | ||
153 | { | ||
154 | long clipsize; | ||
155 | unsigned char* clipbuf; | ||
156 | |||
157 | if (id > VOICEONLY_DELIMITER) | ||
158 | { /* voice-only entries use the second part of the table */ | ||
159 | id -= VOICEONLY_DELIMITER + 1; | ||
160 | if (id >= p_voicefile->id2_max) | ||
161 | return NULL; /* must be newer than we have */ | ||
162 | id += p_voicefile->id1_max; /* table 2 is behind table 1 */ | ||
163 | } | ||
164 | else | ||
165 | { /* normal use of the first table */ | ||
166 | if (id >= p_voicefile->id1_max) | ||
167 | return NULL; /* must be newer than we have */ | ||
168 | } | ||
169 | |||
170 | clipsize = p_voicefile->index[id].size; | ||
171 | if (clipsize == 0) /* clip not included in voicefile */ | ||
172 | return NULL; | ||
173 | clipbuf = (unsigned char *) p_voicefile + p_voicefile->index[id].offset; | ||
174 | |||
175 | #ifdef HAVE_MMC /* dynamic loading, on demand */ | ||
176 | if (!(clipsize & LOADED_MASK)) | ||
177 | { /* clip used for the first time, needs loading */ | ||
178 | lseek(filehandle, p_voicefile->index[id].offset, SEEK_SET); | ||
179 | if (read(filehandle, clipbuf, clipsize) != clipsize) | ||
180 | return NULL; /* read error */ | ||
181 | |||
182 | p_voicefile->index[id].size |= LOADED_MASK; /* mark as loaded */ | ||
183 | } | ||
184 | else | ||
185 | { /* clip is in memory already */ | ||
186 | clipsize &= ~LOADED_MASK; /* without the extra bit gives true size */ | ||
187 | } | ||
188 | #endif | ||
189 | |||
190 | *p_size = clipsize; | ||
191 | return clipbuf; | ||
192 | } | ||
193 | |||
194 | |||
164 | /* load the voice file into the mp3 buffer */ | 195 | /* load the voice file into the mp3 buffer */ |
165 | static void load_voicefile(void) | 196 | static void load_voicefile(void) |
166 | { | 197 | { |
@@ -252,7 +283,7 @@ load_err: | |||
252 | /* Are more voice clips queued and waiting? */ | 283 | /* Are more voice clips queued and waiting? */ |
253 | bool is_voice_queued() | 284 | bool is_voice_queued() |
254 | { | 285 | { |
255 | return !!QUEUE_LEVEL; | 286 | return (QUEUE_LEVEL != 0); |
256 | } | 287 | } |
257 | 288 | ||
258 | 289 | ||
@@ -280,7 +311,7 @@ static void mp3_callback(unsigned char** start, size_t* size) | |||
280 | 311 | ||
281 | re_check: | 312 | re_check: |
282 | 313 | ||
283 | if (QUEUE_LEVEL) /* queue is not empty? */ | 314 | if (QUEUE_LEVEL != 0) /* queue is not empty? */ |
284 | { /* start next clip */ | 315 | { /* start next clip */ |
285 | #if CONFIG_CODEC != SWCODEC | 316 | #if CONFIG_CODEC != SWCODEC |
286 | sent = MIN(queue[queue_read].len, 0xFFFF); | 317 | sent = MIN(queue[queue_read].len, 0xFFFF); |
@@ -309,26 +340,22 @@ re_check: | |||
309 | } | 340 | } |
310 | } | 341 | } |
311 | 342 | ||
343 | /***************** Public routines *****************/ | ||
344 | |||
312 | /* stop the playback and the pending clips */ | 345 | /* stop the playback and the pending clips */ |
313 | int do_shutup(void) | 346 | void talk_force_shutup(void) |
314 | { | 347 | { |
348 | /* Most of this is MAS only */ | ||
315 | #if CONFIG_CODEC != SWCODEC | 349 | #if CONFIG_CODEC != SWCODEC |
316 | unsigned char* pos; | 350 | unsigned char* pos; |
317 | unsigned char* search; | 351 | unsigned char* search; |
318 | unsigned char* end; | 352 | unsigned char* end; |
319 | #endif | ||
320 | |||
321 | if (QUEUE_LEVEL == 0) /* has ended anyway */ | 353 | if (QUEUE_LEVEL == 0) /* has ended anyway */ |
322 | { | 354 | return; |
323 | #if CONFIG_CODEC == SWCODEC | 355 | |
324 | mp3_play_stop(); | ||
325 | #endif | ||
326 | return 0; | ||
327 | } | ||
328 | #if CONFIG_CODEC != SWCODEC | ||
329 | #if CONFIG_CPU == SH7034 | 356 | #if CONFIG_CPU == SH7034 |
330 | CHCR3 &= ~0x0001; /* disable the DMA (and therefore the interrupt also) */ | 357 | CHCR3 &= ~0x0001; /* disable the DMA (and therefore the interrupt also) */ |
331 | #endif | 358 | #endif /* CONFIG_CPU == SH7034 */ |
332 | /* search next frame boundary and continue up to there */ | 359 | /* search next frame boundary and continue up to there */ |
333 | pos = search = mp3_get_pos(); | 360 | pos = search = mp3_get_pos(); |
334 | end = queue[queue_read].buf + queue[queue_read].len; | 361 | end = queue[queue_read].buf + queue[queue_read].len; |
@@ -362,41 +389,38 @@ int do_shutup(void) | |||
362 | #if CONFIG_CPU == SH7034 | 389 | #if CONFIG_CPU == SH7034 |
363 | DTCR3 = sent; /* let the DMA finish this frame */ | 390 | DTCR3 = sent; /* let the DMA finish this frame */ |
364 | CHCR3 |= 0x0001; /* re-enable DMA */ | 391 | CHCR3 |= 0x0001; /* re-enable DMA */ |
365 | #endif | 392 | #endif /* CONFIG_CPU == SH7034 */ |
366 | return 0; | 393 | return; |
367 | } | 394 | } |
368 | } | 395 | } |
369 | #endif | 396 | #endif /* CONFIG_CODEC != SWCODEC */ |
370 | 397 | ||
371 | /* nothing to do, was frame boundary or not our clip */ | 398 | /* Either SWCODEC, or MAS had nothing to do (was frame boundary or not our clip) */ |
372 | mp3_play_stop(); | 399 | mp3_play_stop(); |
373 | |||
374 | queue_write = queue_read = 0; /* reset the queue */ | 400 | queue_write = queue_read = 0; /* reset the queue */ |
375 | 401 | return; | |
376 | return 0; | ||
377 | } | 402 | } |
378 | 403 | ||
379 | /* Shutup the voice, except if force_enqueue_next is set. */ | 404 | /* Shutup the voice, except if force_enqueue_next is set. */ |
380 | int shutup(void) | 405 | void talk_shutup(void) |
381 | { | 406 | { |
382 | if (!force_enqueue_next) | 407 | if (!force_enqueue_next) |
383 | return do_shutup(); | 408 | talk_force_shutup(); |
384 | return 0; | ||
385 | } | 409 | } |
386 | 410 | ||
387 | /* schedule a clip, at the end or discard the existing queue */ | 411 | /* schedule a clip, at the end or discard the existing queue */ |
388 | static int queue_clip(unsigned char* buf, long size, bool enqueue) | 412 | static void queue_clip(unsigned char* buf, long size, bool enqueue) |
389 | { | 413 | { |
390 | int queue_level; | 414 | int queue_level; |
391 | 415 | ||
392 | if (!enqueue) | 416 | if (!enqueue) |
393 | shutup(); /* cut off all the pending stuff */ | 417 | talk_shutup(); /* cut off all the pending stuff */ |
394 | /* Something is being enqueued, force_enqueue_next override is no | 418 | /* Something is being enqueued, force_enqueue_next override is no |
395 | longer in effect. */ | 419 | longer in effect. */ |
396 | force_enqueue_next = false; | 420 | force_enqueue_next = false; |
397 | 421 | ||
398 | if (!size) | 422 | if (!size) |
399 | return 0; /* safety check */ | 423 | return; /* safety check */ |
400 | #if CONFIG_CPU == SH7034 | 424 | #if CONFIG_CPU == SH7034 |
401 | /* disable the DMA temporarily, to be safe of race condition */ | 425 | /* disable the DMA temporarily, to be safe of race condition */ |
402 | CHCR3 &= ~0x0001; | 426 | CHCR3 &= ~0x0001; |
@@ -431,50 +455,7 @@ static int queue_clip(unsigned char* buf, long size, bool enqueue) | |||
431 | #endif | 455 | #endif |
432 | } | 456 | } |
433 | 457 | ||
434 | return 0; | 458 | return; |
435 | } | ||
436 | |||
437 | /* fetch a clip from the voice file */ | ||
438 | static unsigned char* get_clip(long id, long* p_size) | ||
439 | { | ||
440 | long clipsize; | ||
441 | unsigned char* clipbuf; | ||
442 | |||
443 | if (id > VOICEONLY_DELIMITER) | ||
444 | { /* voice-only entries use the second part of the table */ | ||
445 | id -= VOICEONLY_DELIMITER + 1; | ||
446 | if (id >= p_voicefile->id2_max) | ||
447 | return NULL; /* must be newer than we have */ | ||
448 | id += p_voicefile->id1_max; /* table 2 is behind table 1 */ | ||
449 | } | ||
450 | else | ||
451 | { /* normal use of the first table */ | ||
452 | if (id >= p_voicefile->id1_max) | ||
453 | return NULL; /* must be newer than we have */ | ||
454 | } | ||
455 | |||
456 | clipsize = p_voicefile->index[id].size; | ||
457 | if (clipsize == 0) /* clip not included in voicefile */ | ||
458 | return NULL; | ||
459 | clipbuf = (unsigned char *) p_voicefile + p_voicefile->index[id].offset; | ||
460 | |||
461 | #ifdef HAVE_MMC /* dynamic loading, on demand */ | ||
462 | if (!(clipsize & LOADED_MASK)) | ||
463 | { /* clip used for the first time, needs loading */ | ||
464 | lseek(filehandle, p_voicefile->index[id].offset, SEEK_SET); | ||
465 | if (read(filehandle, clipbuf, clipsize) != clipsize) | ||
466 | return NULL; /* read error */ | ||
467 | |||
468 | p_voicefile->index[id].size |= LOADED_MASK; /* mark as loaded */ | ||
469 | } | ||
470 | else | ||
471 | { /* clip is in memory already */ | ||
472 | clipsize &= ~LOADED_MASK; /* without the extra bit gives true size */ | ||
473 | } | ||
474 | #endif | ||
475 | |||
476 | *p_size = clipsize; | ||
477 | return clipbuf; | ||
478 | } | 459 | } |
479 | 460 | ||
480 | 461 | ||
@@ -500,11 +481,12 @@ static void reset_state(void) | |||
500 | p_silence = NULL; /* pause clip not accessible */ | 481 | p_silence = NULL; /* pause clip not accessible */ |
501 | } | 482 | } |
502 | 483 | ||
484 | |||
503 | /***************** Public implementation *****************/ | 485 | /***************** Public implementation *****************/ |
504 | 486 | ||
505 | void talk_init(void) | 487 | void talk_init(void) |
506 | { | 488 | { |
507 | talk_menu_disable = 0; | 489 | talk_temp_disable_count = 0; |
508 | if (talk_initialized && !strcasecmp(last_lang, global_settings.lang_file)) | 490 | if (talk_initialized && !strcasecmp(last_lang, global_settings.lang_file)) |
509 | { | 491 | { |
510 | /* not a new file, nothing to do */ | 492 | /* not a new file, nothing to do */ |
@@ -558,7 +540,7 @@ int talk_get_bufsize(void) | |||
558 | } | 540 | } |
559 | 541 | ||
560 | /* somebody else claims the mp3 buffer, e.g. for regular play/record */ | 542 | /* somebody else claims the mp3 buffer, e.g. for regular play/record */ |
561 | int talk_buffer_steal(void) | 543 | void talk_buffer_steal(void) |
562 | { | 544 | { |
563 | #if CONFIG_CODEC != SWCODEC | 545 | #if CONFIG_CODEC != SWCODEC |
564 | mp3_play_stop(); | 546 | mp3_play_stop(); |
@@ -570,9 +552,7 @@ int talk_buffer_steal(void) | |||
570 | filehandle = -1; | 552 | filehandle = -1; |
571 | } | 553 | } |
572 | #endif | 554 | #endif |
573 | reset_state(); | 555 | reset_state();; |
574 | |||
575 | return 0; | ||
576 | } | 556 | } |
577 | 557 | ||
578 | 558 | ||
@@ -583,6 +563,8 @@ int talk_id(long id, bool enqueue) | |||
583 | unsigned char* clipbuf; | 563 | unsigned char* clipbuf; |
584 | int unit; | 564 | int unit; |
585 | 565 | ||
566 | if (talk_temp_disable_count > 0) | ||
567 | return -1; /* talking has been disabled */ | ||
586 | #if CONFIG_CODEC != SWCODEC | 568 | #if CONFIG_CODEC != SWCODEC |
587 | if (audio_status()) /* busy, buffer in use */ | 569 | if (audio_status()) /* busy, buffer in use */ |
588 | return -1; | 570 | return -1; |
@@ -644,6 +626,8 @@ int talk_file(const char* filename, bool enqueue) | |||
644 | int size; | 626 | int size; |
645 | struct mp3entry info; | 627 | struct mp3entry info; |
646 | 628 | ||
629 | if (talk_temp_disable_count > 0) | ||
630 | return -1; /* talking has been disabled */ | ||
647 | #if CONFIG_CODEC != SWCODEC | 631 | #if CONFIG_CODEC != SWCODEC |
648 | if (audio_status()) /* busy, buffer in use */ | 632 | if (audio_status()) /* busy, buffer in use */ |
649 | return -1; | 633 | return -1; |
@@ -689,13 +673,15 @@ int talk_number(long n, bool enqueue) | |||
689 | int level = 2; /* mille count */ | 673 | int level = 2; /* mille count */ |
690 | long mil = 1000000000; /* highest possible "-illion" */ | 674 | long mil = 1000000000; /* highest possible "-illion" */ |
691 | 675 | ||
676 | if (talk_temp_disable_count > 0) | ||
677 | return -1; /* talking has been disabled */ | ||
692 | #if CONFIG_CODEC != SWCODEC | 678 | #if CONFIG_CODEC != SWCODEC |
693 | if (audio_status()) /* busy, buffer in use */ | 679 | if (audio_status()) /* busy, buffer in use */ |
694 | return -1; | 680 | return -1; |
695 | #endif | 681 | #endif |
696 | 682 | ||
697 | if (!enqueue) | 683 | if (!enqueue) |
698 | shutup(); /* cut off all the pending stuff */ | 684 | talk_shutup(); /* cut off all the pending stuff */ |
699 | 685 | ||
700 | if (n==0) | 686 | if (n==0) |
701 | { /* special case */ | 687 | { /* special case */ |
@@ -785,6 +771,8 @@ int talk_value(long n, int unit, bool enqueue) | |||
785 | = VOICE_PM_UNITS_PER_TICK, | 771 | = VOICE_PM_UNITS_PER_TICK, |
786 | }; | 772 | }; |
787 | 773 | ||
774 | if (talk_temp_disable_count > 0) | ||
775 | return -1; /* talking has been disabled */ | ||
788 | #if CONFIG_CODEC != SWCODEC | 776 | #if CONFIG_CODEC != SWCODEC |
789 | if (audio_status()) /* busy, buffer in use */ | 777 | if (audio_status()) /* busy, buffer in use */ |
790 | return -1; | 778 | return -1; |
@@ -819,13 +807,15 @@ int talk_spell(const char* spell, bool enqueue) | |||
819 | { | 807 | { |
820 | char c; /* currently processed char */ | 808 | char c; /* currently processed char */ |
821 | 809 | ||
810 | if (talk_temp_disable_count > 0) | ||
811 | return -1; /* talking has been disabled */ | ||
822 | #if CONFIG_CODEC != SWCODEC | 812 | #if CONFIG_CODEC != SWCODEC |
823 | if (audio_status()) /* busy, buffer in use */ | 813 | if (audio_status()) /* busy, buffer in use */ |
824 | return -1; | 814 | return -1; |
825 | #endif | 815 | #endif |
826 | 816 | ||
827 | if (!enqueue) | 817 | if (!enqueue) |
828 | shutup(); /* cut off all the pending stuff */ | 818 | talk_shutup(); /* cut off all the pending stuff */ |
829 | 819 | ||
830 | while ((c = *spell++) != '\0') | 820 | while ((c = *spell++) != '\0') |
831 | { | 821 | { |
@@ -849,26 +839,18 @@ int talk_spell(const char* spell, bool enqueue) | |||
849 | return 0; | 839 | return 0; |
850 | } | 840 | } |
851 | 841 | ||
852 | bool talk_menus_enabled(void) | 842 | void talk_disable(bool disable) |
853 | { | 843 | { |
854 | return (global_settings.talk_menu && talk_menu_disable == 0); | 844 | if (disable) |
855 | } | 845 | talk_temp_disable_count++; |
856 | 846 | else | |
857 | 847 | talk_temp_disable_count--; | |
858 | void talk_disable_menus(void) | ||
859 | { | ||
860 | talk_menu_disable++; | ||
861 | } | ||
862 | |||
863 | void talk_enable_menus(void) | ||
864 | { | ||
865 | talk_menu_disable--; | ||
866 | } | 848 | } |
867 | 849 | ||
868 | #if CONFIG_RTC | 850 | #if CONFIG_RTC |
869 | void talk_date_time(struct tm *tm, bool speak_current_time_string) | 851 | void talk_date_time(struct tm *tm, bool speak_current_time_string) |
870 | { | 852 | { |
871 | if(talk_menus_enabled ()) | 853 | if(global_settings.talk_menu) |
872 | { | 854 | { |
873 | if(speak_current_time_string) | 855 | if(speak_current_time_string) |
874 | talk_id(VOICE_CURRENT_TIME, true); | 856 | talk_id(VOICE_CURRENT_TIME, true); |
diff --git a/apps/talk.h b/apps/talk.h index e25a11c702..a939c1f3d1 100644 --- a/apps/talk.h +++ b/apps/talk.h | |||
@@ -66,19 +66,16 @@ void talk_init(void); | |||
66 | bool talk_voice_required(void); /* returns true if voice codec required */ | 66 | bool talk_voice_required(void); /* returns true if voice codec required */ |
67 | #endif | 67 | #endif |
68 | int talk_get_bufsize(void); /* get the loaded voice file size */ | 68 | int talk_get_bufsize(void); /* get the loaded voice file size */ |
69 | /* talk_buffer_steal - on SWCODEC, for use by buffer functions only */ | 69 | void talk_buffer_steal(void); /* claim the mp3 buffer e.g. for play/record */ |
70 | int talk_buffer_steal(void); /* claim the mp3 buffer e.g. for play/record */ | ||
71 | bool is_voice_queued(void); /* Are there more voice clips to be spoken? */ | 70 | bool is_voice_queued(void); /* Are there more voice clips to be spoken? */ |
72 | int talk_id(long id, bool enqueue); /* play a voice ID from voicefont */ | 71 | int talk_id(long id, bool enqueue); /* play a voice ID from voicefont */ |
73 | int talk_file(const char* filename, bool enqueue); /* play a thumbnail from file */ | 72 | int talk_file(const char* filename, bool enqueue); /* play a thumbnail from file */ |
74 | int talk_number(long n, bool enqueue); /* say a number */ | 73 | int talk_number(long n, bool enqueue); /* say a number */ |
75 | int talk_value(long n, int unit, bool enqueue); /* say a numeric value */ | 74 | int talk_value(long n, int unit, bool enqueue); /* say a numeric value */ |
76 | int talk_spell(const char* spell, bool enqueue); /* spell a string */ | 75 | int talk_spell(const char* spell, bool enqueue); /* spell a string */ |
77 | bool talk_menus_enabled(void); /* returns true if menus should be voiced */ | 76 | void talk_disable(bool disable); /* temporarily disable (or re-enable) talking (temporarily, not persisted) */ |
78 | void talk_disable_menus(void); /* disable voice menus (temporarily, not persisted) */ | 77 | void talk_force_shutup(void); /* kill voice unconditionally */ |
79 | void talk_enable_menus(void); /* re-enable voice menus */ | 78 | void talk_shutup(void); /* Interrupt voice, as when enqueue is false */ |
80 | int do_shutup(void); /* kill voice unconditionally */ | ||
81 | int shutup(void); /* Interrupt voice, as when enqueue is false */ | ||
82 | 79 | ||
83 | #if CONFIG_RTC | 80 | #if CONFIG_RTC |
84 | /* this is in talk.c which isnt compiled for hwcodec simulator */ | 81 | /* this is in talk.c which isnt compiled for hwcodec simulator */ |
@@ -94,12 +91,14 @@ void talk_date_time(struct tm *time, bool speak_current_time_string); | |||
94 | 91 | ||
95 | /* We don't build talk.c for hwcodec sims so we need to define these as empty */ | 92 | /* We don't build talk.c for hwcodec sims so we need to define these as empty */ |
96 | #if defined(SIMULATOR) && !(CONFIG_CODEC == SWCODEC) | 93 | #if defined(SIMULATOR) && !(CONFIG_CODEC == SWCODEC) |
94 | #define talk_init(...) | ||
95 | #define talk_buffer_steal(...) | ||
96 | #define talk_shutup(...) | ||
97 | #define talk_force_enqueue_next(...) | 97 | #define talk_force_enqueue_next(...) |
98 | #define talk_idarray(...) | 98 | #define talk_idarray(...) |
99 | #define talk_ids(...) | 99 | #define talk_ids(...) |
100 | #define cond_talk_ids(...) | 100 | #define cond_talk_ids(...) |
101 | #define cond_talk_ids_fq(...) | 101 | #define cond_talk_ids_fq(...) |
102 | #define shutup(...) | ||
103 | #else | 102 | #else |
104 | 103 | ||
105 | /* Enqueue next utterance even if enqueue parameter is false: don't | 104 | /* Enqueue next utterance even if enqueue parameter is false: don't |
@@ -116,18 +115,18 @@ int talk_idarray(long *idarray, bool enqueue); | |||
116 | /* This version talks only if talking menus are enabled, and does not | 115 | /* This version talks only if talking menus are enabled, and does not |
117 | enqueue the initial id. */ | 116 | enqueue the initial id. */ |
118 | #define cond_talk_ids(ids...) do { \ | 117 | #define cond_talk_ids(ids...) do { \ |
119 | if (talk_menus_enabled()) \ | 118 | if (global_settings.talk_menu) \ |
120 | talk_ids(false, ids); \ | 119 | talk_ids(false, ids); \ |
121 | } while(0) | 120 | } while(0) |
122 | /* And a version that takes the array parameter... */ | 121 | /* And a version that takes the array parameter... */ |
123 | #define cond_talk_idarray(idarray) do { \ | 122 | #define cond_talk_idarray(idarray) do { \ |
124 | if (talk_menus_enabled() \ | 123 | if (global_settings.talk_menu \ |
125 | talk_idarray(idarray, false); \ | 124 | talk_idarray(idarray, false); \ |
126 | } while(0) | 125 | } while(0) |
127 | /* Convenience macro to conditionally speak something and not have | 126 | /* Convenience macro to conditionally speak something and not have |
128 | it interrupted. */ | 127 | it interrupted. */ |
129 | #define cond_talk_ids_fq(ids...) do { \ | 128 | #define cond_talk_ids_fq(ids...) do { \ |
130 | if (talk_menus_enabled()) { \ | 129 | if (global_settings.talk_menu) { \ |
131 | talk_ids(false, ids); \ | 130 | talk_ids(false, ids); \ |
132 | talk_force_enqueue_next(); \ | 131 | talk_force_enqueue_next(); \ |
133 | } \ | 132 | } \ |
diff --git a/uisimulator/common/stubs.c b/uisimulator/common/stubs.c index 840b1421c0..00716b39c6 100644 --- a/uisimulator/common/stubs.c +++ b/uisimulator/common/stubs.c | |||
@@ -302,14 +302,6 @@ void button_set_flip(bool yesno) | |||
302 | } | 302 | } |
303 | 303 | ||
304 | #if CONFIG_CODEC != SWCODEC | 304 | #if CONFIG_CODEC != SWCODEC |
305 | void talk_init(void) | ||
306 | { | ||
307 | } | ||
308 | |||
309 | int talk_buffer_steal(void) | ||
310 | { | ||
311 | return 0; | ||
312 | } | ||
313 | 305 | ||
314 | int talk_id(int id, bool enqueue) | 306 | int talk_id(int id, bool enqueue) |
315 | { | 307 | { |
@@ -347,17 +339,9 @@ int talk_spell(char* spell, bool enqueue) | |||
347 | return 0; | 339 | return 0; |
348 | } | 340 | } |
349 | 341 | ||
350 | bool talk_menus_enabled(void) | 342 | void talk_disable(bool disable) |
351 | { | ||
352 | return false; | ||
353 | } | ||
354 | |||
355 | void talk_enable_menus(void) | ||
356 | { | ||
357 | } | ||
358 | |||
359 | void talk_disable_menus(void) | ||
360 | { | 343 | { |
344 | (void) disable; | ||
361 | } | 345 | } |
362 | 346 | ||
363 | const char* const dir_thumbnail_name = "_dirname.talk"; | 347 | const char* const dir_thumbnail_name = "_dirname.talk"; |