forked from len0rd/rockbox
Move the setvol wrapper function to misc.c and use it in more places instead of doing the same checks everywhere
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@13524 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
dfb071d92e
commit
f46657ec5a
7 changed files with 25 additions and 34 deletions
|
|
@ -126,16 +126,6 @@ void fade(bool fade_in)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* set volume */
|
|
||||||
void setvol(void)
|
|
||||||
{
|
|
||||||
if (global_settings.volume < sound_min(SOUND_VOLUME))
|
|
||||||
global_settings.volume = sound_min(SOUND_VOLUME);
|
|
||||||
if (global_settings.volume > sound_max(SOUND_VOLUME))
|
|
||||||
global_settings.volume = sound_max(SOUND_VOLUME);
|
|
||||||
sound_set_volume(global_settings.volume);
|
|
||||||
settings_save();
|
|
||||||
}
|
|
||||||
/* return true if screen restore is needed
|
/* return true if screen restore is needed
|
||||||
return false otherwise
|
return false otherwise
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,6 @@
|
||||||
|
|
||||||
void fade(bool fade_in);
|
void fade(bool fade_in);
|
||||||
bool gui_wps_display(void);
|
bool gui_wps_display(void);
|
||||||
void setvol(void);
|
|
||||||
bool update_onvol_change(struct gui_wps * gwps);
|
bool update_onvol_change(struct gui_wps * gwps);
|
||||||
bool update(struct gui_wps *gwps);
|
bool update(struct gui_wps *gwps);
|
||||||
bool ffwd_rew(int button);
|
bool ffwd_rew(int button);
|
||||||
|
|
|
||||||
|
|
@ -876,13 +876,7 @@ unsigned gui_synclist_do_button(struct gui_synclist * lists,
|
||||||
/* up two because the falthrough brings it down one */
|
/* up two because the falthrough brings it down one */
|
||||||
case ACTION_LIST_VOLDOWN:
|
case ACTION_LIST_VOLDOWN:
|
||||||
global_settings.volume--;
|
global_settings.volume--;
|
||||||
|
setvol();
|
||||||
if (global_settings.volume < sound_min(SOUND_VOLUME))
|
|
||||||
global_settings.volume = sound_min(SOUND_VOLUME);
|
|
||||||
if (global_settings.volume > sound_max(SOUND_VOLUME))
|
|
||||||
global_settings.volume = sound_max(SOUND_VOLUME);
|
|
||||||
sound_set_volume(global_settings.volume);
|
|
||||||
settings_save();
|
|
||||||
return button;
|
return button;
|
||||||
#endif
|
#endif
|
||||||
case ACTION_STD_PREV:
|
case ACTION_STD_PREV:
|
||||||
|
|
|
||||||
15
apps/misc.c
15
apps/misc.c
|
|
@ -47,6 +47,7 @@
|
||||||
#include "splash.h"
|
#include "splash.h"
|
||||||
#include "tagcache.h"
|
#include "tagcache.h"
|
||||||
#include "scrobbler.h"
|
#include "scrobbler.h"
|
||||||
|
#include "sound.h"
|
||||||
#ifdef HAVE_MMC
|
#ifdef HAVE_MMC
|
||||||
#include "ata_mmc.h"
|
#include "ata_mmc.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -969,3 +970,17 @@ void check_bootfile(bool do_rolo)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* check range, set volume and save settings */
|
||||||
|
void setvol(void)
|
||||||
|
{
|
||||||
|
const int min_vol = sound_min(SOUND_VOLUME);
|
||||||
|
const int max_vol = sound_max(SOUND_VOLUME);
|
||||||
|
if (global_settings.volume < min_vol)
|
||||||
|
global_settings.volume = min_vol;
|
||||||
|
if (global_settings.volume > max_vol)
|
||||||
|
global_settings.volume = max_vol;
|
||||||
|
sound_set_volume(global_settings.volume);
|
||||||
|
settings_save();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -106,4 +106,7 @@ void check_bootfile(bool do_rolo);
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* check range, set volume and save settings */
|
||||||
|
void setvol(void);
|
||||||
|
|
||||||
#endif /* MISC_H */
|
#endif /* MISC_H */
|
||||||
|
|
|
||||||
|
|
@ -657,21 +657,15 @@ int radio_screen(void)
|
||||||
case ACTION_SETTINGS_INC:
|
case ACTION_SETTINGS_INC:
|
||||||
case ACTION_SETTINGS_INCREPEAT:
|
case ACTION_SETTINGS_INCREPEAT:
|
||||||
global_settings.volume++;
|
global_settings.volume++;
|
||||||
if(global_settings.volume > sound_max(SOUND_VOLUME))
|
setvol();
|
||||||
global_settings.volume = sound_max(SOUND_VOLUME);
|
|
||||||
sound_set_volume(global_settings.volume);
|
|
||||||
update_screen = true;
|
update_screen = true;
|
||||||
settings_save();
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ACTION_SETTINGS_DEC:
|
case ACTION_SETTINGS_DEC:
|
||||||
case ACTION_SETTINGS_DECREPEAT:
|
case ACTION_SETTINGS_DECREPEAT:
|
||||||
global_settings.volume--;
|
global_settings.volume--;
|
||||||
if(global_settings.volume < sound_min(SOUND_VOLUME))
|
setvol();
|
||||||
global_settings.volume = sound_min(SOUND_VOLUME);
|
|
||||||
sound_set_volume(global_settings.volume);
|
|
||||||
update_screen = true;
|
update_screen = true;
|
||||||
settings_save();
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ACTION_FM_PLAY:
|
case ACTION_FM_PLAY:
|
||||||
|
|
|
||||||
|
|
@ -1052,10 +1052,8 @@ bool recording_screen(bool no_source)
|
||||||
switch(cursor)
|
switch(cursor)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
if(global_settings.volume <
|
global_settings.volume++;
|
||||||
sound_max(SOUND_VOLUME))
|
setvol();
|
||||||
global_settings.volume++;
|
|
||||||
sound_set_volume(global_settings.volume);
|
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
if(global_settings.rec_source == AUDIO_SRC_MIC)
|
if(global_settings.rec_source == AUDIO_SRC_MIC)
|
||||||
|
|
@ -1120,10 +1118,8 @@ bool recording_screen(bool no_source)
|
||||||
switch(cursor)
|
switch(cursor)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
if(global_settings.volume >
|
global_settings.volume--;
|
||||||
sound_min(SOUND_VOLUME))
|
setvol();
|
||||||
global_settings.volume--;
|
|
||||||
sound_set_volume(global_settings.volume);
|
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
if(global_settings.rec_source == AUDIO_SRC_MIC)
|
if(global_settings.rec_source == AUDIO_SRC_MIC)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue