Index: apps/gui/list.c =================================================================== --- apps/gui/list.c (revisione 22439) +++ apps/gui/list.c (copia locale) @@ -38,6 +38,8 @@ #include "misc.h" #include "talk.h" #include "viewport.h" +#include "pcmbuf.h" +#include "playback.h" #ifdef HAVE_LCD_CHARCELLS #define SCROLL_LIMIT 1 @@ -59,6 +61,7 @@ static void gui_list_select_at_offset(struct gui_synclist * gui_list, int offset); void list_draw(struct screen *display, struct gui_synclist *list); +static void edge_beep(struct gui_synclist * gui_list, bool wrap); #ifdef HAVE_LCD_BITMAP static void list_init_viewports(struct gui_synclist *list) @@ -331,11 +334,13 @@ { gui_list->selected_item = gui_list->limit_scroll ? gui_list->nb_items - gui_list->selected_size : 0; + edge_beep(gui_list, !gui_list->limit_scroll); } else if (new_selection < 0) { gui_list->selected_item = gui_list->limit_scroll ? 0 : gui_list->nb_items - gui_list->selected_size; + edge_beep(gui_list, !gui_list->limit_scroll); } else if (gui_list->show_selection_marker == false) { @@ -539,6 +544,44 @@ } #endif /* HAVE_LCD_BITMAP */ +static void edge_beep(struct gui_synclist * gui_list, bool wrap) +{ +#if CONFIG_CODEC != SWCODEC + (void)gui_list; + (void)wrap; +#else + list_speak_item *cb = gui_list->callback_speak_item; + if(cb && global_settings.talk_menu) + { + if(!wrap) /* a bounce */ + { + static long last_bounce_tick = 0; + if(TIME_BEFORE(current_tick, last_bounce_tick+HZ/4)) + return; + last_bounce_tick = current_tick; + } + /* Next thing the list code will do is go speak the item, doing + a talk_shutup() first. Shutup now so the beep is clearer, and + make sure the subsequent shutup is skipped because otherwise + it'd kill the pcm buffer. */ + talk_shutup(); + talk_force_enqueue_next(); + /* On at least x5: if, instead of the above shutup, I insert a + sleep just after the pcmbuf_beep() call, to delay the subsequent + shutup and talk, then in some cases the beep is not played: if + the end of a previous utterance is still playing from the pcm buf, + the beep fails, even if there would seem to remain enough time + to the utterance to mix in the beep. */ + int duration = wrap ? 20 : 40; + pcmbuf_beep(wrap ? 2000 : 1000, duration, 1500); + /* Somehow, the following voice utterance is suppressed on e200, + but not on x5. Work around... */ + sleep((duration*HZ +999)/1000); + talk_force_shutup(); + } +#endif +} + static void _gui_synclist_speak_item(struct gui_synclist *lists, bool repeating) { list_speak_item *cb = lists->callback_speak_item;