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
This commit is contained in:
Solomon Peachy 2026-03-28 08:41:35 -04:00
parent 5ce96b84d8
commit 36f34089d6
2 changed files with 12 additions and 12 deletions

View file

@ -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);
}