summaryrefslogtreecommitdiff
path: root/apps/settings_list.c
diff options
context:
space:
mode:
authorAmaury Pouly <amaury.pouly@gmail.com>2017-01-14 01:40:12 +0100
committerAmaury Pouly <amaury.pouly@gmail.com>2017-02-04 17:22:08 +0100
commit1245c5fe61f6ca8e1980a33a8b8f7ea4322829fd (patch)
tree117ae10a7d6489070321dc2d5d790daa71f7921b /apps/settings_list.c
parentd052f13999a53e440975e0192c67c8a42c75e4ea (diff)
downloadrockbox-1245c5fe61f6ca8e1980a33a8b8f7ea4322829fd.tar.gz
rockbox-1245c5fe61f6ca8e1980a33a8b8f7ea4322829fd.zip
Implement speaker enable/disable on jack (un)plug
The implementation is not very complicated but there are a few things worth noting. There was a previous "speaker enable" setting but it was a boolean. I decided to replace it with a choice setting that has 2 options (on, off) if headphones cannot be detect on this target, or 3 options (on, off, auto) if we can detect headphones. This will break the old setting on target that cannot detect jack but it makes the code more uniform and avoid maintaining two settings with more #ifdef. The third option (auto) uses the LANG_AUTO text, which I think is clear enough (disable speaker on jack plug). In order to avoid code duplication (both in apps and firmware), I decided to keep the audiohw_enable_speaker function as-is: it takes a boolean and doesn't care about the speaker policy. I introduced a new audio_enable_speaker that takes directly the mode (which follows the setting encoding): 0=off, 1=on and 2=auto. This way one calls audio_enable_speaker and it changes the speaker once to reflect the request mode. The apps code then uses this function in the places where it makes sense: on setting load, setting change and jack (un)plug event. Change-Id: I027873f698eb4bc365d7c02b515297806355d9e2
Diffstat (limited to 'apps/settings_list.c')
-rw-r--r--apps/settings_list.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/apps/settings_list.c b/apps/settings_list.c
index 58be3d2575..57763d345a 100644
--- a/apps/settings_list.c
+++ b/apps/settings_list.c
@@ -2118,9 +2118,13 @@ const struct settings_list settings[] = {
2118 false, "shortcuts instead of quickscreen", NULL), 2118 false, "shortcuts instead of quickscreen", NULL),
2119#endif 2119#endif
2120#ifdef HAVE_SPEAKER 2120#ifdef HAVE_SPEAKER
2121 OFFON_SETTING(0, speaker_enabled, LANG_ENABLE_SPEAKER, false, "speaker", 2121 CHOICE_SETTING(0, speaker_mode, LANG_ENABLE_SPEAKER, 0, "speaker mode",
2122 audiohw_enable_speaker), 2122# ifdef HAVE_HEADPHONE_DETECTION
2123#endif 2123 "on,off,auto", audio_enable_speaker, 3, ID2P(LANG_OFF), ID2P(LANG_ON), ID2P(LANG_AUTO)),
2124#else /* HAVE_HEADPHONE_DETECTION */
2125 "on,off", audio_enable_speaker, 2, ID2P(LANG_OFF), ID2P(LANG_ON)),
2126#endif /* HAVE_HEADPHONE_DETECTION */
2127#endif /* HAVE_SPEAKER */
2124#ifdef HAVE_TOUCHSCREEN 2128#ifdef HAVE_TOUCHSCREEN
2125 CHOICE_SETTING(0, touch_mode, LANG_TOUCHSCREEN_MODE, DEFAULT_TOUCHSCREEN_MODE, 2129 CHOICE_SETTING(0, touch_mode, LANG_TOUCHSCREEN_MODE, DEFAULT_TOUCHSCREEN_MODE,
2126 "touchscreen mode", "point,grid", NULL, 2, 2130 "touchscreen mode", "point,grid", NULL, 2,