mirror of
https://github.com/Rockbox/rockbox.git
synced 2026-04-12 00:47:49 -04:00
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:
parent
5ce96b84d8
commit
36f34089d6
2 changed files with 12 additions and 12 deletions
14
apps/misc.c
14
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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue