[prev in list] [next in list] [prev in thread] [next in thread] 

List:       rockbox-cvs
Subject:    plugins trade talk_value for talk_value_decimal
From:       rockbox-gerrit-noreply--- via rockbox-cvs <rockbox-cvs () cool ! haxx ! se>
Date:       2021-08-19 1:17:30
Message-ID: 202108190117.17J1HUlW4193006 () stuffed ! shaftnet ! org
[Download RAW message or body]

commit 24e8fa317e9905ee30d195c4beedd7b8939ed6e1
Author: William Wilgus <wilgus.william@gmail.com>
Date:   Wed Aug 18 01:23:26 2021 -0400

    plugins trade talk_value for talk_value_decimal
    
    talk_value is just talk_value_decimal with 0 decimals
    
    lets add the extended function instead
    
    static inline int talk_val(long n, int unit, bool enqueue)
    {
        #define NODECIMALS 0
        return rb->talk_value_decimal(n, unit, NODECIMALS, enqueue);
    }
    
    Change-Id: Iaba3d2f95785f2e1855e294ccf099a977bb6cb20

diff --git a/apps/plugin.c b/apps/plugin.c
index a3970a88a7..4877c3d255 100644
--- a/apps/plugin.c
+++ b/apps/plugin.c
@@ -439,7 +439,7 @@ static const struct plugin_api rockbox_api = {
     talk_file_or_spell,
     talk_dir_or_spell,
     talk_number,
-    talk_value,
+    talk_value_decimal,
     talk_spell,
     talk_time,
     talk_date,
diff --git a/apps/plugin.h b/apps/plugin.h
index 64ced00bfa..bd467bcade 100644
--- a/apps/plugin.h
+++ b/apps/plugin.h
@@ -495,7 +495,7 @@ struct plugin_api {
     int (*talk_dir_or_spell)(const char* filename,
                              const long *prefix_ids, bool enqueue);
     int (*talk_number)(long n, bool enqueue);
-    int (*talk_value)(long n, int unit, bool enqueue);
+    int (*talk_value_decimal)(long n, int unit, int decimals, bool enqueue);
     int (*talk_spell)(const char* spell, bool enqueue);
     void (*talk_time)(const struct tm *tm, bool enqueue);
     void (*talk_date)(const struct tm *tm, bool enqueue);
diff --git a/apps/plugins/announce_status.c b/apps/plugins/announce_status.c
index 84a44556ef..5a112ed6df 100644
--- a/apps/plugins/announce_status.c
+++ b/apps/plugins/announce_status.c
@@ -185,6 +185,11 @@ static void config_reset_voice(void)
 }
 
 /****************** helper fuctions ******************/
+static inline int talk_val(long n, int unit, bool enqueue)
+{
+    #define NODECIMALS 0
+    return rb->talk_value_decimal(n, unit, NODECIMALS, enqueue);
+}
 
 void announce(void)
 {
@@ -658,7 +663,7 @@ static unsigned char* voice_info_group(unsigned char* current_token, bool testin
             if (current_char == 'T')
             {
                 runtime = rb->global_status->runtime;
-                rb->talk_value(runtime, UNIT_TIME, true);
+                talk_val(runtime, UNIT_TIME, true);
             }
             /* prefix suffix connectives */
             else if (current_char == '1')
@@ -669,7 +674,7 @@ static unsigned char* voice_info_group(unsigned char* current_token, bool testin
             {
                 if (current_char == 'S')
                 {
-                    rb->talk_value(sleep_remaining, UNIT_TIME, true);
+                    talk_val(sleep_remaining, UNIT_TIME, true);
                 }
                 /* prefix suffix connectives */
                 else if (current_char == '2')
@@ -704,15 +709,15 @@ static unsigned char* voice_info_group(unsigned char* current_token, bool testin
 
             if (current_char == 'E')
             {
-                rb->talk_value(elapsed_length, UNIT_TIME, true);
+                talk_val(elapsed_length, UNIT_TIME, true);
             }
             else if (current_char == 'L')
             {
-                rb->talk_value(track_length, UNIT_TIME, true);
+                talk_val(track_length, UNIT_TIME, true);
             }
             else if (current_char == 'R')
             {
-                rb->talk_value(track_remaining, UNIT_TIME, true);
+                talk_val(track_remaining, UNIT_TIME, true);
             }
             else if (current_char == 'T' && id3->title)
             {
@@ -797,11 +802,11 @@ static unsigned char* voice_info_group(unsigned char* current_token, bool testin
 
             if (current_char == 'P')
             {
-                rb->talk_value(rb->battery_level(), UNIT_PERCENT, true);
+                talk_val(rb->battery_level(), UNIT_PERCENT, true);
             }
             else if (current_char == 'M')
             {
-                rb->talk_value(rb->battery_time() * 60, UNIT_TIME, true);
+                talk_val(rb->battery_time() * 60, UNIT_TIME, true);
             }
             /* prefix suffix connectives */
             else if (current_char == '1')
diff --git a/apps/plugins/mpegplayer/mpeg_settings.c b/apps/plugins/mpegplayer/mpeg_settings.c
index b1445781d0..4c9fc16804 100644
--- a/apps/plugins/mpegplayer/mpeg_settings.c
+++ b/apps/plugins/mpegplayer/mpeg_settings.c
@@ -470,6 +470,12 @@ static bool mpeg_set_int(const char *string, const char *unit,
     return usb;
 }
 
+static inline int talk_val(long n, int unit, bool enqueue)
+{
+    #define NODECIMALS 0
+    return rb->talk_value_decimal(n, unit, NODECIMALS, enqueue);
+}
+
 static int32_t backlight_brightness_getlang(int value, int unit)
 {
     if (value < 0)
@@ -988,8 +994,8 @@ static int get_start_time(uint32_t duration)
                     mpegplayer_iram_preserve();
 #endif
                     rb->talk_disable(false);
-                    rb->talk_value(resume_time / TS_SECOND, UNIT_TIME, false);
-                    rb->talk_value(resume_time * 100 / duration, UNIT_PERCENT, true);
+                    talk_val(resume_time / TS_SECOND, UNIT_TIME, false);
+                    talk_val(resume_time * 100 / duration, UNIT_PERCENT, true);
                 }
                 sliding = false;
             }
diff --git a/apps/plugins/properties.c b/apps/plugins/properties.c
index 28f539f49f..0fa83c0b56 100644
--- a/apps/plugins/properties.c
+++ b/apps/plugins/properties.c
@@ -334,7 +334,7 @@ static int speak_property_selection(int selected_item, void *data)
         rb->talk_time(&tm, true);
         break;
     case LANG_PROPERTIES_DURATION:
-        rb->talk_value(nseconds, UNIT_TIME, true);
+        rb->talk_value_decimal(nseconds, UNIT_TIME, 0, true);
         break;
     case LANG_PROPERTIES_SUBDIRS:
         rb->talk_number(dps->dc, true);
diff --git a/apps/plugins/vbrfix.c b/apps/plugins/vbrfix.c
index 768ec9d99f..88f0a6579e 100644
--- a/apps/plugins/vbrfix.c
+++ b/apps/plugins/vbrfix.c
@@ -37,7 +37,7 @@ static void xingupdate(int percent)
         long now = *(rb->current_tick) / HZ;
         if (now - last_talk >= 5)
         {
-            rb->talk_value(percent, UNIT_PERCENT, false);
+            rb->talk_value_decimal(percent, UNIT_PERCENT, 0, false);
             last_talk = now;
         }
     }
_______________________________________________
rockbox-cvs mailing list
rockbox-cvs@cool.haxx.se
https://cool.haxx.se/cgi-bin/mailman/listinfo/rockbox-cvs

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic