summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
authorDan Everton <dan@iocaine.org>2007-12-07 10:59:07 +0000
committerDan Everton <dan@iocaine.org>2007-12-07 10:59:07 +0000
commit5886efabf5e4c96a8a96836d665aad935c727e31 (patch)
treedfff344379b09bf0de89530393390113585658c0 /apps
parent05007e1a79fa9d9bb5985e0f6195871ea5ea71a6 (diff)
downloadrockbox-5886efabf5e4c96a8a96836d665aad935c727e31.zip
rockbox-5886efabf5e4c96a8a96836d665aad935c727e31.tar.gz
rockbox-5886efabf5e4c96a8a96836d665aad935c727e31.tar.bz2
rockbox-5886efabf5e4c96a8a96836d665aad935c727e31.tar.xz
Save some bytes and reuse the settings saving code for eq preset saving.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@15891 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps')
-rw-r--r--apps/menus/eq_menu.c46
-rw-r--r--apps/settings.c10
-rw-r--r--apps/settings.h3
-rw-r--r--apps/settings_list.c79
-rw-r--r--apps/settings_list.h1
5 files changed, 61 insertions, 78 deletions
diff --git a/apps/menus/eq_menu.c b/apps/menus/eq_menu.c
index 2c2e596..b3e67e4 100644
--- a/apps/menus/eq_menu.c
+++ b/apps/menus/eq_menu.c
@@ -596,50 +596,17 @@ bool eq_menu_graphical(void)
return result;
}
-/* Preset saver.
- * TODO: Can the settings system be used to do this instead?
- */
static bool eq_save_preset(void)
{
- int fd, i;
- char filename[MAX_PATH];
- int *setting;
-
- create_numbered_filename(filename, EQS_DIR, "eq", ".cfg", 2
- IF_CNFN_NUM_(, NULL));
-
- /* allow user to modify filename */
- while (true) {
- if (!kbd_input(filename, sizeof filename)) {
- fd = creat(filename);
- if (fd < 0)
- gui_syncsplash(HZ, ID2P(LANG_FAILED));
- else
- break;
- }
- else {
- gui_syncsplash(HZ, ID2P(LANG_CANCEL));
- return false;
- }
- }
-
- /* TODO: Should we really do this? */
- fdprintf(fd, "eq enabled: on\r\n");
- fdprintf(fd, "eq precut: %d\r\n", global_settings.eq_precut);
+ /* make sure that the eq is enabled for setting saving */
+ bool enabled = global_settings.eq_enabled;
+ global_settings.eq_enabled = true;
- setting = &global_settings.eq_band0_cutoff;
+ bool result = settings_save_config(SETTINGS_SAVE_EQPRESET);
- for(i = 0; i < 5; ++i) {
- fdprintf(fd, "eq band %d cutoff: %d\r\n", i, *setting++);
- fdprintf(fd, "eq band %d q: %d\r\n", i, *setting++);
- fdprintf(fd, "eq band %d gain: %d\r\n", i, *setting++);
- }
-
- close(fd);
+ global_settings.eq_enabled = enabled;
- gui_syncsplash(HZ, ID2P(LANG_SETTINGS_SAVED));
-
- return true;
+ return result;
}
/* Allows browsing of preset files */
@@ -648,7 +615,6 @@ bool eq_browse_presets(void)
return rockbox_browse(EQS_DIR, SHOW_CFG);
}
-
MENUITEM_FUNCTION(eq_graphical, 0, ID2P(LANG_EQUALIZER_GRAPHICAL),
(int(*)(void))eq_menu_graphical, NULL, NULL,
Icon_EQ);
diff --git a/apps/settings.c b/apps/settings.c
index b22c521..7f0de3e 100644
--- a/apps/settings.c
+++ b/apps/settings.c
@@ -477,6 +477,11 @@ static bool settings_write_config(char* filename, int options)
((settings[i].flags&F_RECSETTING) == 0))
continue;
#endif
+#if CONFIG_CODEC == SWCODEC
+ else if ((options == SETTINGS_SAVE_EQPRESET) &&
+ ((settings[i].flags&F_EQSETTING) == 0))
+ continue;
+#endif
switch (settings[i].flags&F_T_MASK)
{
case F_T_INT:
@@ -614,6 +619,11 @@ bool settings_save_config(int options)
folder = RECPRESETS_DIR;
break;
#endif
+#if CONFIG_CODEC == SWCODEC
+ case SETTINGS_SAVE_EQPRESET:
+ folder = EQS_DIR;
+ break;
+#endif
default:
folder = ROCKBOX_DIR;
}
diff --git a/apps/settings.h b/apps/settings.h
index a03a24a..0e4e627 100644
--- a/apps/settings.h
+++ b/apps/settings.h
@@ -207,6 +207,9 @@ enum {
#ifdef HAVE_RECORDING
SETTINGS_SAVE_RECPRESETS,
#endif
+#if CONFIG_CODEC == SWCODEC
+ SETTINGS_SAVE_EQPRESET,
+#endif
};
bool settings_save_config(int options);
diff --git a/apps/settings_list.c b/apps/settings_list.c
index ed879aa..3d5075c 100644
--- a/apps/settings_list.c
+++ b/apps/settings_list.c
@@ -906,58 +906,61 @@ const struct settings_list settings[] = {
INT_SETTING_NOWRAP(0, crossfeed_hf_cutoff, LANG_CROSSFEED_HF_CUTOFF, 700,
"crossfeed hf cutoff", UNIT_HERTZ, 500, 2000, 100,
NULL, NULL, crossfeed_cross_set),
+
/* equalizer */
- OFFON_SETTING(0,eq_enabled,LANG_EQUALIZER_ENABLED,false,"eq enabled",NULL),
- INT_SETTING_NOWRAP(0, eq_precut, LANG_EQUALIZER_PRECUT, 0, "eq precut",
- UNIT_DB, 0, 240, 5, eq_precut_format, NULL, dsp_set_eq_precut),
+ OFFON_SETTING(F_EQSETTING, eq_enabled, LANG_EQUALIZER_ENABLED, false,
+ "eq enabled", NULL),
+ INT_SETTING_NOWRAP(F_EQSETTING, eq_precut, LANG_EQUALIZER_PRECUT, 0,
+ "eq precut", UNIT_DB, 0, 240, 5, eq_precut_format, NULL,
+ dsp_set_eq_precut),
/* 0..32768 Hz */
- INT_SETTING_NOWRAP(0, eq_band0_cutoff, LANG_EQUALIZER_BAND_CUTOFF, 60,
- "eq band 0 cutoff", UNIT_HERTZ, EQ_CUTOFF_MIN,
+ INT_SETTING_NOWRAP(F_EQSETTING, eq_band0_cutoff, LANG_EQUALIZER_BAND_CUTOFF,
+ 60, "eq band 0 cutoff", UNIT_HERTZ, EQ_CUTOFF_MIN,
EQ_CUTOFF_MAX, EQ_CUTOFF_STEP, NULL, NULL, NULL),
- INT_SETTING_NOWRAP(0, eq_band1_cutoff, LANG_EQUALIZER_BAND_CENTER, 200,
- "eq band 1 cutoff", UNIT_HERTZ, EQ_CUTOFF_MIN,
+ INT_SETTING_NOWRAP(F_EQSETTING, eq_band1_cutoff, LANG_EQUALIZER_BAND_CENTER,
+ 200, "eq band 1 cutoff", UNIT_HERTZ, EQ_CUTOFF_MIN,
EQ_CUTOFF_MAX, EQ_CUTOFF_STEP, NULL, NULL, NULL),
- INT_SETTING_NOWRAP(0, eq_band2_cutoff, LANG_EQUALIZER_BAND_CENTER, 800,
- "eq band 2 cutoff", UNIT_HERTZ, EQ_CUTOFF_MIN,
+ INT_SETTING_NOWRAP(F_EQSETTING, eq_band2_cutoff, LANG_EQUALIZER_BAND_CENTER,
+ 800, "eq band 2 cutoff", UNIT_HERTZ, EQ_CUTOFF_MIN,
EQ_CUTOFF_MAX, EQ_CUTOFF_STEP, NULL, NULL, NULL),
- INT_SETTING_NOWRAP(0, eq_band3_cutoff, LANG_EQUALIZER_BAND_CENTER, 4000,
- "eq band 3 cutoff", UNIT_HERTZ, EQ_CUTOFF_MIN,
+ INT_SETTING_NOWRAP(F_EQSETTING, eq_band3_cutoff, LANG_EQUALIZER_BAND_CENTER,
+ 4000, "eq band 3 cutoff", UNIT_HERTZ, EQ_CUTOFF_MIN,
EQ_CUTOFF_MAX, EQ_CUTOFF_STEP, NULL, NULL, NULL),
- INT_SETTING_NOWRAP(0, eq_band4_cutoff, LANG_EQUALIZER_BAND_CUTOFF, 12000,
- "eq band 4 cutoff", UNIT_HERTZ, EQ_CUTOFF_MIN,
+ INT_SETTING_NOWRAP(F_EQSETTING, eq_band4_cutoff, LANG_EQUALIZER_BAND_CUTOFF,
+ 12000, "eq band 4 cutoff", UNIT_HERTZ, EQ_CUTOFF_MIN,
EQ_CUTOFF_MAX, EQ_CUTOFF_STEP, NULL, NULL, NULL),
/* 0..64 (or 0.0 to 6.4) */
- INT_SETTING_NOWRAP(0, eq_band0_q, LANG_EQUALIZER_BAND_Q, 7, "eq band 0 q",
- UNIT_INT, EQ_Q_MIN, EQ_Q_MAX, EQ_Q_STEP,
+ INT_SETTING_NOWRAP(F_EQSETTING, eq_band0_q, LANG_EQUALIZER_BAND_Q, 7,
+ "eq band 0 q", UNIT_INT, EQ_Q_MIN, EQ_Q_MAX, EQ_Q_STEP,
eq_q_format, NULL, NULL),
- INT_SETTING_NOWRAP(0, eq_band1_q, LANG_EQUALIZER_BAND_Q, 10, "eq band 1 q",
- UNIT_INT, EQ_Q_MIN, EQ_Q_MAX, EQ_Q_STEP,
+ INT_SETTING_NOWRAP(F_EQSETTING, eq_band1_q, LANG_EQUALIZER_BAND_Q, 10,
+ "eq band 1 q", UNIT_INT, EQ_Q_MIN, EQ_Q_MAX, EQ_Q_STEP,
eq_q_format, NULL, NULL),
- INT_SETTING_NOWRAP(0, eq_band2_q, LANG_EQUALIZER_BAND_Q, 10, "eq band 2 q",
- UNIT_INT, EQ_Q_MIN, EQ_Q_MAX, EQ_Q_STEP,
+ INT_SETTING_NOWRAP(F_EQSETTING, eq_band2_q, LANG_EQUALIZER_BAND_Q, 10,
+ "eq band 2 q", UNIT_INT, EQ_Q_MIN, EQ_Q_MAX, EQ_Q_STEP,
eq_q_format, NULL, NULL),
- INT_SETTING_NOWRAP(0, eq_band3_q, LANG_EQUALIZER_BAND_Q, 10, "eq band 3 q",
- UNIT_INT, EQ_Q_MIN, EQ_Q_MAX, EQ_Q_STEP,
+ INT_SETTING_NOWRAP(F_EQSETTING, eq_band3_q, LANG_EQUALIZER_BAND_Q, 10,
+ "eq band 3 q", UNIT_INT, EQ_Q_MIN, EQ_Q_MAX, EQ_Q_STEP,
eq_q_format, NULL, NULL),
- INT_SETTING_NOWRAP(0, eq_band4_q, LANG_EQUALIZER_BAND_Q, 7, "eq band 4 q",
- UNIT_INT, EQ_Q_MIN, EQ_Q_MAX, EQ_Q_STEP,
+ INT_SETTING_NOWRAP(F_EQSETTING, eq_band4_q, LANG_EQUALIZER_BAND_Q, 7,
+ "eq band 4 q", UNIT_INT, EQ_Q_MIN, EQ_Q_MAX, EQ_Q_STEP,
eq_q_format, NULL, NULL),
/* -240..240 (or -24db to +24db) */
- INT_SETTING_NOWRAP(0, eq_band0_gain, LANG_GAIN, 0, "eq band 0 gain",
- UNIT_DB, EQ_GAIN_MIN, EQ_GAIN_MAX, EQ_GAIN_STEP,
- eq_gain_format, NULL, NULL),
- INT_SETTING_NOWRAP(0, eq_band1_gain, LANG_GAIN, 0, "eq band 1 gain",
- UNIT_DB, EQ_GAIN_MIN, EQ_GAIN_MAX, EQ_GAIN_STEP,
- eq_gain_format, NULL, NULL),
- INT_SETTING_NOWRAP(0, eq_band2_gain, LANG_GAIN, 0, "eq band 2 gain",
- UNIT_DB, EQ_GAIN_MIN, EQ_GAIN_MAX, EQ_GAIN_STEP,
- eq_gain_format, NULL, NULL),
- INT_SETTING_NOWRAP(0, eq_band3_gain, LANG_GAIN, 0, "eq band 3 gain",
- UNIT_DB, EQ_GAIN_MIN, EQ_GAIN_MAX, EQ_GAIN_STEP,
- eq_gain_format, NULL, NULL),
- INT_SETTING_NOWRAP(0, eq_band4_gain, LANG_GAIN, 0, "eq band 4 gain",
- UNIT_DB, EQ_GAIN_MIN, EQ_GAIN_MAX, EQ_GAIN_STEP,
- eq_gain_format, NULL, NULL),
+ INT_SETTING_NOWRAP(F_EQSETTING, eq_band0_gain, LANG_GAIN, 0,
+ "eq band 0 gain", UNIT_DB, EQ_GAIN_MIN, EQ_GAIN_MAX,
+ EQ_GAIN_STEP, eq_gain_format, NULL, NULL),
+ INT_SETTING_NOWRAP(F_EQSETTING, eq_band1_gain, LANG_GAIN, 0,
+ "eq band 1 gain", UNIT_DB, EQ_GAIN_MIN, EQ_GAIN_MAX,
+ EQ_GAIN_STEP, eq_gain_format, NULL, NULL),
+ INT_SETTING_NOWRAP(F_EQSETTING, eq_band2_gain, LANG_GAIN, 0,
+ "eq band 2 gain", UNIT_DB, EQ_GAIN_MIN, EQ_GAIN_MAX,
+ EQ_GAIN_STEP, eq_gain_format, NULL, NULL),
+ INT_SETTING_NOWRAP(F_EQSETTING, eq_band3_gain, LANG_GAIN, 0,
+ "eq band 3 gain", UNIT_DB, EQ_GAIN_MIN, EQ_GAIN_MAX,
+ EQ_GAIN_STEP, eq_gain_format, NULL, NULL),
+ INT_SETTING_NOWRAP(F_EQSETTING, eq_band4_gain, LANG_GAIN, 0,
+ "eq band 4 gain", UNIT_DB, EQ_GAIN_MIN, EQ_GAIN_MAX,
+ EQ_GAIN_STEP, eq_gain_format, NULL, NULL),
/* dithering */
OFFON_SETTING(0, dithering_enabled, LANG_DITHERING,
diff --git a/apps/settings_list.h b/apps/settings_list.h
index 75768fe..b959789 100644
--- a/apps/settings_list.h
+++ b/apps/settings_list.h
@@ -104,6 +104,7 @@ struct table_setting {
#define F_THEMESETTING 0x0800000
#define F_RECSETTING 0x1000000
+#define F_EQSETTING 0x2000000
#define F_NVRAM_BYTES_MASK 0xE0000 /*0-4 bytes can be stored */
#define F_NVRAM_MASK_SHIFT 17