volume: Apply limits inside sound_set_volume()

rockbox-gerrit-noreply--- via rockbox-cvs <[email protected]>
Newsgroups gmane.comp.systems.archos.rockbox.cvs
Message-ID <[email protected]>
commit 36f34089d6cc9b425162c490868a06904a103dca
Author: Solomon Peachy <[email protected]>
Date:   Sat Mar 28 08:41:35 2026 -0400

    volume:  Apply limits inside sound_set_volume()
    
    This way all paths to setting the volume respect the limits, instead
    of only callers of setvol(), which only applies to (some?) interactive
    paths.
    
    Change-Id: Ia8ece22aafcb04df33021071cb933eaeb1146502

diff --git a/apps/misc.c b/apps/misc.c
index 40a55d032f..a44f106fb9 100644
--- a/apps/misc.c
+++ b/apps/misc.c
@@ -866,20 +866,10 @@ void check_bootfile(bool do_rolo)
 #endif
 #endif
 
-/* check range, set volume and save settings */
+/* set volume and save settings */
 void setvol(void)
 {
-    const int min_vol = sound_min(SOUND_VOLUME);
-    const int max_vol = sound_max(SOUND_VOLUME);
-    int volume = global_status.volume;
-    if (volume < min_vol)
-        volume = min_vol;
-    if (volume > max_vol)
-        volume = max_vol;
-    if (volume > global_settings.volume_limit)
-        volume = global_settings.volume_limit;
-
-    sound_set_volume(volume);
+    sound_set_volume(global_status.volume);
     global_status.last_volume_change = current_tick;
     status_save(false);
 }
diff --git a/firmware/sound.c b/firmware/sound.c
index 0e43f38f5a..07a91878d8 100644
--- a/firmware/sound.c
+++ b/firmware/sound.c
@@ -312,6 +312,16 @@ void sound_set_volume(int value)
     if (!audio_is_initialized)
         return;
 
+    /* Apply limits */
+    const int min_vol = sound_min(SOUND_VOLUME);
+    const int max_vol = sound_max(SOUND_VOLUME);
+    if (value < min_vol)
+        value = min_vol;
+    if (value > max_vol)
+        value = max_vol;
+    if (value > global_settings.volume_limit)
+        value = global_settings.volume_limit;
+
 #ifndef BOOTLOADER
     global_status.volume = value;
 #endif
-- 
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.