diff options
Diffstat (limited to 'apps/settings_list.c')
-rw-r--r-- | apps/settings_list.c | 169 |
1 files changed, 114 insertions, 55 deletions
diff --git a/apps/settings_list.c b/apps/settings_list.c index 969d7c361c..1023235af5 100644 --- a/apps/settings_list.c +++ b/apps/settings_list.c | |||
@@ -19,7 +19,7 @@ | |||
19 | 19 | ||
20 | #include "config.h" | 20 | #include "config.h" |
21 | #include <stdbool.h> | 21 | #include <stdbool.h> |
22 | 22 | #include <string.h> | |
23 | #include "lang.h" | 23 | #include "lang.h" |
24 | #include "talk.h" | 24 | #include "talk.h" |
25 | #include "lcd.h" | 25 | #include "lcd.h" |
@@ -27,6 +27,9 @@ | |||
27 | #include "settings_list.h" | 27 | #include "settings_list.h" |
28 | #include "sound.h" | 28 | #include "sound.h" |
29 | #include "dsp.h" | 29 | #include "dsp.h" |
30 | #include "debug.h" | ||
31 | #include "mpeg.h" | ||
32 | #include "audio.h" | ||
30 | 33 | ||
31 | /* some sets of values which are used more than once, to save memory */ | 34 | /* some sets of values which are used more than once, to save memory */ |
32 | static const char off_on[] = "off,on"; | 35 | static const char off_on[] = "off,on"; |
@@ -76,6 +79,34 @@ static const char trig_durations_conf [] = | |||
76 | static const char backlight_times_conf [] = | 79 | static const char backlight_times_conf [] = |
77 | "off,on,1,2,3,4,5,6,7,8,9,10,15,20,25,30,45,60,90"; | 80 | "off,on,1,2,3,4,5,6,7,8,9,10,15,20,25,30,45,60,90"; |
78 | #endif | 81 | #endif |
82 | /* ffwd/rewind and scan acceleration stuff */ | ||
83 | static int ff_rewind_min_stepvals[] = {1,2,3,4,5,6,8,10,15,20,25,30,45,60}; | ||
84 | static long ff_rewind_min_step_getlang(int value) | ||
85 | { | ||
86 | return TALK_ID(ff_rewind_min_stepvals[value], UNIT_SEC); | ||
87 | } | ||
88 | static void ff_rewind_min_step_formatter(char *buffer, int buffer_size, | ||
89 | int val, const char *unit) | ||
90 | { | ||
91 | (void)unit; | ||
92 | snprintf(buffer, buffer_size, "%ds", ff_rewind_min_stepvals[val]); | ||
93 | } | ||
94 | static long scanaccel_getlang(int value) | ||
95 | { | ||
96 | if (value == 0) | ||
97 | return LANG_OFF; | ||
98 | return TALK_ID(value, UNIT_SEC); | ||
99 | } | ||
100 | static void scanaccel_formatter(char *buffer, int buffer_size, | ||
101 | int val, const char *unit) | ||
102 | { | ||
103 | (void)unit; | ||
104 | if (val == 0) | ||
105 | strcpy(buffer, str(LANG_OFF)); | ||
106 | else | ||
107 | snprintf(buffer, buffer_size, "2x/%ds", val); | ||
108 | } | ||
109 | |||
79 | 110 | ||
80 | #define NVRAM(bytes) (bytes<<F_NVRAM_MASK_SHIFT) | 111 | #define NVRAM(bytes) (bytes<<F_NVRAM_MASK_SHIFT) |
81 | /** NOTE: NVRAM_CONFIG_VERSION is in settings_list.h | 112 | /** NOTE: NVRAM_CONFIG_VERSION is in settings_list.h |
@@ -155,13 +186,21 @@ static const char backlight_times_conf [] = | |||
155 | {cb, count, {.talks = (int[]){__VA_ARGS__}}}}}} | 186 | {cb, count, {.talks = (int[]){__VA_ARGS__}}}}}} |
156 | 187 | ||
157 | /* for settings which use the set_int() setting screen. | 188 | /* for settings which use the set_int() setting screen. |
158 | unit is the UNIT_ define to display/talk. */ | 189 | unit is the UNIT_ define to display/talk. |
159 | #define INT_SETTING(flags, var, lang_id, default, name, \ | 190 | the first one saves a string to the config file, |
160 | unit, min, max, step, formatter, cb) \ | 191 | the second one saves the variable value to the config file */ |
192 | #define INT_SETTING_W_CFGVALS(flags, var, lang_id, default, name, cfg_vals, \ | ||
193 | unit, min, max, step, formatter, get_talk_id, cb) \ | ||
161 | {flags|F_INT_SETTING|F_T_INT, &global_settings.var, \ | 194 | {flags|F_INT_SETTING|F_T_INT, &global_settings.var, \ |
162 | lang_id, INT(default), \ | 195 | lang_id, INT(default), name, cfg_vals, \ |
163 | name, NULL, {.int_setting = (struct int_setting[]){ \ | 196 | {.int_setting = (struct int_setting[]){ \ |
164 | {cb, unit, min, max, step, formatter}}}} | 197 | {cb, unit, min, max, step, formatter, get_talk_id}}}} |
198 | #define INT_SETTING(flags, var, lang_id, default, name, \ | ||
199 | unit, min, max, step, formatter, get_talk_id, cb) \ | ||
200 | {flags|F_INT_SETTING|F_T_INT, &global_settings.var, \ | ||
201 | lang_id, INT(default), name, NULL, \ | ||
202 | {.int_setting = (struct int_setting[]){ \ | ||
203 | {cb, unit, min, max, step, formatter, get_talk_id}}}} | ||
165 | 204 | ||
166 | #if CONFIG_CODEC == SWCODEC | 205 | #if CONFIG_CODEC == SWCODEC |
167 | static void crossfeed_format(char* buffer, int buffer_size, int value, | 206 | static void crossfeed_format(char* buffer, int buffer_size, int value, |
@@ -188,6 +227,16 @@ static void crossfeed_hf_cutoff_helper(int val) | |||
188 | global_settings.crossfeed_cross_gain | 227 | global_settings.crossfeed_cross_gain |
189 | + global_settings.crossfeed_hf_attenuation, val); | 228 | + global_settings.crossfeed_hf_attenuation, val); |
190 | } | 229 | } |
230 | |||
231 | static void replaygain_preamp_format(char* buffer, int buffer_size, int value, | ||
232 | const char* unit) | ||
233 | { | ||
234 | int v = abs(value); | ||
235 | |||
236 | snprintf(buffer, buffer_size, "%s%d.%d %s", value < 0 ? "-" : "", | ||
237 | v / 10, v % 10, unit); | ||
238 | } | ||
239 | |||
191 | #endif | 240 | #endif |
192 | #if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F) | 241 | #if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F) |
193 | static void set_mdb_enable(bool value) | 242 | static void set_mdb_enable(bool value) |
@@ -277,7 +326,7 @@ const struct settings_list settings[] = { | |||
277 | SYSTEM_SETTING(NVRAM(4),topruntime,0), | 326 | SYSTEM_SETTING(NVRAM(4),topruntime,0), |
278 | #if MEM > 1 | 327 | #if MEM > 1 |
279 | INT_SETTING(0,max_files_in_playlist,LANG_MAX_FILES_IN_PLAYLIST,10000, | 328 | INT_SETTING(0,max_files_in_playlist,LANG_MAX_FILES_IN_PLAYLIST,10000, |
280 | "max files in playlist", UNIT_INT,1000,20000,1000,NULL,NULL), | 329 | "max files in playlist", UNIT_INT,1000,20000,1000,NULL,NULL,NULL), |
281 | {F_T_INT,&global_settings.max_files_in_dir,LANG_MAX_FILES_IN_DIR, | 330 | {F_T_INT,&global_settings.max_files_in_dir,LANG_MAX_FILES_IN_DIR, |
282 | INT(400),"max files in dir",NULL,UNUSED}, | 331 | INT(400),"max files in dir",NULL,UNUSED}, |
283 | #else | 332 | #else |
@@ -398,16 +447,21 @@ const struct settings_list settings[] = { | |||
398 | OFFON_SETTING(0,play_selected,LANG_PLAY_SELECTED,true,"play selected",NULL), | 447 | OFFON_SETTING(0,play_selected,LANG_PLAY_SELECTED,true,"play selected",NULL), |
399 | OFFON_SETTING(0,party_mode,LANG_PARTY_MODE,false,"party mode",NULL), | 448 | OFFON_SETTING(0,party_mode,LANG_PARTY_MODE,false,"party mode",NULL), |
400 | OFFON_SETTING(0,fade_on_stop,LANG_FADE_ON_STOP,true,"volume fade",NULL), | 449 | OFFON_SETTING(0,fade_on_stop,LANG_FADE_ON_STOP,true,"volume fade",NULL), |
401 | {F_T_INT,&global_settings.ff_rewind_min_step,LANG_FFRW_STEP,INT(FF_REWIND_1000), | 450 | INT_SETTING_W_CFGVALS(0, ff_rewind_min_step, LANG_FFRW_STEP, FF_REWIND_1000, |
402 | "scan min step","1,2,3,4,5,6,8,10,15,20,25,30,45,60",UNUSED}, | 451 | "scan min step", "1,2,3,4,5,6,8,10,15,20,25,30,45,60", UNIT_SEC, |
403 | {F_T_INT,&global_settings.ff_rewind_accel,LANG_FFRW_ACCEL,INT(3), | 452 | 13, 0, -1, ff_rewind_min_step_formatter, |
404 | "scan accel",NULL,UNUSED}, | 453 | ff_rewind_min_step_getlang, NULL), |
454 | INT_SETTING(0, ff_rewind_accel, LANG_FFRW_ACCEL, 3, "scan accel", | ||
455 | UNIT_SEC, 16, 0, -1, scanaccel_formatter, scanaccel_getlang, NULL), | ||
405 | #if CONFIG_CODEC == SWCODEC | 456 | #if CONFIG_CODEC == SWCODEC |
406 | {F_T_INT,&global_settings.buffer_margin,LANG_MP3BUFFER_MARGIN,INT(0),"antiskip", | 457 | STRINGCHOICE_SETTING(0, buffer_margin, LANG_MP3BUFFER_MARGIN, 0,"antiskip", |
407 | "5s,15s,30s,1min,2min,3min,5min,10min",UNUSED}, | 458 | "5s,15s,30s,1min,2min,3min,5min,10min",NULL, 8, |
459 | TALK_ID(5, UNIT_SEC), TALK_ID(15, UNIT_SEC), | ||
460 | TALK_ID(30, UNIT_SEC), TALK_ID(1, UNIT_MIN), TALK_ID(2, UNIT_MIN), | ||
461 | TALK_ID(3, UNIT_MIN), TALK_ID(5, UNIT_MIN), TALK_ID(10, UNIT_MIN)), | ||
408 | #else | 462 | #else |
409 | {F_T_INT,&global_settings.buffer_margin,LANG_MP3BUFFER_MARGIN,INT(0), | 463 | INT_SETTING(0, buffer_margin, LANG_MP3BUFFER_MARGIN, 0, "antiskip", \ |
410 | "antiskip",NULL,UNUSED}, | 464 | UNIT_SEC, 0, 7, 1, NULL, NULL, audio_set_buffer_margin), |
411 | #endif | 465 | #endif |
412 | /* disk */ | 466 | /* disk */ |
413 | #ifndef HAVE_MMC | 467 | #ifndef HAVE_MMC |
@@ -482,9 +536,9 @@ const struct settings_list settings[] = { | |||
482 | "sort files","alpha,oldest,newest,type",UNUSED}, | 536 | "sort files","alpha,oldest,newest,type",UNUSED}, |
483 | {F_T_INT,&global_settings.sort_dir,LANG_SORT_DIR,INT(0), | 537 | {F_T_INT,&global_settings.sort_dir,LANG_SORT_DIR,INT(0), |
484 | "sort dirs","alpha,oldest,newest",UNUSED}, | 538 | "sort dirs","alpha,oldest,newest",UNUSED}, |
485 | BOOL_SETTING(0,id3_v1_first,LANG_ID3_ORDER,false, | 539 | BOOL_SETTING(0, id3_v1_first, LANG_ID3_ORDER, false, |
486 | "id3 tag priority","v2-v1,v1-v2", | 540 | "id3 tag priority", "v2-v1,v1-v2", |
487 | LANG_ID3_V2_FIRST,LANG_ID3_V1_FIRST,NULL), | 541 | LANG_ID3_V2_FIRST, LANG_ID3_V1_FIRST, mpeg_id3_options), |
488 | 542 | ||
489 | #ifdef HAVE_RECORDING | 543 | #ifdef HAVE_RECORDING |
490 | /* recording */ | 544 | /* recording */ |
@@ -567,57 +621,61 @@ const struct settings_list settings[] = { | |||
567 | #endif /* HAVE_RECORDING */ | 621 | #endif /* HAVE_RECORDING */ |
568 | 622 | ||
569 | #ifdef HAVE_SPDIF_POWER | 623 | #ifdef HAVE_SPDIF_POWER |
570 | OFFON_SETTING(0,spdif_enable,LANG_SPDIF_ENABLE,false,"spdif enable",NULL), | 624 | OFFON_SETTING(0, spdif_enable, LANG_SPDIF_ENABLE, false, |
625 | "spdif enable", spdif_power_enable), | ||
571 | #endif | 626 | #endif |
572 | {F_T_INT,&global_settings.next_folder,LANG_NEXT_FOLDER,INT(FOLDER_ADVANCE_OFF), | 627 | CHOICE_SETTING(0, next_folder, LANG_NEXT_FOLDER, FOLDER_ADVANCE_OFF, |
573 | "folder navigation","off,on,random",UNUSED}, | 628 | "folder navigation", "off,on,random",NULL ,3, |
629 | ID2P(LANG_SET_BOOL_NO), ID2P(LANG_SET_BOOL_YES), ID2P(LANG_RANDOM)), | ||
574 | OFFON_SETTING(0,runtimedb,LANG_RUNTIMEDB_ACTIVE,false,"gather runtime data",NULL), | 630 | OFFON_SETTING(0,runtimedb,LANG_RUNTIMEDB_ACTIVE,false,"gather runtime data",NULL), |
575 | 631 | ||
576 | #if CONFIG_CODEC == SWCODEC | 632 | #if CONFIG_CODEC == SWCODEC |
577 | /* replay gain */ | 633 | /* replay gain */ |
578 | OFFON_SETTING(0,replaygain,LANG_REPLAYGAIN,false,"replaygain",NULL), | 634 | OFFON_SETTING(0, replaygain, LANG_REPLAYGAIN, false, "replaygain", NULL), |
579 | {F_T_INT,&global_settings.replaygain_type,LANG_REPLAYGAIN_MODE,INT(REPLAYGAIN_ALBUM), | 635 | CHOICE_SETTING(0, replaygain_type, LANG_REPLAYGAIN_MODE, REPLAYGAIN_ALBUM, |
580 | "replaygain type","track,album,track shuffle",UNUSED}, | 636 | "replaygain type", "track,album,track shuffle", NULL, 3, |
581 | OFFON_SETTING(0,replaygain_noclip,LANG_REPLAYGAIN_NOCLIP, | 637 | ID2P(LANG_TRACK_GAIN), ID2P(LANG_ALBUM_GAIN), ID2P(LANG_SHUFFLE_GAIN)), |
582 | false,"replaygain noclip",NULL), | 638 | OFFON_SETTING(0, replaygain_noclip, LANG_REPLAYGAIN_NOCLIP, |
583 | {F_T_INT,&global_settings.replaygain_preamp,LANG_REPLAYGAIN_PREAMP, | 639 | false, "replaygain noclip", NULL), |
584 | INT(0),"replaygain preamp",NULL,UNUSED}, | 640 | INT_SETTING(0, replaygain_preamp, LANG_REPLAYGAIN_PREAMP, 0, "replaygain preamp", |
585 | 641 | UNIT_DB, -120, 120, 1, replaygain_preamp_format, NULL, NULL), | |
586 | {F_T_INT,&global_settings.beep,LANG_BEEP,INT(0),"beep","off,weak,moderate,strong",UNUSED}, | 642 | |
643 | CHOICE_SETTING(0, beep, LANG_BEEP, 0, | ||
644 | "beep", "off,weak,moderate,strong", NULL, 3, | ||
645 | ID2P(LANG_OFF), ID2P(LANG_WEAK), ID2P(LANG_MODERATE), ID2P(LANG_STRONG)), | ||
587 | 646 | ||
588 | /* crossfade */ | 647 | /* crossfade */ |
589 | {F_T_INT,&global_settings.crossfade,LANG_CROSSFADE_ENABLE,INT(0),"crossfade", | 648 | CHOICE_SETTING(0, crossfade, LANG_CROSSFADE_ENABLE, 0, "crossfade", |
590 | "off,shuffle,track skip,shuffle and track skip,always",UNUSED}, | 649 | "off,shuffle,track skip,shuffle and track skip,always",NULL, 5, |
591 | {F_T_INT,&global_settings.crossfade_fade_in_delay,LANG_CROSSFADE_FADE_IN_DELAY,INT(0), | 650 | ID2P(LANG_OFF), ID2P(LANG_SHUFFLE), ID2P(LANG_TRACKSKIP), |
592 | "crossfade fade in delay",NULL,UNUSED}, | 651 | ID2P(LANG_SHUFFLE_TRACKSKIP), ID2P(LANG_ALWAYS)), |
593 | {F_T_INT,&global_settings.crossfade_fade_out_delay, | 652 | INT_SETTING(0, crossfade_fade_in_delay, LANG_CROSSFADE_FADE_IN_DELAY, 0, |
594 | LANG_CROSSFADE_FADE_OUT_DELAY,INT(0), | 653 | "crossfade fade in delay", UNIT_SEC, 0, 7, 1, NULL, NULL, NULL), |
595 | "crossfade fade out delay",NULL,UNUSED}, | 654 | INT_SETTING(0, crossfade_fade_out_delay, LANG_CROSSFADE_FADE_OUT_DELAY, 0, |
596 | {F_T_INT,&global_settings.crossfade_fade_in_duration, | 655 | "crossfade fade out delay", UNIT_SEC, 0, 7, 1, NULL, NULL, NULL), |
597 | LANG_CROSSFADE_FADE_IN_DURATION,INT(0), | 656 | INT_SETTING(0, crossfade_fade_in_duration, LANG_CROSSFADE_FADE_IN_DURATION, 0, |
598 | "crossfade fade in duration",NULL,UNUSED}, | 657 | "crossfade fade in duration", UNIT_SEC, 0, 15, 1, NULL, NULL, NULL), |
599 | {F_T_INT,&global_settings.crossfade_fade_out_duration, | 658 | INT_SETTING(0, crossfade_fade_out_duration, LANG_CROSSFADE_FADE_OUT_DURATION, 0, |
600 | LANG_CROSSFADE_FADE_OUT_DURATION,INT(0), | 659 | "crossfade fade out duration", UNIT_SEC, 0, 15, 1, NULL, NULL, NULL), |
601 | "crossfade fade out duration",NULL,UNUSED}, | 660 | CHOICE_SETTING(0, crossfade_fade_out_mixmode, LANG_CROSSFADE_FADE_OUT_MODE, |
602 | {F_T_INT,&global_settings.crossfade_fade_out_mixmode, | 661 | 0, "crossfade fade out mode", "crossfade,mix" ,NULL, 2, |
603 | LANG_CROSSFADE_FADE_OUT_MODE,INT(0), | 662 | ID2P(LANG_CROSSFADE), ID2P(LANG_MIX)), |
604 | "crossfade fade out mode","crossfade,mix",UNUSED}, | ||
605 | 663 | ||
606 | /* crossfeed */ | 664 | /* crossfeed */ |
607 | OFFON_SETTING(0,crossfeed, LANG_CROSSFEED, false, | 665 | OFFON_SETTING(0,crossfeed, LANG_CROSSFEED, false, |
608 | "crossfeed", dsp_set_crossfeed), | 666 | "crossfeed", dsp_set_crossfeed), |
609 | INT_SETTING(0, crossfeed_direct_gain, LANG_CROSSFEED_DIRECT_GAIN, 15, | 667 | INT_SETTING(0, crossfeed_direct_gain, LANG_CROSSFEED_DIRECT_GAIN, 15, |
610 | "crossfeed direct gain", UNIT_DB, 0, 60, 5, | 668 | "crossfeed direct gain", UNIT_DB, 0, 60, 5, |
611 | crossfeed_format, dsp_set_crossfeed_direct_gain), | 669 | crossfeed_format, NULL, dsp_set_crossfeed_direct_gain), |
612 | INT_SETTING(0, crossfeed_cross_gain, LANG_CROSSFEED_CROSS_GAIN, 60, | 670 | INT_SETTING(0, crossfeed_cross_gain, LANG_CROSSFEED_CROSS_GAIN, 60, |
613 | "crossfeed cross gain", UNIT_DB, 30, 120, 5, | 671 | "crossfeed cross gain", UNIT_DB, 30, 120, 5, |
614 | crossfeed_format, crossfeed_cross_gain_helper), | 672 | crossfeed_format, NULL, crossfeed_cross_gain_helper), |
615 | INT_SETTING(0, crossfeed_hf_attenuation, LANG_CROSSFEED_HF_ATTENUATION, 160, | 673 | INT_SETTING(0, crossfeed_hf_attenuation, LANG_CROSSFEED_HF_ATTENUATION, 160, |
616 | "crossfeed hf attenuation", UNIT_DB, 60, 240, 5, | 674 | "crossfeed hf attenuation", UNIT_DB, 60, 240, 5, |
617 | crossfeed_format, crossfeed_hf_att_helper), | 675 | crossfeed_format, NULL, crossfeed_hf_att_helper), |
618 | INT_SETTING(0, crossfeed_hf_cutoff, LANG_CROSSFEED_HF_CUTOFF,700, | 676 | INT_SETTING(0, crossfeed_hf_cutoff, LANG_CROSSFEED_HF_CUTOFF,700, |
619 | "crossfeed hf cutoff", UNIT_HERTZ, 500, 2000, 100, | 677 | "crossfeed hf cutoff", UNIT_HERTZ, 500, 2000, 100, |
620 | crossfeed_format, crossfeed_hf_cutoff_helper), | 678 | crossfeed_format, NULL, crossfeed_hf_cutoff_helper), |
621 | /* equalizer */ | 679 | /* equalizer */ |
622 | OFFON_SETTING(0,eq_enabled,LANG_EQUALIZER_ENABLED,false,"eq enabled",NULL), | 680 | OFFON_SETTING(0,eq_enabled,LANG_EQUALIZER_ENABLED,false,"eq enabled",NULL), |
623 | {F_T_INT,&global_settings.eq_precut,LANG_EQUALIZER_PRECUT,INT(0), | 681 | {F_T_INT,&global_settings.eq_precut,LANG_EQUALIZER_PRECUT,INT(0), |
@@ -763,10 +821,11 @@ const struct settings_list settings[] = { | |||
763 | #endif | 821 | #endif |
764 | #endif | 822 | #endif |
765 | #ifdef HAVE_HEADPHONE_DETECTION | 823 | #ifdef HAVE_HEADPHONE_DETECTION |
766 | {F_T_INT,&global_settings.unplug_mode,LANG_UNPLUG,INT(0), | 824 | CHOICE_SETTING(0, unplug_mode, LANG_UNPLUG, 0, |
767 | "pause on headphone unplug",NULL,UNUSED}, | 825 | "pause on headphone unplug", "off,pause,pause and resume", NULL, 3, |
768 | {F_T_INT,&global_settings.unplug_rw,LANG_UNPLUG_RW,INT(0), | 826 | ID2P(LANG_OFF), ID2P(LANG_PAUSE), ID2P(LANG_UNPLUG_RESUME)), |
769 | "rewind duration on pause",NULL,UNUSED}, | 827 | INT_SETTING(0, unplug_rw, LANG_UNPLUG_RW, 0, "rewind duration on pause", |
828 | UNIT_SEC, 0, 15, 1, NULL, NULL,NULL) , | ||
770 | OFFON_SETTING(0,unplug_autoresume,LANG_UNPLUG_DISABLE_AUTORESUME,false, | 829 | OFFON_SETTING(0,unplug_autoresume,LANG_UNPLUG_DISABLE_AUTORESUME,false, |
771 | "disable autoresume if phones not present",NULL), | 830 | "disable autoresume if phones not present",NULL), |
772 | #endif | 831 | #endif |