announce_status plugin command line arguments + force_enque_next

rockbox-gerrit-noreply--- via rockbox-cvs <[email protected]>
Newsgroups gmane.comp.systems.archos.rockbox.cvs
Message-ID <[email protected]>
commit c80723b5397e0d0a5832c1f055aea8097491c688
Author: William Wilgus <[email protected]>
Date:   Fri Jan 23 11:02:36 2026 -0500

    announce_status plugin command line arguments + force_enque_next
    
    I had commented out 'talk_force_enqueue_next()' in the voice prompts
    pretty sure it was because really long prompts just keep droning on
    problem being as soon as the plugin returns in some cases the prompt
    gets cut off by the parent calling shutup on us
    
    so it is now a setting (on by default)
    
    Now allows command line arguments
    so you can announce whatever prompt you want whenever / wherever you want
    (checkout open plugins for a way to create a plugin with command line arguments)
    you can then add this .opx shortcut to your shortcuts or quick screen
    
    and as before you can use a hotkey which also will allow command line args..
    
    Change-Id: Id8883c0a4e85e1cb813959ab72e89817f388a397

diff --git a/apps/plugins/announce_status.c b/apps/plugins/announce_status.c
index 214a3812c2..927bac720c 100644
--- a/apps/plugins/announce_status.c
+++ b/apps/plugins/announce_status.c
@@ -84,7 +84,7 @@ void thread_create(void);
 void thread(void); /* the thread running it all */
 void thread_quit(void);
 static int voice_general_info(bool testing);
-static unsigned char* voice_info_group(unsigned char* current_token, bool testing);
+static const char* voice_info_group(const char* current_token, bool testing);
 
 int plugin_main(const void* parameter); /* main loop */
 enum plugin_status plugin_start(const void* parameter); /* entry */
@@ -115,8 +115,9 @@ static struct
     int bin_added;
 
     bool show_prompt;
+    bool force_enqueue;
 
-    unsigned char wps_fmt[MAX_ANNOUNCE_WPS+1];
+    char wps_fmt[MAX_ANNOUNCE_WPS+1];
 } gAnnounce;
 
 static struct configdata config[] =
@@ -126,6 +127,7 @@ static struct configdata config[] =
    {TYPE_INT, 0, 10, { .int_p = &gAnnounce.grouping }, "Grouping", NULL},
    {TYPE_INT, 0, 10000, { .int_p = &gAnnounce.bin_added }, "Added", NULL},
    {TYPE_BOOL, 0, 1, { .bool_p = &gAnnounce.show_prompt }, "Prompt", NULL},
+   {TYPE_BOOL, 0, 1, { .bool_p = &gAnnounce.force_enqueue }, "Enqueue", NULL},
    {TYPE_STRING, 0, MAX_ANNOUNCE_WPS+1,
                    { .string =  (char*)&gAnnounce.wps_fmt }, "Fmt", NULL},
 };
@@ -165,6 +167,7 @@ static void config_set_defaults(void)
     gAnnounce.grouping = 0;
     gAnnounce.wps_fmt[0] = '\0';
     gAnnounce.show_prompt = true;
+    gAnnounce.force_enqueue = true;
 }
 
 static void config_reset_voice(void)
@@ -176,7 +179,7 @@ static void config_reset_voice(void)
 
     if (configfile_load(CFG_FILE, config, gCfg_sz, CFG_VER) < 0)
     {
-        rb->splash(100, "ERROR!");
+        rb->splashf(100, "%s", "ERROR!");
         return;
     }
 
@@ -194,7 +197,8 @@ void announce(void)
     voice_general_info(false);
     if (rb->talk_id(VOICE_PAUSE, true) < 0)
         rb->beep_play(800, 100, 1000);
-    //rb->talk_force_enqueue_next();
+    if (gAnnounce.force_enqueue)
+        rb->talk_force_enqueue_next();
 }
 
 static void announce_test(void)
@@ -202,8 +206,8 @@ static void announce_test(void)
     rb->talk_force_shutup();
     rb->sleep(HZ / 2);
     voice_info_group(gAnnounce.wps_fmt, true);
-    rb->splash(HZ, "...");
-    //rb->talk_force_enqueue_next();
+    if (gAnnounce.force_enqueue)
+        rb->talk_force_enqueue_next();
 }
 
 static void announce_add(const char *str)
