mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-10-13 10:07:38 -04:00
sound: update global volume state in sound_set_volume()
Instead of calling sound_set_volume() and then manually setting global_status.volume to match, update the global volume state directly in sound_set_volume(). This makes things a bit simpler and less error-prone. Change-Id: I4db4d60ae1a72bd051ef49c90b1ae7f5ba59e535
This commit is contained in:
parent
ae001cb60c
commit
b19b95c00f
10 changed files with 7 additions and 18 deletions
|
@ -594,9 +594,6 @@ bool option_screen(const struct settings_list *setting,
|
||||||
if (!cb_on_changed || (*variable != oldvalue))
|
if (!cb_on_changed || (*variable != oldvalue))
|
||||||
{
|
{
|
||||||
function(*variable);
|
function(*variable);
|
||||||
/* if the volume is changing we need to let the skins know */
|
|
||||||
if (function == sound_get_fn(SOUND_VOLUME))
|
|
||||||
global_status.last_volume_change = current_tick;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -877,9 +877,8 @@ void setvol(void)
|
||||||
volume = max_vol;
|
volume = max_vol;
|
||||||
if (volume > global_settings.volume_limit)
|
if (volume > global_settings.volume_limit)
|
||||||
volume = global_settings.volume_limit;
|
volume = global_settings.volume_limit;
|
||||||
global_status.volume = volume;
|
|
||||||
sound_set_volume(volume);
|
sound_set_volume(volume);
|
||||||
global_status.last_volume_change = current_tick;
|
|
||||||
status_save(false);
|
status_save(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -606,7 +606,6 @@ int beatboxmain()
|
||||||
{
|
{
|
||||||
vol++;
|
vol++;
|
||||||
rb->sound_set(SOUND_VOLUME, vol);
|
rb->sound_set(SOUND_VOLUME, vol);
|
||||||
rb->global_status->volume = vol;
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -617,7 +616,6 @@ int beatboxmain()
|
||||||
{
|
{
|
||||||
vol--;
|
vol--;
|
||||||
rb->sound_set(SOUND_VOLUME, vol);
|
rb->sound_set(SOUND_VOLUME, vol);
|
||||||
rb->global_status->volume = vol;
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
|
@ -878,7 +878,6 @@ void M_SystemVol(int choice)
|
||||||
{
|
{
|
||||||
systemvol-=5;
|
systemvol-=5;
|
||||||
rb->sound_set(SOUND_VOLUME, systemvol);
|
rb->sound_set(SOUND_VOLUME, systemvol);
|
||||||
rb->global_status->volume = systemvol;
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
|
@ -886,7 +885,6 @@ void M_SystemVol(int choice)
|
||||||
{
|
{
|
||||||
systemvol+=5;
|
systemvol+=5;
|
||||||
rb->sound_set(SOUND_VOLUME, systemvol);
|
rb->sound_set(SOUND_VOLUME, systemvol);
|
||||||
rb->global_status->volume = systemvol;
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -601,7 +601,6 @@ static int midimain(const void * filename)
|
||||||
{
|
{
|
||||||
vol++;
|
vol++;
|
||||||
rb->sound_set(SOUND_VOLUME, vol);
|
rb->sound_set(SOUND_VOLUME, vol);
|
||||||
rb->global_status->volume = vol;
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -614,7 +613,6 @@ static int midimain(const void * filename)
|
||||||
{
|
{
|
||||||
vol--;
|
vol--;
|
||||||
rb->sound_set(SOUND_VOLUME, vol);
|
rb->sound_set(SOUND_VOLUME, vol);
|
||||||
rb->global_status->volume = vol;
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1897,10 +1897,8 @@ static void osd_set_volume(int delta)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Sync the global settings */
|
/* Sync the global settings */
|
||||||
if (vol != rb->global_status->volume) {
|
if (vol != rb->global_status->volume)
|
||||||
rb->sound_set(SOUND_VOLUME, vol);
|
rb->sound_set(SOUND_VOLUME, vol);
|
||||||
rb->global_status->volume = vol;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Update the volume display */
|
/* Update the volume display */
|
||||||
osd_refresh(OSD_REFRESH_VOLUME);
|
osd_refresh(OSD_REFRESH_VOLUME);
|
||||||
|
|
|
@ -2131,7 +2131,6 @@ enum plugin_status plugin_start(const void* parameter)
|
||||||
{
|
{
|
||||||
vol++;
|
vol++;
|
||||||
rb->sound_set(SOUND_VOLUME, vol);
|
rb->sound_set(SOUND_VOLUME, vol);
|
||||||
rb->global_status->volume = vol;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
osc_popupmsg(OSC_MSG_VOLUME, vol);
|
osc_popupmsg(OSC_MSG_VOLUME, vol);
|
||||||
|
@ -2147,7 +2146,6 @@ enum plugin_status plugin_start(const void* parameter)
|
||||||
{
|
{
|
||||||
vol--;
|
vol--;
|
||||||
rb->sound_set(SOUND_VOLUME, vol);
|
rb->sound_set(SOUND_VOLUME, vol);
|
||||||
rb->global_status->volume = vol;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
osc_popupmsg(OSC_MSG_VOLUME, vol);
|
osc_popupmsg(OSC_MSG_VOLUME, vol);
|
||||||
|
|
|
@ -174,7 +174,6 @@ static void set_frequency(int index)
|
||||||
#ifndef HAVE_VOLUME_IN_LIST
|
#ifndef HAVE_VOLUME_IN_LIST
|
||||||
static void set_volume(int value)
|
static void set_volume(int value)
|
||||||
{
|
{
|
||||||
rb->global_status->volume = value;
|
|
||||||
rb->sound_set(SOUND_VOLUME, value);
|
rb->sound_set(SOUND_VOLUME, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -654,7 +654,6 @@ static void change_volume(int delta) {
|
||||||
else if (vol < minvol) vol = minvol;
|
else if (vol < minvol) vol = minvol;
|
||||||
if (vol != rb->global_status->volume) {
|
if (vol != rb->global_status->volume) {
|
||||||
rb->sound_set(SOUND_VOLUME, vol);
|
rb->sound_set(SOUND_VOLUME, vol);
|
||||||
rb->global_status->volume = vol;
|
|
||||||
rb->lcd_putsxyf(0,0, "%d", vol);
|
rb->lcd_putsxyf(0,0, "%d", vol);
|
||||||
rb->lcd_update();
|
rb->lcd_update();
|
||||||
rb->sleep(HZ/12);
|
rb->sleep(HZ/12);
|
||||||
|
|
|
@ -316,6 +316,11 @@ void sound_set_volume(int value)
|
||||||
if (!audio_is_initialized)
|
if (!audio_is_initialized)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
#ifndef BOOTLOADER
|
||||||
|
global_status.volume = value;
|
||||||
|
global_status.last_volume_change = current_tick;
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(AUDIOHW_HAVE_CLIPPING)
|
#if defined(AUDIOHW_HAVE_CLIPPING)
|
||||||
audiohw_set_volume(value);
|
audiohw_set_volume(value);
|
||||||
#else
|
#else
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue