summaryrefslogtreecommitdiff
path: root/apps/menus/sound_menu.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/menus/sound_menu.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/menus/sound_menu.c')
-rw-r--r--apps/menus/sound_menu.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/apps/menus/sound_menu.c b/apps/menus/sound_menu.c
index 7c04662233..69e8e3676a 100644
--- a/apps/menus/sound_menu.c
+++ b/apps/menus/sound_menu.c
@@ -225,7 +225,7 @@ static int timestretch_callback(int action,const struct menu_item_ex *this_item)
225#endif 225#endif
226 226
227#ifdef HAVE_SPEAKER 227#ifdef HAVE_SPEAKER
228 MENUITEM_SETTING(speaker_enabled, &global_settings.speaker_enabled, NULL); 228 MENUITEM_SETTING(speaker_mode, &global_settings.speaker_mode, NULL);
229#endif 229#endif
230 230
231#ifdef AUDIOHW_HAVE_EQ 231#ifdef AUDIOHW_HAVE_EQ
@@ -269,7 +269,7 @@ MAKE_MENU(sound_settings, ID2P(LANG_SOUND_SETTINGS), NULL, Icon_Audio,
269 ,&mdb_harmonics,&mdb_center,&mdb_shape 269 ,&mdb_harmonics,&mdb_center,&mdb_shape
270#endif 270#endif
271#ifdef HAVE_SPEAKER 271#ifdef HAVE_SPEAKER
272 ,&speaker_enabled 272 ,&speaker_mode
273#endif 273#endif
274 ); 274 );
275 275