summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apps/audio_path.c13
-rw-r--r--apps/menus/sound_menu.c4
-rw-r--r--apps/misc.c5
-rw-r--r--apps/plugin.h4
-rw-r--r--apps/recorder/recording.c4
-rw-r--r--apps/settings.c2
-rw-r--r--apps/settings.h4
-rw-r--r--apps/settings_list.c10
-rw-r--r--firmware/export/audio.h9
9 files changed, 43 insertions, 12 deletions
diff --git a/apps/audio_path.c b/apps/audio_path.c
index 6709d4421d..3f43badc25 100644
--- a/apps/audio_path.c
+++ b/apps/audio_path.c
@@ -164,3 +164,16 @@ int audio_get_spdif_sample_rate(void)
164#endif /* HAVE_SPDIF_IN */ 164#endif /* HAVE_SPDIF_IN */
165 165
166#endif /* PLATFORM_NATIVE */ 166#endif /* PLATFORM_NATIVE */
167
168#ifdef HAVE_SPEAKER
169void audio_enable_speaker(int mode)
170{
171#ifdef HAVE_HEADPHONE_DETECTION
172 /* if needed, query jack state */
173 if(mode == 2)
174 mode = !headphones_inserted();
175#endif
176 /* treat any nonzero value as enable */
177 audiohw_enable_speaker(mode);
178}
179#endif
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
diff --git a/apps/misc.c b/apps/misc.c
index 15e1b6ecad..e460eb542c 100644
--- a/apps/misc.c
+++ b/apps/misc.c
@@ -522,6 +522,11 @@ static void unplug_change(bool inserted)
522 } 522 }
523 } 523 }
524 } 524 }
525
526#ifdef HAVE_SPEAKER
527 /* update speaker status */
528 audio_enable_speaker(global_settings.speaker_mode);
529#endif
525} 530}
526#endif 531#endif
527 532
diff --git a/apps/plugin.h b/apps/plugin.h
index f781f60350..c96c4ac899 100644
--- a/apps/plugin.h
+++ b/apps/plugin.h
@@ -160,12 +160,12 @@ void* plugin_get_buffer(size_t *buffer_size);
160#define PLUGIN_MAGIC 0x526F634B /* RocK */ 160#define PLUGIN_MAGIC 0x526F634B /* RocK */
161 161
162/* increase this every time the api struct changes */ 162/* increase this every time the api struct changes */
163#define PLUGIN_API_VERSION 233 163#define PLUGIN_API_VERSION 234
164 164
165/* update this to latest version if a change to the api struct breaks 165/* update this to latest version if a change to the api struct breaks
166 backwards compatibility (and please take the opportunity to sort in any 166 backwards compatibility (and please take the opportunity to sort in any
167 new function which are "waiting" at the end of the function table) */ 167 new function which are "waiting" at the end of the function table) */
168#define PLUGIN_MIN_API_VERSION 233 168#define PLUGIN_MIN_API_VERSION 234
169 169
170/* plugin return codes */ 170/* plugin return codes */
171/* internal returns start at 0x100 to make exit(1..255) work */ 171/* internal returns start at 0x100 to make exit(1..255) work */
diff --git a/apps/recorder/recording.c b/apps/recorder/recording.c
index 1c53c8026f..4816b3bad4 100644
--- a/apps/recorder/recording.c
+++ b/apps/recorder/recording.c
@@ -1097,7 +1097,7 @@ bool recording_screen(bool no_source)
1097 1097
1098#ifdef HAVE_SPEAKER 1098#ifdef HAVE_SPEAKER
1099 /* Disable speaker to prevent feedback */ 1099 /* Disable speaker to prevent feedback */
1100 audiohw_enable_speaker(false); 1100 audio_enable_speaker(0);
1101#endif 1101#endif
1102 1102
1103 audio_init_recording(); 1103 audio_init_recording();
@@ -1959,7 +1959,7 @@ rec_abort:
1959 1959
1960#ifdef HAVE_SPEAKER 1960#ifdef HAVE_SPEAKER
1961 /* Re-enable speaker */ 1961 /* Re-enable speaker */
1962 audiohw_enable_speaker(global_settings.speaker_enabled); 1962 audio_enable_speaker(global_settings.speaker_mode);
1963#endif 1963#endif
1964 1964
1965 /* make sure the trigger is really turned off */ 1965 /* make sure the trigger is really turned off */
diff --git a/apps/settings.c b/apps/settings.c
index 992cc1f391..aa51e051e9 100644
--- a/apps/settings.c
+++ b/apps/settings.c
@@ -927,7 +927,7 @@ void settings_apply(bool read_disk)
927#endif 927#endif
928 928
929#ifdef HAVE_SPEAKER 929#ifdef HAVE_SPEAKER
930 audiohw_enable_speaker(global_settings.speaker_enabled); 930 audio_enable_speaker(global_settings.speaker_mode);
931#endif 931#endif
932 932
933 if (read_disk) 933 if (read_disk)
diff --git a/apps/settings.h b/apps/settings.h
index c79aeb37f4..5de65bb193 100644
--- a/apps/settings.h
+++ b/apps/settings.h
@@ -746,8 +746,8 @@ struct user_settings
746#endif 746#endif
747 747
748#ifdef HAVE_SPEAKER 748#ifdef HAVE_SPEAKER
749 bool speaker_enabled; 749 int speaker_mode; /* 0: off, 1: on, 2: auto (only if headphone detection) */
750#endif 750#endif /* HAVE_SPEAKER */
751 bool prevent_skip; 751 bool prevent_skip;
752 752
753#ifdef HAVE_TOUCHSCREEN 753#ifdef HAVE_TOUCHSCREEN
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,
diff --git a/firmware/export/audio.h b/firmware/export/audio.h
index 08a88d6325..5710f9f653 100644
--- a/firmware/export/audio.h
+++ b/firmware/export/audio.h
@@ -232,6 +232,15 @@ int audio_get_spdif_sample_rate(void);
232void audio_spdif_set_monitor(int monitor_spdif); 232void audio_spdif_set_monitor(int monitor_spdif);
233#endif /* HAVE_SPDIF_IN */ 233#endif /* HAVE_SPDIF_IN */
234 234
235#ifdef HAVE_SPEAKER
236/* enable/disable the speaker: 0=off, 1=on, 2=on if jack unpluged, off otherwise
237 * NOTE this is a one time thing, this function doesn't implement the logic to
238 * check for jack events, it merely changes the speaker state to the expected
239 * state based on the requested mode.
240 */
241void audio_enable_speaker(int mode);
242#endif
243
235/***********************************************************************/ 244/***********************************************************************/
236/* audio event handling */ 245/* audio event handling */
237enum track_event_flags 246enum track_event_flags