@@ -298,7 +302,7 @@ static int announce_menu_cb(int action,
             case 8: /*Clear All*/
                 gAnnounce.wps_fmt[0] = '\0';
                 gAnnounce.bin_added = 0;
-                rb->splash(HZ / 2, ID2P(LANG_RESET_DONE_CLEAR));
+                rb->splashf(HZ / 2, "%s", ID2P(LANG_RESET_DONE_CLEAR));
                 break;
             case 9: /* inspect it */
                 kbd_p = kbd_buf;
@@ -364,6 +368,7 @@ static int settings_menu(void)
                         ID2P(LANG_ANNOUNCE_ON),
                         ID2P(LANG_GROUPING),
                         ID2P(LANG_ANNOUNCEMENT_FMT),
+                        ID2P(LANG_QUEUE_FIRST),
                         ID2P(VOICE_BLANK),
                         ID2P(LANG_MENU_QUIT),
                         ID2P(LANG_SAVE_EXIT));
@@ -392,12 +397,15 @@ static int settings_menu(void)
             case 3:
                 announce_menu();
                 break;
-            case 4: /*sep*/
+            case 4:
+                rb->set_bool(rb->str(LANG_QUEUE_FIRST), &gAnnounce.force_enqueue);
+                break;
+            case 5: /*sep*/
                 continue;
-            case 5: /* quit the plugin */
+            case 6: /* quit the plugin */
                 return -1;
                 break;
-            case 6:
+            case 7:
                 configfile_save(CFG_FILE, config, gCfg_sz, CFG_VER);
                 return 0;
                 break;
@@ -538,7 +546,7 @@ int plugin_main(const void* parameter)
     }
     else
     {
-        rb->splash(HZ / 2, "Announce Status");
+        rb->splashf(HZ / 2, "%s", "Announce Status");
         if (gAnnounce.show_prompt)
         {
             if (rb->mixer_channel_status(PCM_MIXER_CHAN_PLAYBACK) != CHANNEL_PLAYING)
@@ -551,7 +559,7 @@ int plugin_main(const void* parameter)
 
         if (check_user_input() == true)
         {
-            rb->splash(100, ID2P(LANG_SETTINGS));
+            rb->splashf(100, "%s", ID2P(LANG_SETTINGS));
             int ret = settings_menu();
             if (ret < 0)
                 return 0;
@@ -580,12 +588,25 @@ enum plugin_status plugin_start(const void* parameter)
         return PLUGIN_USB_CONNECTED;
 
     config_set_defaults();
+
+    if (parameter && parameter != rb->plugin_tsr)
+    {
+        const char *param = (const char*) parameter;
+        if (param[0] != '\0')
+        {
+            voice_info_group(param, false);
+            rb->talk_force_enqueue_next();
+            return PLUGIN_OK;
+        }
+    }
+
+
     if (configfile_load(CFG_FILE, config, gCfg_sz, CFG_VER) < 0)
     {
         /* If the loading failed, save a new config file */
         config_set_defaults();
         configfile_save(CFG_FILE, config, gCfg_sz, CFG_VER);
-        rb->splash(HZ, ID2P(LANG_HOLD_FOR_SETTINGS));
+        rb->splashf(HZ, "%s", ID2P(LANG_HOLD_FOR_SETTINGS));
     }
 
     int ret = plugin_main(parameter);
@@ -594,7 +615,7 @@ enum plugin_status plugin_start(const void* parameter)
 
 static int voice_general_info(bool testing)
 {
-    unsigned char* infotemplate = gAnnounce.wps_fmt;
+    const char* infotemplate = gAnnounce.wps_fmt;
 
     if (gAnnounce.index >= rb->strlen(gAnnounce.wps_fmt))
         gAnnounce.index = 0;
@@ -629,9 +650,9 @@ static int voice_general_info(bool testing)
     return 0;
 }
 
-static unsigned char* voice_info_group(unsigned char* current_token, bool testing)
+static const char* voice_info_group(const char* current_token, bool testing)
 {
-    unsigned char current_char;
+    char current_char;
     bool skip_next_group = false;
     gAnnounce.count = 0;
 
-- 
rockbox-cvs mailing list
[email protected]
https://lists.haxx.se/mailman/listinfo/rockbox-cvs
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.