summaryrefslogtreecommitdiffstats
path: root/apps/menus
diff options
context:
space:
mode:
authorPurlingNayuki <cyq.yzfl@gmail.com>2013-12-21 21:33:54 +0800
committerJonathan Gordon <rockbox@jdgordon.info>2014-01-13 11:32:03 +0100
commitf0bec023d9ff45cede09274dff12f015f0830a38 (patch)
tree88af20d2941735f441491762daa4139d1bbbbed0 /apps/menus
parent31dfabfa254235516dde148f16fa2ac4d522944d (diff)
downloadrockbox-f0bec023d9ff45cede09274dff12f015f0830a38.tar.gz
rockbox-f0bec023d9ff45cede09274dff12f015f0830a38.tar.bz2
rockbox-f0bec023d9ff45cede09274dff12f015f0830a38.zip
Implement volume limiter feature
Add a "volume limit" parameter to the configuration file. The maximum value of volume setting in sound menu will be limited to the same as volume limit. Also each time when setvol() is excuted, Rockbox will check if the global_settings.volume value larger than global_settings.volume_limit. If larger, take the value of volume_limit instead. The volume_limit argument shares the same maximum and minimum values with volume argument, while taking the maximum volume as its default value. Change-Id: I8ca9bc6ea6e617b48fc346aae5f2a0a1d259ae36 Reviewed-on: http://gerrit.rockbox.org/697 Reviewed-by: Jonathan Gordon <rockbox@jdgordon.info>
Diffstat (limited to 'apps/menus')
-rw-r--r--apps/menus/sound_menu.c41
1 files changed, 41 insertions, 0 deletions
diff --git a/apps/menus/sound_menu.c b/apps/menus/sound_menu.c
index 28cc257193..8913266a5f 100644
--- a/apps/menus/sound_menu.c
+++ b/apps/menus/sound_menu.c
@@ -34,10 +34,50 @@
#include "menu_common.h"
#include "splash.h"
#include "kernel.h"
+#include "talk.h"
+#include "option_select.h"
+#include "misc.h"
+
+static int32_t get_dec_talkid(int value, int unit)
+{
+ return TALK_ID_DECIMAL(value, 1, unit);
+}
+
+static int volume_limit_callback(int action,const struct menu_item_ex *this_item)
+{
+ (void)this_item;
+
+ static struct int_setting volume_limit_int_setting;
+ volume_limit_int_setting.option_callback = NULL;
+ volume_limit_int_setting.unit = UNIT_DB;
+ volume_limit_int_setting.min = sound_min(SOUND_VOLUME);
+ volume_limit_int_setting.max = sound_max(SOUND_VOLUME);
+ volume_limit_int_setting.step = sound_steps(SOUND_VOLUME);
+ volume_limit_int_setting.formatter = NULL;
+ volume_limit_int_setting.get_talk_id = get_dec_talkid;
+
+ struct settings_list setting;
+ setting.flags = F_BANFROMQS|F_INT_SETTING|F_T_INT|F_NO_WRAP;
+ setting.lang_id = LANG_VOLUME_LIMIT;
+ setting.default_val.int_ = sound_max(SOUND_VOLUME);
+ setting.int_setting = &volume_limit_int_setting;
+
+ switch (action)
+ {
+ case ACTION_ENTER_MENUITEM:
+ setting.setting = &global_settings.volume_limit;
+ option_screen(&setting, NULL, false, ID2P(LANG_VOLUME_LIMIT));
+ case ACTION_EXIT_MENUITEM: /* on exit */
+ setvol();
+ break;
+ }
+ return action;
+}
/***********************************/
/* SOUND MENU */
MENUITEM_SETTING(volume, &global_settings.volume, NULL);
+MENUITEM_SETTING(volume_limit, &global_settings.volume_limit, volume_limit_callback);
#ifdef AUDIOHW_HAVE_BASS
MENUITEM_SETTING(bass, &global_settings.bass,
#ifdef HAVE_SW_TONE_CONTROLS
@@ -171,6 +211,7 @@ static int timestretch_callback(int action,const struct menu_item_ex *this_item)
MAKE_MENU(sound_settings, ID2P(LANG_SOUND_SETTINGS), NULL, Icon_Audio,
&volume
+ ,&volume_limit
#ifdef AUDIOHW_HAVE_BASS
,&bass
#endif