From c51ca1eeb55ee8d4bfedbca768d4284b59670fa5 Mon Sep 17 00:00:00 2001 From: Christian Soffke Date: Wed, 28 May 2025 12:14:53 +0200 Subject: [PATCH] voice: splash_progress Says "Loading x%" in previously unvoiced splash_progress Change-Id: I81780e3baf6ea8a8871a4433e1a733100b8cd5f6 --- apps/gui/splash.c | 12 +++++++++++- apps/misc.c | 3 +-- apps/plugins/playing_time.c | 10 +--------- apps/root_menu.c | 5 +++++ apps/tagtree.c | 6 ++++-- 5 files changed, 22 insertions(+), 14 deletions(-) diff --git a/apps/gui/splash.c b/apps/gui/splash.c index 7082f28b48..3df6c547f6 100644 --- a/apps/gui/splash.c +++ b/apps/gui/splash.c @@ -36,7 +36,7 @@ #include "misc.h" /* get_current_activity */ #endif -static long progress_next_tick = 0; +static long progress_next_tick, talked_tick; #define MAXLINES (LCD_HEIGHT/6) #define MAXBUFFER 512 @@ -247,6 +247,7 @@ void splashf(int ticks, const char *fmt, ...) void splash_progress_set_delay(long delay_ticks) { progress_next_tick = current_tick + delay_ticks; + talked_tick = 0; } /* splash a progress meter */ @@ -266,6 +267,15 @@ void splash_progress(int current, int total, const char *fmt, ...) vp_flag = 0; /* don't mark vp dirty to prevent flashing */ } + if (global_settings.talk_menu && + total > 0 && + TIME_AFTER(current_tick, talked_tick + HZ*5)) + { + talked_tick = current_tick; + talk_ids(false, LANG_LOADING_PERCENT, + TALK_ID(current * 100 / total, UNIT_PERCENT)); + } + /* If fmt is a lang ID then get the corresponding string (which still might contain % place holders). */ fmt = P2STR((unsigned char *)fmt); diff --git a/apps/misc.c b/apps/misc.c index 82aec68b47..b50128220d 100644 --- a/apps/misc.c +++ b/apps/misc.c @@ -223,10 +223,9 @@ bool show_search_progress(bool init, int display_count, int current, int total) if (TIME_AFTER(current_tick, last_tick + HZ/10)) { if (total != current) - { + /* (voiced) */ splash_progress(current, total, str(LANG_PLAYLIST_SEARCH_MSG), display_count, str(LANG_OFF_ABORT)); - } else splashf(0, ID2P(LANG_PLAYLIST_SEARCH_MSG), display_count, str(LANG_OFF_ABORT)); diff --git a/apps/plugins/playing_time.c b/apps/plugins/playing_time.c index 2ad3ba0e3d..87d66062a7 100644 --- a/apps/plugins/playing_time.c +++ b/apps/plugins/playing_time.c @@ -420,22 +420,14 @@ static int pt_add_track(int i, enum ePT_SUM section, struct playing_time_info *p { struct mp3entry id3; struct playlist_track_info pl_track; - static unsigned long talked_tick; int progress_total = pti->remaining_only ? (pti->nb_tracks - pti->curr_display_index) + 1 : pti->nb_tracks; + /* (voiced) */ rb->splash_progress(pti->counted, progress_total, "%s (%s)", rb->str(LANG_WAIT), rb->str(LANG_OFF_ABORT)); - if (rb->global_settings->talk_menu && TIME_AFTER(*rb->current_tick, talked_tick + HZ*5)) - { - talked_tick = *rb->current_tick; - rb_talk_ids(false, LANG_LOADING_PERCENT, - TALK_ID(pti->counted * 100 / progress_total, - UNIT_PERCENT)); - } - if (rb->action_userabort(TIMEOUT_NOBLOCK)) return -1; else if (rb->playlist_get_track_info(NULL, i, &pl_track) < 0 diff --git a/apps/root_menu.c b/apps/root_menu.c index 37adda7468..419ae72708 100644 --- a/apps/root_menu.c +++ b/apps/root_menu.c @@ -238,6 +238,10 @@ static int browser(void* param) } if (stat->commit_step > 0) { + /* (prevent redundant voicing by splash_progress */ + bool tmp = global_settings.talk_menu; + global_settings.talk_menu = false; + if (lang_is_rtl()) { splash_progress(stat->commit_step, @@ -254,6 +258,7 @@ static int browser(void* param) stat->commit_step, tagcache_get_max_commit_step()); } + global_settings.talk_menu = tmp; } else { diff --git a/apps/tagtree.c b/apps/tagtree.c index 94854083b1..1904cc139f 100644 --- a/apps/tagtree.c +++ b/apps/tagtree.c @@ -2415,7 +2415,8 @@ static bool insert_all_playlist(struct tree_context *c, { if (TIME_AFTER(current_tick, last_tick + HZ/4)) { - splash_progress(i, n, "%s (%s)", str(LANG_WAIT), str(LANG_OFF_ABORT)); // XXX not voiced + /* (voiced) */ + splash_progress(i, n, "%s (%s)", str(LANG_WAIT), str(LANG_OFF_ABORT)); if (action_userabort(TIMEOUT_NOBLOCK)) { exit_loop_now = true; @@ -2593,7 +2594,8 @@ bool tagtree_subentries_do_action(bool (*action_cb)(const char *file_name)) n = tc->filesindir; for (i = 0; i < n; i++) { - splash_progress(i, n, "%s (%s)", str(LANG_WAIT), str(LANG_OFF_ABORT)); // XXX not voiced + /* (voiced) */ + splash_progress(i, n, "%s (%s)", str(LANG_WAIT), str(LANG_OFF_ABORT)); if (TIME_AFTER(current_tick, last_tick + HZ/4)) { if (action_userabort(TIMEOUT_NOBLOCK))