From 36f34089d6cc9b425162c490868a06904a103dca Mon Sep 17 00:00:00 2001 From: Solomon Peachy Date: Sat, 28 Mar 2026 08:41:35 -0400 Subject: [PATCH] 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 --- apps/misc.c | 14 ++------------ firmware/sound.c | 10 ++++++++++ 2 files changed, 12 insertions(+), 12 deletions(-) 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