Corrected ipodmini manual builds.
[kugel-rb.git] / apps / menus / recording_menu.c
blob7b99b48a2d749d55b11432c1d0d1b52f120be79c
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 "screens.h"
35 #include "icons.h"
36 #ifdef HAVE_LCD_BITMAP
37 #include "font.h"
38 #include "scrollbar.h"
39 #endif
40 #include "lang.h"
41 #include "sprintf.h"
42 #include "talk.h"
43 #include "misc.h"
44 #include "sound.h"
45 #ifdef HAVE_RECORDING
46 #include "audio.h"
47 #if CONFIG_TUNER
48 #include "radio.h"
49 #endif
50 #endif
51 #ifdef HAVE_RECORDING
52 #include "peakmeter.h"
53 #include "mas.h"
54 #endif
55 #include "splash.h"
56 #if CONFIG_CODEC == SWCODEC
57 #include "metadata.h"
58 #include "dsp.h"
59 #include "menus/eq_menu.h"
60 #ifdef HAVE_RECORDING
61 #include "enc_config.h"
62 #endif
63 #include "general.h"
64 #endif
65 #include "action.h"
66 #include "recording.h"
67 #include "sound_menu.h"
68 #include "option_select.h"
69 #include "settings_list.h"
70 #include "list.h"
71 #include "viewport.h"
72 #include "exported_menus.h"
74 static bool no_source_in_menu = false;
75 static int recmenu_callback(int action,const struct menu_item_ex *this_item);
77 static int recsource_func(void)
79 int n_opts = REC_NUM_SOURCES;
81 static const struct opt_items names[AUDIO_NUM_SOURCES] = {
82 HAVE_MIC_REC_([AUDIO_SRC_MIC]
83 = { STR(LANG_RECORDING_SRC_MIC) },)
84 HAVE_LINE_REC_([AUDIO_SRC_LINEIN]
85 = { STR(LANG_LINE_IN) },)
86 HAVE_SPDIF_REC_([AUDIO_SRC_SPDIF]
87 = { STR(LANG_RECORDING_SRC_DIGITAL) },)
88 HAVE_FMRADIO_REC_([AUDIO_SRC_FMRADIO]
89 = { STR(LANG_FM_RADIO) },)
92 /* caveat: assumes it's the last item! */
93 #ifdef HAVE_FMRADIO_REC
94 if (!radio_hardware_present())
95 n_opts--;
96 #endif
98 return set_option(str(LANG_RECORDING_SOURCE),
99 &global_settings.rec_source, INT, names,
100 n_opts, NULL );
102 MENUITEM_FUNCTION(recsource, 0, ID2P(LANG_RECORDING_SOURCE),
103 recsource_func, NULL, recmenu_callback, Icon_Menu_setting);
105 #if CONFIG_CODEC == SWCODEC
106 /* Makes an options list from a source list of options and indexes */
107 static void make_options_from_indexes(const struct opt_items *src_names,
108 const long *src_indexes,
109 int n_indexes,
110 struct opt_items *dst_names)
112 while (--n_indexes >= 0)
113 dst_names[n_indexes] = src_names[src_indexes[n_indexes]];
114 } /* make_options_from_indexes */
117 #endif /* CONFIG_CODEC == SWCODEC */
119 static int recfrequency_func(void)
121 #if CONFIG_CODEC == MAS3587F
122 static const struct opt_items names[6] = {
123 { "44.1kHz", TALK_ID(44, UNIT_KHZ) },
124 { "48kHz", TALK_ID(48, UNIT_KHZ) },
125 { "32kHz", TALK_ID(32, UNIT_KHZ) },
126 { "22.05kHz", TALK_ID(22, UNIT_KHZ) },
127 { "24kHz", TALK_ID(24, UNIT_KHZ) },
128 { "16kHz", TALK_ID(16, UNIT_KHZ) }
130 return set_option(str(LANG_RECORDING_FREQUENCY),
131 &global_settings.rec_frequency, INT,
132 names, 6, NULL );
133 #endif /* CONFIG_CODEC == MAS3587F */
135 #if CONFIG_CODEC == SWCODEC
136 static const struct opt_items names[REC_NUM_FREQ] = {
137 REC_HAVE_96_([REC_FREQ_96] = { "96kHz", TALK_ID(96, UNIT_KHZ) },)
138 REC_HAVE_88_([REC_FREQ_88] = { "88.2kHz", TALK_ID(88, UNIT_KHZ) },)
139 REC_HAVE_64_([REC_FREQ_64] = { "64kHz", TALK_ID(64, UNIT_KHZ) },)
140 REC_HAVE_48_([REC_FREQ_48] = { "48kHz", TALK_ID(48, UNIT_KHZ) },)
141 REC_HAVE_44_([REC_FREQ_44] = { "44.1kHz", TALK_ID(44, UNIT_KHZ) },)
142 REC_HAVE_32_([REC_FREQ_32] = { "32kHz", TALK_ID(32, UNIT_KHZ) },)
143 REC_HAVE_24_([REC_FREQ_24] = { "24kHz", TALK_ID(24, UNIT_KHZ) },)
144 REC_HAVE_22_([REC_FREQ_22] = { "22.05kHz", TALK_ID(22, UNIT_KHZ) },)
145 REC_HAVE_16_([REC_FREQ_16] = { "16kHz", TALK_ID(16, UNIT_KHZ) },)
146 REC_HAVE_12_([REC_FREQ_12] = { "12kHz", TALK_ID(12, UNIT_KHZ) },)
147 REC_HAVE_11_([REC_FREQ_11] = { "11.025kHz", TALK_ID(11, UNIT_KHZ) },)
148 REC_HAVE_8_( [REC_FREQ_8 ] = { "8kHz", TALK_ID( 8, UNIT_KHZ) },)
151 struct opt_items opts[REC_NUM_FREQ];
152 unsigned long table[REC_NUM_FREQ];
153 int n_opts;
154 int rec_frequency;
155 bool ret;
157 #ifdef HAVE_SPDIF_REC
158 if (global_settings.rec_source == REC_SRC_SPDIF)
160 /* Inform user that frequency follows the source's frequency */
161 opts[0].string = ID2P(LANG_SOURCE_FREQUENCY);
162 opts[0].voice_id = LANG_SOURCE_FREQUENCY;
163 n_opts = 1;
164 rec_frequency = 0;
166 else
167 #endif
169 struct encoder_caps caps;
170 struct encoder_config cfg;
172 cfg.rec_format = global_settings.rec_format;
173 global_to_encoder_config(&cfg);
175 if (!enc_get_caps(&cfg, &caps, true))
176 return false;
178 /* Construct samplerate menu based upon encoder settings */
179 n_opts = make_list_from_caps32(REC_SAMPR_CAPS, NULL,
180 caps.samplerate_caps, table);
182 if (n_opts == 0)
183 return false; /* No common flags...?? */
185 make_options_from_indexes(names, table, n_opts, opts);
187 /* Find closest rate that the potentially restricted list
188 comes to */
189 make_list_from_caps32(REC_SAMPR_CAPS, rec_freq_sampr,
190 caps.samplerate_caps, table);
192 rec_frequency = round_value_to_list32(
193 rec_freq_sampr[global_settings.rec_frequency],
194 table, n_opts, false);
197 ret = set_option(str(LANG_RECORDING_FREQUENCY),
198 &rec_frequency, INT, opts, n_opts, NULL );
200 if (!ret
201 HAVE_SPDIF_REC_( && global_settings.rec_source != REC_SRC_SPDIF)
204 /* Translate back to full index */
205 global_settings.rec_frequency =
206 round_value_to_list32(table[rec_frequency],
207 rec_freq_sampr,
208 REC_NUM_FREQ,
209 false);
212 return ret;
213 #endif /* CONFIG_CODEC == SWCODEC */
214 } /* recfrequency */
215 MENUITEM_FUNCTION(recfrequency, 0, ID2P(LANG_RECORDING_FREQUENCY),
216 recfrequency_func, NULL, NULL, Icon_Menu_setting);
219 static int recchannels_func(void)
221 static const struct opt_items names[CHN_NUM_MODES] = {
222 [CHN_MODE_STEREO] = { STR(LANG_CHANNEL_STEREO) },
223 [CHN_MODE_MONO] = { STR(LANG_CHANNEL_MONO) }
225 #if CONFIG_CODEC == MAS3587F
226 return set_option(str(LANG_CHANNELS),
227 &global_settings.rec_channels, INT,
228 names, CHN_NUM_MODES, NULL );
229 #endif /* CONFIG_CODEC == MAS3587F */
231 #if CONFIG_CODEC == SWCODEC
232 struct opt_items opts[CHN_NUM_MODES];
233 long table[CHN_NUM_MODES];
234 struct encoder_caps caps;
235 struct encoder_config cfg;
236 int n_opts;
237 int rec_channels;
238 bool ret;
240 cfg.rec_format = global_settings.rec_format;
241 global_to_encoder_config(&cfg);
243 if (!enc_get_caps(&cfg, &caps, true))
244 return false;
246 n_opts = make_list_from_caps32(CHN_CAP_ALL, NULL,
247 caps.channel_caps, table);
249 rec_channels = round_value_to_list32(global_settings.rec_channels,
250 table, n_opts, false);
252 make_options_from_indexes(names, table, n_opts, opts);
254 ret = set_option(str(LANG_CHANNELS), &rec_channels,
255 INT, opts, n_opts, NULL );
257 if (!ret)
258 global_settings.rec_channels = table[rec_channels];
260 return ret;
261 #endif /* CONFIG_CODEC == SWCODEC */
263 MENUITEM_FUNCTION(recchannels, 0, ID2P(LANG_CHANNELS),
264 recchannels_func, NULL, NULL, Icon_Menu_setting);
266 #if CONFIG_CODEC == SWCODEC
268 static int recmonomode_func(void)
270 static const struct opt_items names[3] = {
271 [0] = { STR(LANG_CHANNEL_LEFTRIGHT) },
272 [1] = { STR(LANG_CHANNEL_LEFT) },
273 [2] = { STR(LANG_CHANNEL_RIGHT) },
276 int rec_mono_mode = global_settings.rec_mono_mode;
277 bool ret = set_option(str(LANG_RECORDING_MONO_MODE), &rec_mono_mode,
278 INT, names, 3, NULL );
280 if (rec_mono_mode != global_settings.rec_mono_mode)
281 global_settings.rec_mono_mode = rec_mono_mode;
283 return ret;
285 MENUITEM_FUNCTION(recmonomode, 0, ID2P(LANG_RECORDING_MONO_MODE),
286 recmonomode_func, NULL, NULL, Icon_Menu_setting);
288 static int recformat_func(void)
290 static const struct opt_items names[REC_NUM_FORMATS] = {
291 [REC_FORMAT_AIFF] = { STR(LANG_AFMT_AIFF) },
292 [REC_FORMAT_MPA_L3] = { STR(LANG_AFMT_MPA_L3) },
293 [REC_FORMAT_WAVPACK] = { STR(LANG_AFMT_WAVPACK) },
294 [REC_FORMAT_PCM_WAV] = { STR(LANG_AFMT_PCM_WAV) },
297 int rec_format = global_settings.rec_format;
298 bool res = set_option(str(LANG_RECORDING_FORMAT), &rec_format, INT,
299 names, REC_NUM_FORMATS, NULL );
301 if (rec_format != global_settings.rec_format)
303 global_settings.rec_format = rec_format;
304 enc_global_settings_apply();
307 return res;
308 } /* recformat */
309 MENUITEM_FUNCTION(recformat, 0, ID2P(LANG_RECORDING_FORMAT),
310 recformat_func, NULL, NULL, Icon_Menu_setting);
312 MENUITEM_FUNCTION(enc_global_config_menu_item, 0, ID2P(LANG_ENCODER_SETTINGS),
313 (int(*)(void))enc_global_config_menu,
314 NULL, NULL, Icon_Submenu);
316 #endif /* CONFIG_CODEC == SWCODEC */
319 static int recmenu_callback(int action,const struct menu_item_ex *this_item)
321 switch (action)
323 case ACTION_REQUEST_MENUITEM:
324 if (this_item == &recsource && no_source_in_menu)
325 return ACTION_EXIT_MENUITEM;
326 break;
328 return action;
330 #if CONFIG_CODEC == MAS3587F
331 MENUITEM_SETTING(rec_quality, &global_settings.rec_quality, NULL);
332 MENUITEM_SETTING(rec_editable, &global_settings.rec_editable, NULL);
333 #endif
335 MENUITEM_SETTING(rec_split_type, &global_settings.rec_split_type, NULL);
336 MENUITEM_SETTING(rec_split_method, &global_settings.rec_split_method, NULL);
337 MENUITEM_SETTING(rec_timesplit, &global_settings.rec_timesplit, NULL);
338 MENUITEM_SETTING(rec_sizesplit, &global_settings.rec_sizesplit, NULL);
339 MAKE_MENU(filesplitoptionsmenu, ID2P(LANG_RECORD_TIMESPLIT), NULL, Icon_NOICON,
340 &rec_split_method, &rec_split_type, &rec_timesplit, &rec_sizesplit);
343 MENUITEM_SETTING(rec_prerecord_time, &global_settings.rec_prerecord_time, NULL);
345 static int clear_rec_directory(void)
347 strcpy(global_settings.rec_directory, REC_BASE_DIR);
348 splash(HZ, ID2P(LANG_RESET_DONE_CLEAR));
349 return false;
351 MENUITEM_FUNCTION(clear_rec_directory_item, 0, ID2P(LANG_CLEAR_REC_DIR),
352 clear_rec_directory, NULL, NULL, Icon_Folder);
354 MENUITEM_SETTING(cliplight, &global_settings.cliplight, NULL);
356 #ifdef HAVE_AGC
357 static int agc_preset_func(void)
359 static const struct opt_items names[] = {
360 { STR(LANG_OFF) },
361 { STR(LANG_AGC_SAFETY) },
362 { STR(LANG_AGC_LIVE) },
363 { STR(LANG_AGC_DJSET) },
364 { STR(LANG_AGC_MEDIUM) },
365 { STR(LANG_AGC_VOICE) },
367 if (global_settings.rec_source)
368 return set_option(str(LANG_RECORDING_AGC_PRESET),
369 &global_settings.rec_agc_preset_line,
370 INT, names, 6, NULL );
371 else
372 return set_option(str(LANG_RECORDING_AGC_PRESET),
373 &global_settings.rec_agc_preset_mic,
374 INT, names, 6, NULL );
377 static int agc_cliptime_func(void)
379 static const struct opt_items names[] = {
380 { "200ms", TALK_ID(200, UNIT_MS) },
381 { "400ms", TALK_ID(400, UNIT_MS) },
382 { "600ms", TALK_ID(600, UNIT_MS) },
383 { "800ms", TALK_ID(800, UNIT_MS) },
384 { "1s", TALK_ID(1, UNIT_SEC) }
386 return set_option(str(LANG_RECORDING_AGC_CLIPTIME),
387 &global_settings.rec_agc_cliptime,
388 INT, names, 5, NULL );
390 MENUITEM_FUNCTION(agc_preset, 0, ID2P(LANG_RECORDING_AGC_PRESET),
391 agc_preset_func, NULL, NULL, Icon_Menu_setting);
392 MENUITEM_FUNCTION(agc_cliptime, 0, ID2P(LANG_RECORDING_AGC_CLIPTIME),
393 agc_cliptime_func, NULL, NULL, Icon_Menu_setting);
394 #endif /* HAVE_AGC */
396 /** Rec trigger **/
397 enum trigger_menu_option
399 TRIGGER_MODE,
400 TRIGGER_TYPE,
401 PRERECORD_TIME,
402 START_THRESHOLD,
403 START_DURATION,
404 STOP_THRESHOLD,
405 STOP_POSTREC,
406 STOP_GAP,
407 TRIG_OPTION_COUNT,
410 static enum themable_icons trigger_get_icon(int selected_item, void * data)
412 (void)data;
413 if ((selected_item % 2) == 0) /* header */
414 return Icon_Menu_setting;
415 return Icon_NOICON;
418 static const char * trigger_get_name(int selected_item, void * data,
419 char * buffer, size_t buffer_len)
421 const struct settings_list **settings =
422 (const struct settings_list **)data;
423 const struct settings_list *s = settings[selected_item / 2];
424 if ((selected_item % 2) == 0) /* header */
425 return P2STR(ID2P(s->lang_id));
426 else
428 int temp;
429 temp = option_value_as_int(s);
430 if ((selected_item / 2 == START_THRESHOLD ||
431 selected_item / 2 == STOP_THRESHOLD) &&
432 temp == 0)
434 return str(LANG_OFF);
436 return option_get_valuestring(s, buffer, buffer_len, temp);
439 static void trigger_speak_item(const struct settings_list **settings,
440 int selected_setting, bool title)
442 const struct settings_list *s = settings[selected_setting];
443 int temp;
444 if (!global_settings.talk_menu)
445 return;
446 if (title)
447 talk_id(s->lang_id, false);
448 temp = option_value_as_int(s);
449 if ((selected_setting == START_THRESHOLD ||
450 selected_setting == STOP_THRESHOLD) &&
451 temp == 0)
453 talk_id(LANG_OFF, title);
454 } else {
455 option_talk_value(s, temp, title);
458 int rectrigger(void)
460 struct viewport vp[NB_SCREENS], triggervp[NB_SCREENS];
461 struct gui_synclist lists;
462 int i, action = ACTION_REDRAW;
463 bool done = false, changed = true;
464 const struct settings_list *settings[TRIG_OPTION_COUNT];
466 int pm_x[NB_SCREENS];
467 int pm_y[NB_SCREENS];
468 int pm_h[NB_SCREENS];
469 int trig_xpos[NB_SCREENS];
470 int trig_ypos[NB_SCREENS];
471 int trig_width[NB_SCREENS];
473 int old_start_thres_db = global_settings.rec_start_thres_db;
474 int old_start_thres_linear = global_settings.rec_start_thres_linear;
475 int old_start_duration = global_settings.rec_start_duration;
476 int old_prerecord_time = global_settings.rec_prerecord_time;
477 int old_stop_thres_db = global_settings.rec_stop_thres_db;
478 int old_stop_thres_linear = global_settings.rec_stop_thres_linear;
479 int old_stop_postrec = global_settings.rec_stop_postrec;
480 int old_stop_gap = global_settings.rec_stop_gap;
481 int old_trigger_mode = global_settings.rec_trigger_mode;
482 int old_trigger_type = global_settings.rec_trigger_type;
484 FOR_NB_SCREENS(i)
486 screens[i].clear_display();
487 screens[i].update();
488 viewport_set_defaults(&vp[i], i);
489 vp[i].height -= SYSFONT_HEIGHT*2;
490 triggervp[i] = vp[i];
491 triggervp[i].y = vp[i].y + vp[i].height;
492 triggervp[i].height = SYSFONT_HEIGHT*2;
493 trig_xpos[i] = 0;
494 trig_ypos[i] = 0;
495 pm_x[i] = 0;
496 pm_y[i] = SYSFONT_HEIGHT;
497 pm_h[i] = SYSFONT_HEIGHT;
498 trig_width[i] = triggervp[i].width;
500 /* TODO: what to do if there is < 4 lines on the screen? */
502 settings[TRIGGER_MODE] =
503 find_setting(&global_settings.rec_trigger_mode, NULL);
504 settings[TRIGGER_TYPE] =
505 find_setting(&global_settings.rec_trigger_type, NULL);
506 settings[PRERECORD_TIME] =
507 find_setting(&global_settings.rec_prerecord_time, NULL);
508 settings[START_DURATION] =
509 find_setting(&global_settings.rec_start_duration, NULL);
510 settings[STOP_POSTREC] =
511 find_setting(&global_settings.rec_stop_postrec, NULL);
512 settings[STOP_GAP] =
513 find_setting(&global_settings.rec_stop_gap, NULL);
514 if (global_settings.peak_meter_dbfs) /* show the dB settings */
516 settings[START_THRESHOLD] =
517 find_setting(&global_settings.rec_start_thres_db, NULL);
518 settings[STOP_THRESHOLD] =
519 find_setting(&global_settings.rec_stop_thres_db, NULL);
521 else
523 settings[START_THRESHOLD] =
524 find_setting(&global_settings.rec_start_thres_linear, NULL);
525 settings[STOP_THRESHOLD] =
526 find_setting(&global_settings.rec_stop_thres_linear, NULL);
528 gui_synclist_init(&lists, trigger_get_name, settings, false, 2, vp);
529 gui_synclist_set_nb_items(&lists, TRIG_OPTION_COUNT*2);
530 gui_synclist_set_icon_callback(&lists, trigger_get_icon);
531 /* restart trigger with new values */
532 settings_apply_trigger();
533 peak_meter_trigger (global_settings.rec_trigger_mode != TRIG_MODE_OFF);
535 trigger_speak_item(settings, 0, true);
537 while (!done)
539 if (changed)
541 gui_synclist_draw(&lists);
542 peak_meter_trigger(global_settings.rec_trigger_mode!=TRIG_OFF);
543 settings_apply_trigger();
544 changed = false;
547 FOR_NB_SCREENS(i)
548 screens[i].set_viewport(&triggervp[i]);
549 peak_meter_draw_trig(trig_xpos, trig_ypos, trig_width, NB_SCREENS);
550 action = peak_meter_draw_get_btn(CONTEXT_SETTINGS_RECTRIGGER,
551 pm_x, pm_y, pm_h, NB_SCREENS, triggervp);
552 FOR_NB_SCREENS(i)
553 screens[i].update();
554 i = gui_synclist_get_sel_pos(&lists);
555 switch (action)
557 case ACTION_STD_CANCEL:
558 splash(HZ/2, ID2P(LANG_CANCEL));
559 global_settings.rec_start_thres_db = old_start_thres_db;
560 global_settings.rec_start_thres_linear = old_start_thres_linear;
561 global_settings.rec_start_duration = old_start_duration;
562 global_settings.rec_prerecord_time = old_prerecord_time;
563 global_settings.rec_stop_thres_db = old_stop_thres_db;
564 global_settings.rec_stop_thres_linear = old_stop_thres_linear;
565 global_settings.rec_stop_postrec = old_stop_postrec;
566 global_settings.rec_stop_gap = old_stop_gap;
567 global_settings.rec_trigger_mode = old_trigger_mode;
568 global_settings.rec_trigger_type = old_trigger_type;
569 peak_meter_trigger(global_settings.rec_trigger_mode!=TRIG_OFF);
570 settings_apply_trigger();
571 done = true;
572 break;
573 case ACTION_STD_OK:
574 done = true;
575 break;
576 case ACTION_SETTINGS_DEC:
577 case ACTION_SETTINGS_DECREPEAT:
578 option_select_next_val(settings[i/2], true, false);
579 trigger_speak_item(settings, i/2, false);
580 changed = true;
581 break;
582 case ACTION_SETTINGS_INC:
583 case ACTION_SETTINGS_INCREPEAT:
584 option_select_next_val(settings[i/2], false, false);
585 trigger_speak_item(settings, i/2, false);
586 changed = true;
587 break;
588 case ACTION_STD_PREV:
589 case ACTION_STD_PREVREPEAT:
590 i -= 2;
591 if (i<0)
592 i = (TRIG_OPTION_COUNT*2) - 2;
593 gui_synclist_select_item(&lists, i);
594 i = gui_synclist_get_sel_pos(&lists);
595 trigger_speak_item(settings, i/2, true);
596 changed = true;
597 break;
598 case ACTION_STD_NEXT:
599 case ACTION_STD_NEXTREPEAT:
600 gui_synclist_select_item(&lists, (i+2) % (TRIG_OPTION_COUNT*2));
601 i = gui_synclist_get_sel_pos(&lists);
602 trigger_speak_item(settings, i/2, true);
603 changed = true;
604 break;
607 peak_meter_trigger(false);
608 settings_save();
609 return 0;
611 MENUITEM_FUNCTION(rectrigger_item, 0, ID2P(LANG_RECORD_TRIGGER),
612 rectrigger, NULL, NULL, Icon_Menu_setting);
614 static struct browse_folder_info rec_config_browse = {RECPRESETS_DIR, SHOW_CFG};
615 MENUITEM_FUNCTION(browse_recconfigs, MENU_FUNC_USEPARAM, ID2P(LANG_CUSTOM_CFG),
616 browse_folder, (void*)&rec_config_browse, NULL, Icon_Config);
617 static int write_settings_file(void)
619 return settings_save_config(SETTINGS_SAVE_RECPRESETS);
621 MENUITEM_FUNCTION(save_recpresets_item, 0, ID2P(LANG_SAVE_SETTINGS),
622 write_settings_file, NULL, NULL, Icon_Config);
624 MAKE_MENU(recording_settings_menu, ID2P(LANG_RECORDING_SETTINGS),
625 NULL, Icon_Recording,
626 #if CONFIG_CODEC == MAS3587F
627 &rec_quality,
628 #endif
629 #if CONFIG_CODEC == SWCODEC
630 &recformat, &enc_global_config_menu_item,
631 #endif
632 &recfrequency, &recsource, /* recsource not shown if no_source */
633 &recchannels,
634 #if CONFIG_CODEC == SWCODEC
635 &recmonomode,
636 #endif
637 #if CONFIG_CODEC == MAS3587F
638 &rec_editable,
639 #endif
640 &filesplitoptionsmenu,
641 &rec_prerecord_time,
642 &clear_rec_directory_item,
643 #ifdef HAVE_BACKLIGHT
644 &cliplight,
645 #endif
646 &rectrigger_item,
647 #ifdef HAVE_AGC
648 &agc_preset, &agc_cliptime,
649 #endif
650 #ifdef HAVE_LCD_BITMAP
651 &peak_meter_menu,
652 #endif
653 &browse_recconfigs, &save_recpresets_item
656 bool recording_menu(bool no_source)
658 bool retval;
659 no_source_in_menu = no_source;
660 retval = do_menu(&recording_settings_menu, NULL, NULL, false) == MENU_ATTACHED_USB;
661 no_source_in_menu = false; /* always fall back to the default */
662 return retval;
665 MENUITEM_FUNCTION(recording_settings, MENU_FUNC_USEPARAM, ID2P(LANG_RECORDING_SETTINGS),
666 (int (*)(void*))recording_menu, 0, NULL, Icon_Recording);