Make the mips compiler not complain when bitwise operations do not have parenthesis.
[kugel-rb.git] / apps / menus / recording_menu.c
blob435ebb6ba398e0b38548577b07dc513303e8d548
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
10 * Copyright (C) 2007 Jonathan Gordon
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
20 ****************************************************************************/
22 #include "config.h"
23 #include <stdio.h>
24 #include <stdlib.h>
25 #include <stdbool.h>
26 #include "string.h"
27 #include "system.h"
28 #include "kernel.h"
29 #include "lcd.h"
30 #include "menu.h"
31 #include "button.h"
32 #include "mp3_playback.h"
33 #include "settings.h"
34 #include "statusbar.h"
35 #include "screens.h"
36 #include "icons.h"
37 #ifdef HAVE_LCD_BITMAP
38 #include "font.h"
39 #include "scrollbar.h"
40 #endif
41 #include "lang.h"
42 #include "sprintf.h"
43 #include "talk.h"
44 #include "misc.h"
45 #include "sound.h"
46 #ifdef HAVE_RECORDING
47 #include "audio.h"
48 #if CONFIG_TUNER
49 #include "radio.h"
50 #endif
51 #endif
52 #ifdef HAVE_RECORDING
53 #include "peakmeter.h"
54 #include "mas.h"
55 #endif
56 #include "splash.h"
57 #if CONFIG_CODEC == SWCODEC
58 #include "metadata.h"
59 #include "dsp.h"
60 #include "menus/eq_menu.h"
61 #ifdef HAVE_RECORDING
62 #include "enc_config.h"
63 #endif
64 #include "general.h"
65 #endif
66 #include "action.h"
67 #include "recording.h"
68 #include "sound_menu.h"
69 #include "option_select.h"
70 #include "settings_list.h"
71 #include "list.h"
72 #include "viewport.h"
73 #include "exported_menus.h"
75 static bool no_source_in_menu = false;
76 static int recmenu_callback(int action,const struct menu_item_ex *this_item);
78 static int recsource_func(void)
80 int n_opts = REC_NUM_SOURCES;
82 static const struct opt_items names[AUDIO_NUM_SOURCES] = {
83 HAVE_MIC_REC_([AUDIO_SRC_MIC]
84 = { STR(LANG_RECORDING_SRC_MIC) },)
85 HAVE_LINE_REC_([AUDIO_SRC_LINEIN]
86 = { STR(LANG_LINE_IN) },)
87 HAVE_SPDIF_REC_([AUDIO_SRC_SPDIF]
88 = { STR(LANG_RECORDING_SRC_DIGITAL) },)
89 HAVE_FMRADIO_REC_([AUDIO_SRC_FMRADIO]
90 = { STR(LANG_FM_RADIO) },)
93 /* caveat: assumes it's the last item! */
94 #ifdef HAVE_FMRADIO_REC
95 if (!radio_hardware_present())
96 n_opts--;
97 #endif
99 return set_option(str(LANG_RECORDING_SOURCE),
100 &global_settings.rec_source, INT, names,
101 n_opts, NULL );
103 MENUITEM_FUNCTION(recsource, 0, ID2P(LANG_RECORDING_SOURCE),
104 recsource_func, NULL, recmenu_callback, Icon_Menu_setting);
106 #if CONFIG_CODEC == SWCODEC
107 /* Makes an options list from a source list of options and indexes */
108 static void make_options_from_indexes(const struct opt_items *src_names,
109 const long *src_indexes,
110 int n_indexes,
111 struct opt_items *dst_names)
113 while (--n_indexes >= 0)
114 dst_names[n_indexes] = src_names[src_indexes[n_indexes]];
115 } /* make_options_from_indexes */
118 #endif /* CONFIG_CODEC == SWCODEC */
120 static int recfrequency_func(void)
122 #if CONFIG_CODEC == MAS3587F
123 static const struct opt_items names[6] = {
124 { "44.1kHz", TALK_ID(44, UNIT_KHZ) },
125 { "48kHz", TALK_ID(48, UNIT_KHZ) },
126 { "32kHz", TALK_ID(32, UNIT_KHZ) },
127 { "22.05kHz", TALK_ID(22, UNIT_KHZ) },
128 { "24kHz", TALK_ID(24, UNIT_KHZ) },
129 { "16kHz", TALK_ID(16, UNIT_KHZ) }
131 return set_option(str(LANG_RECORDING_FREQUENCY),
132 &global_settings.rec_frequency, INT,
133 names, 6, NULL );
134 #endif /* CONFIG_CODEC == MAS3587F */
136 #if CONFIG_CODEC == SWCODEC
137 static const struct opt_items names[REC_NUM_FREQ] = {
138 REC_HAVE_96_([REC_FREQ_96] = { "96kHz", TALK_ID(96, UNIT_KHZ) },)
139 REC_HAVE_88_([REC_FREQ_88] = { "88.2kHz", TALK_ID(88, UNIT_KHZ) },)
140 REC_HAVE_64_([REC_FREQ_64] = { "64kHz", TALK_ID(64, UNIT_KHZ) },)
141 REC_HAVE_48_([REC_FREQ_48] = { "48kHz", TALK_ID(48, UNIT_KHZ) },)
142 REC_HAVE_44_([REC_FREQ_44] = { "44.1kHz", TALK_ID(44, UNIT_KHZ) },)
143 REC_HAVE_32_([REC_FREQ_32] = { "32kHz", TALK_ID(32, UNIT_KHZ) },)
144 REC_HAVE_24_([REC_FREQ_24] = { "24kHz", TALK_ID(24, UNIT_KHZ) },)
145 REC_HAVE_22_([REC_FREQ_22] = { "22.05kHz", TALK_ID(22, UNIT_KHZ) },)
146 REC_HAVE_16_([REC_FREQ_16] = { "16kHz", TALK_ID(16, UNIT_KHZ) },)
147 REC_HAVE_12_([REC_FREQ_12] = { "12kHz", TALK_ID(12, UNIT_KHZ) },)
148 REC_HAVE_11_([REC_FREQ_11] = { "11.025kHz", TALK_ID(11, UNIT_KHZ) },)
149 REC_HAVE_8_( [REC_FREQ_8 ] = { "8kHz", TALK_ID( 8, UNIT_KHZ) },)
152 struct opt_items opts[REC_NUM_FREQ];
153 unsigned long table[REC_NUM_FREQ];
154 int n_opts;
155 int rec_frequency;
156 bool ret;
158 #ifdef HAVE_SPDIF_REC
159 if (global_settings.rec_source == REC_SRC_SPDIF)
161 /* Inform user that frequency follows the source's frequency */
162 opts[0].string = ID2P(LANG_SOURCE_FREQUENCY);
163 opts[0].voice_id = LANG_SOURCE_FREQUENCY;
164 n_opts = 1;
165 rec_frequency = 0;
167 else
168 #endif
170 struct encoder_caps caps;
171 struct encoder_config cfg;
173 cfg.rec_format = global_settings.rec_format;
174 global_to_encoder_config(&cfg);
176 if (!enc_get_caps(&cfg, &caps, true))
177 return false;
179 /* Construct samplerate menu based upon encoder settings */
180 n_opts = make_list_from_caps32(REC_SAMPR_CAPS, NULL,
181 caps.samplerate_caps, table);
183 if (n_opts == 0)
184 return false; /* No common flags...?? */
186 make_options_from_indexes(names, table, n_opts, opts);
188 /* Find closest rate that the potentially restricted list
189 comes to */
190 make_list_from_caps32(REC_SAMPR_CAPS, rec_freq_sampr,
191 caps.samplerate_caps, table);
193 rec_frequency = round_value_to_list32(
194 rec_freq_sampr[global_settings.rec_frequency],
195 table, n_opts, false);
198 ret = set_option(str(LANG_RECORDING_FREQUENCY),
199 &rec_frequency, INT, opts, n_opts, NULL );
201 if (!ret
202 HAVE_SPDIF_REC_( && global_settings.rec_source != REC_SRC_SPDIF)
205 /* Translate back to full index */
206 global_settings.rec_frequency =
207 round_value_to_list32(table[rec_frequency],
208 rec_freq_sampr,
209 REC_NUM_FREQ,
210 false);
213 return ret;
214 #endif /* CONFIG_CODEC == SWCODEC */
215 } /* recfrequency */
216 MENUITEM_FUNCTION(recfrequency, 0, ID2P(LANG_RECORDING_FREQUENCY),
217 recfrequency_func, NULL, NULL, Icon_Menu_setting);
220 static int recchannels_func(void)
222 static const struct opt_items names[CHN_NUM_MODES] = {
223 [CHN_MODE_STEREO] = { STR(LANG_CHANNEL_STEREO) },
224 [CHN_MODE_MONO] = { STR(LANG_CHANNEL_MONO) }
226 #if CONFIG_CODEC == MAS3587F
227 return set_option(str(LANG_CHANNELS),
228 &global_settings.rec_channels, INT,
229 names, CHN_NUM_MODES, NULL );
230 #endif /* CONFIG_CODEC == MAS3587F */
232 #if CONFIG_CODEC == SWCODEC
233 struct opt_items opts[CHN_NUM_MODES];
234 long table[CHN_NUM_MODES];
235 struct encoder_caps caps;
236 struct encoder_config cfg;
237 int n_opts;
238 int rec_channels;
239 bool ret;
241 cfg.rec_format = global_settings.rec_format;
242 global_to_encoder_config(&cfg);
244 if (!enc_get_caps(&cfg, &caps, true))
245 return false;
247 n_opts = make_list_from_caps32(CHN_CAP_ALL, NULL,
248 caps.channel_caps, table);
250 rec_channels = round_value_to_list32(global_settings.rec_channels,
251 table, n_opts, false);
253 make_options_from_indexes(names, table, n_opts, opts);
255 ret = set_option(str(LANG_CHANNELS), &rec_channels,
256 INT, opts, n_opts, NULL );
258 if (!ret)
259 global_settings.rec_channels = table[rec_channels];
261 return ret;
262 #endif /* CONFIG_CODEC == SWCODEC */
264 MENUITEM_FUNCTION(recchannels, 0, ID2P(LANG_CHANNELS),
265 recchannels_func, NULL, NULL, Icon_Menu_setting);
267 #if CONFIG_CODEC == SWCODEC
269 static int recmonomode_func(void)
271 static const struct opt_items names[3] = {
272 [0] = { STR(LANG_CHANNEL_LEFTRIGHT) },
273 [1] = { STR(LANG_CHANNEL_LEFT) },
274 [2] = { STR(LANG_CHANNEL_RIGHT) },
277 int rec_mono_mode = global_settings.rec_mono_mode;
278 bool ret = set_option(str(LANG_RECORDING_MONO_MODE), &rec_mono_mode,
279 INT, names, 3, NULL );
281 if (rec_mono_mode != global_settings.rec_mono_mode)
282 global_settings.rec_mono_mode = rec_mono_mode;
284 return ret;
286 MENUITEM_FUNCTION(recmonomode, 0, ID2P(LANG_RECORDING_MONO_MODE),
287 recmonomode_func, NULL, NULL, Icon_Menu_setting);
289 static int recformat_func(void)
291 static const struct opt_items names[REC_NUM_FORMATS] = {
292 [REC_FORMAT_AIFF] = { STR(LANG_AFMT_AIFF) },
293 [REC_FORMAT_MPA_L3] = { STR(LANG_AFMT_MPA_L3) },
294 [REC_FORMAT_WAVPACK] = { STR(LANG_AFMT_WAVPACK) },
295 [REC_FORMAT_PCM_WAV] = { STR(LANG_AFMT_PCM_WAV) },
298 int rec_format = global_settings.rec_format;
299 bool res = set_option(str(LANG_RECORDING_FORMAT), &rec_format, INT,
300 names, REC_NUM_FORMATS, NULL );
302 if (rec_format != global_settings.rec_format)
304 global_settings.rec_format = rec_format;
305 enc_global_settings_apply();
308 return res;
309 } /* recformat */
310 MENUITEM_FUNCTION(recformat, 0, ID2P(LANG_RECORDING_FORMAT),
311 recformat_func, NULL, NULL, Icon_Menu_setting);
313 MENUITEM_FUNCTION(enc_global_config_menu_item, 0, ID2P(LANG_ENCODER_SETTINGS),
314 (int(*)(void))enc_global_config_menu,
315 NULL, NULL, Icon_Submenu);
317 #endif /* CONFIG_CODEC == SWCODEC */
320 static int recmenu_callback(int action,const struct menu_item_ex *this_item)
322 switch (action)
324 case ACTION_REQUEST_MENUITEM:
325 if (this_item == &recsource && no_source_in_menu)
326 return ACTION_EXIT_MENUITEM;
327 break;
329 return action;
331 #if CONFIG_CODEC == MAS3587F
332 MENUITEM_SETTING(rec_quality, &global_settings.rec_quality, NULL);
333 MENUITEM_SETTING(rec_editable, &global_settings.rec_editable, NULL);
334 #endif
336 MENUITEM_SETTING(rec_split_type, &global_settings.rec_split_type, NULL);
337 MENUITEM_SETTING(rec_split_method, &global_settings.rec_split_method, NULL);
338 MENUITEM_SETTING(rec_timesplit, &global_settings.rec_timesplit, NULL);
339 MENUITEM_SETTING(rec_sizesplit, &global_settings.rec_sizesplit, NULL);
340 MAKE_MENU(filesplitoptionsmenu, ID2P(LANG_RECORD_TIMESPLIT), NULL, Icon_NOICON,
341 &rec_split_method, &rec_split_type, &rec_timesplit, &rec_sizesplit);
344 MENUITEM_SETTING(rec_prerecord_time, &global_settings.rec_prerecord_time, NULL);
346 static int clear_rec_directory(void)
348 strcpy(global_settings.rec_directory, REC_BASE_DIR);
349 splash(HZ, ID2P(LANG_RESET_DONE_CLEAR));
350 return false;
352 MENUITEM_FUNCTION(clear_rec_directory_item, 0, ID2P(LANG_CLEAR_REC_DIR),
353 clear_rec_directory, NULL, NULL, Icon_Folder);
355 MENUITEM_SETTING(cliplight, &global_settings.cliplight, NULL);
357 #ifdef HAVE_AGC
358 static int agc_preset_func(void)
360 static const struct opt_items names[] = {
361 { STR(LANG_OFF) },
362 { STR(LANG_AGC_SAFETY) },
363 { STR(LANG_AGC_LIVE) },
364 { STR(LANG_AGC_DJSET) },
365 { STR(LANG_AGC_MEDIUM) },
366 { STR(LANG_AGC_VOICE) },
368 if (global_settings.rec_source)
369 return set_option(str(LANG_RECORDING_AGC_PRESET),
370 &global_settings.rec_agc_preset_line,
371 INT, names, 6, NULL );
372 else
373 return set_option(str(LANG_RECORDING_AGC_PRESET),
374 &global_settings.rec_agc_preset_mic,
375 INT, names, 6, NULL );
378 static int agc_cliptime_func(void)
380 static const struct opt_items names[] = {
381 { "200ms", TALK_ID(200, UNIT_MS) },
382 { "400ms", TALK_ID(400, UNIT_MS) },
383 { "600ms", TALK_ID(600, UNIT_MS) },
384 { "800ms", TALK_ID(800, UNIT_MS) },
385 { "1s", TALK_ID(1, UNIT_SEC) }
387 return set_option(str(LANG_RECORDING_AGC_CLIPTIME),
388 &global_settings.rec_agc_cliptime,
389 INT, names, 5, NULL );
391 MENUITEM_FUNCTION(agc_preset, 0, ID2P(LANG_RECORDING_AGC_PRESET),
392 agc_preset_func, NULL, NULL, Icon_Menu_setting);
393 MENUITEM_FUNCTION(agc_cliptime, 0, ID2P(LANG_RECORDING_AGC_CLIPTIME),
394 agc_cliptime_func, NULL, NULL, Icon_Menu_setting);
395 #endif /* HAVE_AGC */
397 /** Rec trigger **/
398 enum trigger_menu_option
400 TRIGGER_MODE,
401 TRIGGER_TYPE,
402 PRERECORD_TIME,
403 START_THRESHOLD,
404 START_DURATION,
405 STOP_THRESHOLD,
406 STOP_POSTREC,
407 STOP_GAP,
408 TRIG_OPTION_COUNT,
411 static enum themable_icons trigger_get_icon(int selected_item, void * data)
413 (void)data;
414 if ((selected_item % 2) == 0) /* header */
415 return Icon_Menu_setting;
416 return Icon_NOICON;
419 static char * trigger_get_name(int selected_item, void * data,
420 char * buffer, size_t buffer_len)
422 const struct settings_list **settings =
423 (const struct settings_list **)data;
424 const struct settings_list *s = settings[selected_item / 2];
425 if ((selected_item % 2) == 0) /* header */
426 return P2STR(ID2P(s->lang_id));
427 else
429 int temp;
430 temp = option_value_as_int(s);
431 if ((selected_item / 2 == START_THRESHOLD ||
432 selected_item / 2 == STOP_THRESHOLD) &&
433 temp == 0)
435 return str(LANG_OFF);
437 return option_get_valuestring(s, buffer, buffer_len, temp);
440 static void trigger_speak_item(const struct settings_list **settings,
441 int selected_setting, bool title)
443 const struct settings_list *s = settings[selected_setting];
444 int temp;
445 if (!global_settings.talk_menu)
446 return;
447 if (title)
448 talk_id(s->lang_id, false);
449 temp = option_value_as_int(s);
450 if ((selected_setting == START_THRESHOLD ||
451 selected_setting == STOP_THRESHOLD) &&
452 temp == 0)
454 talk_id(LANG_OFF, title?true:false);
455 } else {
456 option_talk_value(s, temp, title?true:false);
459 int rectrigger(void)
461 struct viewport vp[NB_SCREENS], triggervp[NB_SCREENS];
462 struct gui_synclist lists;
463 int i, action = ACTION_REDRAW;
464 bool done = false, changed = true;
465 const struct settings_list *settings[TRIG_OPTION_COUNT];
467 int pm_x[NB_SCREENS];
468 int pm_y[NB_SCREENS];
469 int pm_h[NB_SCREENS];
470 int trig_xpos[NB_SCREENS];
471 int trig_ypos[NB_SCREENS];
472 int trig_width[NB_SCREENS];
474 int old_start_thres_db = global_settings.rec_start_thres_db;
475 int old_start_thres_linear = global_settings.rec_start_thres_linear;
476 int old_start_duration = global_settings.rec_start_duration;
477 int old_prerecord_time = global_settings.rec_prerecord_time;
478 int old_stop_thres_db = global_settings.rec_stop_thres_db;
479 int old_stop_thres_linear = global_settings.rec_stop_thres_linear;
480 int old_stop_postrec = global_settings.rec_stop_postrec;
481 int old_stop_gap = global_settings.rec_stop_gap;
482 int old_trigger_mode = global_settings.rec_trigger_mode;
483 int old_trigger_type = global_settings.rec_trigger_type;
485 FOR_NB_SCREENS(i)
487 screens[i].clear_display();
488 screens[i].update();
489 viewport_set_defaults(&vp[i], i);
490 vp[i].height -= SYSFONT_HEIGHT*2;
491 triggervp[i] = vp[i];
492 triggervp[i].y = vp[i].y + vp[i].height;
493 triggervp[i].height = SYSFONT_HEIGHT*2;
494 trig_xpos[i] = 0;
495 trig_ypos[i] = 0;
496 pm_x[i] = 0;
497 pm_y[i] = SYSFONT_HEIGHT;
498 pm_h[i] = SYSFONT_HEIGHT;
499 trig_width[i] = triggervp[i].width;
501 /* TODO: what to do if there is < 4 lines on the screen? */
503 settings[TRIGGER_MODE] =
504 find_setting(&global_settings.rec_trigger_mode, NULL);
505 settings[TRIGGER_TYPE] =
506 find_setting(&global_settings.rec_trigger_type, NULL);
507 settings[PRERECORD_TIME] =
508 find_setting(&global_settings.rec_prerecord_time, NULL);
509 settings[START_DURATION] =
510 find_setting(&global_settings.rec_start_duration, NULL);
511 settings[STOP_POSTREC] =
512 find_setting(&global_settings.rec_stop_postrec, NULL);
513 settings[STOP_GAP] =
514 find_setting(&global_settings.rec_stop_gap, NULL);
515 if (global_settings.peak_meter_dbfs) /* show the dB settings */
517 settings[START_THRESHOLD] =
518 find_setting(&global_settings.rec_start_thres_db, NULL);
519 settings[STOP_THRESHOLD] =
520 find_setting(&global_settings.rec_stop_thres_db, NULL);
522 else
524 settings[START_THRESHOLD] =
525 find_setting(&global_settings.rec_start_thres_linear, NULL);
526 settings[STOP_THRESHOLD] =
527 find_setting(&global_settings.rec_stop_thres_linear, NULL);
529 gui_synclist_init(&lists, trigger_get_name, settings, false, 2, vp);
530 gui_synclist_set_nb_items(&lists, TRIG_OPTION_COUNT*2);
531 gui_synclist_set_icon_callback(&lists, trigger_get_icon);
532 /* restart trigger with new values */
533 settings_apply_trigger();
534 peak_meter_trigger (global_settings.rec_trigger_mode != TRIG_MODE_OFF);
536 trigger_speak_item(settings, 0, true);
538 while (!done)
540 if (changed)
542 gui_synclist_draw(&lists);
543 peak_meter_trigger(global_settings.rec_trigger_mode!=TRIG_OFF);
544 settings_apply_trigger();
545 changed = false;
548 FOR_NB_SCREENS(i)
549 screens[i].set_viewport(&triggervp[i]);
550 peak_meter_draw_trig(trig_xpos, trig_ypos, trig_width, NB_SCREENS);
551 action = peak_meter_draw_get_btn(CONTEXT_SETTINGS_RECTRIGGER,
552 pm_x, pm_y, pm_h, NB_SCREENS, triggervp);
553 FOR_NB_SCREENS(i)
554 screens[i].update();
555 i = gui_synclist_get_sel_pos(&lists);
556 switch (action)
558 case ACTION_STD_CANCEL:
559 splash(HZ/2, ID2P(LANG_CANCEL));
560 global_settings.rec_start_thres_db = old_start_thres_db;
561 global_settings.rec_start_thres_linear = old_start_thres_linear;
562 global_settings.rec_start_duration = old_start_duration;
563 global_settings.rec_prerecord_time = old_prerecord_time;
564 global_settings.rec_stop_thres_db = old_stop_thres_db;
565 global_settings.rec_stop_thres_linear = old_stop_thres_linear;
566 global_settings.rec_stop_postrec = old_stop_postrec;
567 global_settings.rec_stop_gap = old_stop_gap;
568 global_settings.rec_trigger_mode = old_trigger_mode;
569 global_settings.rec_trigger_type = old_trigger_type;
570 peak_meter_trigger(global_settings.rec_trigger_mode!=TRIG_OFF);
571 settings_apply_trigger();
572 done = true;
573 break;
574 case ACTION_STD_OK:
575 done = true;
576 break;
577 case ACTION_SETTINGS_DEC:
578 case ACTION_SETTINGS_DECREPEAT:
579 option_select_next_val(settings[i/2], true, false);
580 trigger_speak_item(settings, i/2, false);
581 changed = true;
582 break;
583 case ACTION_SETTINGS_INC:
584 case ACTION_SETTINGS_INCREPEAT:
585 option_select_next_val(settings[i/2], false, false);
586 trigger_speak_item(settings, i/2, false);
587 changed = true;
588 break;
589 case ACTION_STD_PREV:
590 case ACTION_STD_PREVREPEAT:
591 i -= 2;
592 if (i<0)
593 i = (TRIG_OPTION_COUNT*2) - 2;
594 gui_synclist_select_item(&lists, i);
595 i = gui_synclist_get_sel_pos(&lists);
596 trigger_speak_item(settings, i/2, true);
597 changed = true;
598 break;
599 case ACTION_STD_NEXT:
600 case ACTION_STD_NEXTREPEAT:
601 gui_synclist_select_item(&lists, (i+2) % (TRIG_OPTION_COUNT*2));
602 i = gui_synclist_get_sel_pos(&lists);
603 trigger_speak_item(settings, i/2, true);
604 changed = true;
605 break;
608 peak_meter_trigger(false);
609 settings_save();
610 return 0;
612 MENUITEM_FUNCTION(rectrigger_item, 0, ID2P(LANG_RECORD_TRIGGER),
613 rectrigger, NULL, NULL, Icon_Menu_setting);
615 static struct browse_folder_info rec_config_browse = {RECPRESETS_DIR, SHOW_CFG};
616 int browse_folder(void *param);
617 MENUITEM_FUNCTION(browse_recconfigs, MENU_FUNC_USEPARAM, ID2P(LANG_CUSTOM_CFG),
618 browse_folder, (void*)&rec_config_browse, NULL, Icon_Config);
619 static int write_settings_file(void)
621 return settings_save_config(SETTINGS_SAVE_RECPRESETS);
623 MENUITEM_FUNCTION(save_recpresets_item, 0, ID2P(LANG_SAVE_SETTINGS),
624 write_settings_file, NULL, NULL, Icon_Config);
626 MAKE_MENU(recording_settings_menu, ID2P(LANG_RECORDING_SETTINGS),
627 NULL, Icon_Recording,
628 #if CONFIG_CODEC == MAS3587F
629 &rec_quality,
630 #endif
631 #if CONFIG_CODEC == SWCODEC
632 &recformat, &enc_global_config_menu_item,
633 #endif
634 &recfrequency, &recsource, /* recsource not shown if no_source */
635 &recchannels,
636 #if CONFIG_CODEC == SWCODEC
637 &recmonomode,
638 #endif
639 #if CONFIG_CODEC == MAS3587F
640 &rec_editable,
641 #endif
642 &filesplitoptionsmenu,
643 &rec_prerecord_time,
644 &clear_rec_directory_item,
645 #ifdef HAVE_BACKLIGHT
646 &cliplight,
647 #endif
648 &rectrigger_item,
649 #ifdef HAVE_AGC
650 &agc_preset, &agc_cliptime,
651 #endif
652 #ifdef HAVE_LCD_BITMAP
653 &peak_meter_menu,
654 #endif
655 &browse_recconfigs, &save_recpresets_item
658 bool recording_menu(bool no_source)
660 bool retval;
661 no_source_in_menu = no_source;
662 retval = do_menu(&recording_settings_menu, NULL, NULL, false) == MENU_ATTACHED_USB;
663 no_source_in_menu = false; /* always fall back to the default */
664 return retval;
667 MENUITEM_FUNCTION(recording_settings, MENU_FUNC_USEPARAM, ID2P(LANG_RECORDING_SETTINGS),
668 (int (*)(void*))recording_menu, 0, NULL, Icon_Recording);