diff options
author | Dan Everton <dan@iocaine.org> | 2008-03-30 09:31:09 +0000 |
---|---|---|
committer | Dan Everton <dan@iocaine.org> | 2008-03-30 09:31:09 +0000 |
commit | ad74906e18eb43df923ea686fa4d6b650fead72c (patch) | |
tree | c203c5365ef0d5c800410683b5f8bbaa7c4249d8 | |
parent | 52527a4d1db31ce4717ee259e1912c50215273a7 (diff) | |
download | rockbox-ad74906e18eb43df923ea686fa4d6b650fead72c.tar.gz rockbox-ad74906e18eb43df923ea686fa4d6b650fead72c.zip |
In the equalizer menu, switch to low-latency mode in the smallest scope rather than for the entire equalizer menu. Also mark some more functions as static.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@16888 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r-- | apps/menus/eq_menu.c | 95 |
1 files changed, 50 insertions, 45 deletions
diff --git a/apps/menus/eq_menu.c b/apps/menus/eq_menu.c index 9b8c2e3e6b..2b4e9ad8a8 100644 --- a/apps/menus/eq_menu.c +++ b/apps/menus/eq_menu.c | |||
@@ -66,7 +66,7 @@ void eq_precut_format(char* buffer, size_t buffer_size, int value, const char* u | |||
66 | /* | 66 | /* |
67 | * Settings functions | 67 | * Settings functions |
68 | */ | 68 | */ |
69 | void eq_apply(void) | 69 | static void eq_apply(void) |
70 | { | 70 | { |
71 | int i; | 71 | int i; |
72 | dsp_set_eq(global_settings.eq_enabled); | 72 | dsp_set_eq(global_settings.eq_enabled); |
@@ -76,37 +76,52 @@ void eq_apply(void) | |||
76 | dsp_set_eq_coefs(i); | 76 | dsp_set_eq_coefs(i); |
77 | } | 77 | } |
78 | } | 78 | } |
79 | int enable_callback(int action, const struct menu_item_ex *this_item) | ||
80 | { | ||
81 | (void)this_item; | ||
82 | if (action == ACTION_EXIT_MENUITEM) | ||
83 | eq_apply(); | ||
84 | return action; | ||
85 | } | ||
86 | MENUITEM_SETTING(eq_enable, &global_settings.eq_enabled, enable_callback); | ||
87 | MENUITEM_SETTING(eq_precut, &global_settings.eq_precut, enable_callback); | ||
88 | 79 | ||
89 | int dsp_set_coefs_callback(int action, const struct menu_item_ex *this_item) | 80 | static int eq_setting_callback(int action, const struct menu_item_ex *this_item) |
90 | { | 81 | { |
91 | (void)this_item; | 82 | switch (action) |
92 | if (action == ACTION_EXIT_MENUITEM) | ||
93 | { | 83 | { |
94 | /* for now, set every band... figure out a better way later */ | 84 | case ACTION_ENTER_MENUITEM: |
95 | int i=0; | 85 | action = lowlatency_callback(action, this_item); |
96 | for (i=0; i<5; i++) | 86 | break; |
97 | dsp_set_eq_coefs(i); | 87 | case ACTION_EXIT_MENUITEM: |
88 | eq_apply(); | ||
89 | action = lowlatency_callback(action, this_item); | ||
90 | break; | ||
98 | } | 91 | } |
92 | |||
99 | return action; | 93 | return action; |
100 | } | 94 | } |
101 | 95 | MENUITEM_SETTING(eq_enable, &global_settings.eq_enabled, eq_setting_callback); | |
102 | char* gainitem_get_name(int selected_item, void * data, char *buffer) | 96 | MENUITEM_SETTING(eq_precut, &global_settings.eq_precut, eq_setting_callback); |
97 | |||
98 | MENUITEM_SETTING(cutoff_0, &global_settings.eq_band0_cutoff, eq_setting_callback); | ||
99 | MENUITEM_SETTING(cutoff_1, &global_settings.eq_band1_cutoff, eq_setting_callback); | ||
100 | MENUITEM_SETTING(cutoff_2, &global_settings.eq_band2_cutoff, eq_setting_callback); | ||
101 | MENUITEM_SETTING(cutoff_3, &global_settings.eq_band3_cutoff, eq_setting_callback); | ||
102 | MENUITEM_SETTING(cutoff_4, &global_settings.eq_band4_cutoff, eq_setting_callback); | ||
103 | |||
104 | MENUITEM_SETTING(q_0, &global_settings.eq_band0_q, eq_setting_callback); | ||
105 | MENUITEM_SETTING(q_1, &global_settings.eq_band1_q, eq_setting_callback); | ||
106 | MENUITEM_SETTING(q_2, &global_settings.eq_band2_q, eq_setting_callback); | ||
107 | MENUITEM_SETTING(q_3, &global_settings.eq_band3_q, eq_setting_callback); | ||
108 | MENUITEM_SETTING(q_4, &global_settings.eq_band4_q, eq_setting_callback); | ||
109 | |||
110 | MENUITEM_SETTING(gain_0, &global_settings.eq_band0_gain, eq_setting_callback); | ||
111 | MENUITEM_SETTING(gain_1, &global_settings.eq_band1_gain, eq_setting_callback); | ||
112 | MENUITEM_SETTING(gain_2, &global_settings.eq_band2_gain, eq_setting_callback); | ||
113 | MENUITEM_SETTING(gain_3, &global_settings.eq_band3_gain, eq_setting_callback); | ||
114 | MENUITEM_SETTING(gain_4, &global_settings.eq_band4_gain, eq_setting_callback); | ||
115 | |||
116 | static char* gainitem_get_name(int selected_item, void * data, char *buffer) | ||
103 | { | 117 | { |
104 | (void)selected_item; | 118 | (void)selected_item; |
105 | int *setting = (int*)data; | 119 | int *setting = (int*)data; |
106 | snprintf(buffer, MAX_PATH, str(LANG_EQUALIZER_GAIN_ITEM), *setting); | 120 | snprintf(buffer, MAX_PATH, str(LANG_EQUALIZER_GAIN_ITEM), *setting); |
107 | return buffer; | 121 | return buffer; |
108 | } | 122 | } |
109 | int gainitem_speak_item(int selected_item, void * data) | 123 | |
124 | static int gainitem_speak_item(int selected_item, void * data) | ||
110 | { | 125 | { |
111 | (void)selected_item; | 126 | (void)selected_item; |
112 | int *setting = (int*)data; | 127 | int *setting = (int*)data; |
@@ -115,32 +130,16 @@ int gainitem_speak_item(int selected_item, void * data) | |||
115 | return 0; | 130 | return 0; |
116 | } | 131 | } |
117 | 132 | ||
118 | int do_option(void* param) | 133 | static int do_option(void * param) |
119 | { | 134 | { |
120 | const struct menu_item_ex *setting = (const struct menu_item_ex*)param; | 135 | const struct menu_item_ex *setting = (const struct menu_item_ex*)param; |
136 | lowlatency_callback(ACTION_ENTER_MENUITEM, setting); | ||
121 | do_setting_from_menu(setting); | 137 | do_setting_from_menu(setting); |
122 | eq_apply(); | 138 | eq_apply(); |
139 | lowlatency_callback(ACTION_EXIT_MENUITEM, setting); | ||
123 | return 0; | 140 | return 0; |
124 | } | 141 | } |
125 | 142 | ||
126 | MENUITEM_SETTING(cutoff_0, &global_settings.eq_band0_cutoff, dsp_set_coefs_callback); | ||
127 | MENUITEM_SETTING(cutoff_1, &global_settings.eq_band1_cutoff, dsp_set_coefs_callback); | ||
128 | MENUITEM_SETTING(cutoff_2, &global_settings.eq_band2_cutoff, dsp_set_coefs_callback); | ||
129 | MENUITEM_SETTING(cutoff_3, &global_settings.eq_band3_cutoff, dsp_set_coefs_callback); | ||
130 | MENUITEM_SETTING(cutoff_4, &global_settings.eq_band4_cutoff, dsp_set_coefs_callback); | ||
131 | |||
132 | MENUITEM_SETTING(q_0, &global_settings.eq_band0_q, dsp_set_coefs_callback); | ||
133 | MENUITEM_SETTING(q_1, &global_settings.eq_band1_q, dsp_set_coefs_callback); | ||
134 | MENUITEM_SETTING(q_2, &global_settings.eq_band2_q, dsp_set_coefs_callback); | ||
135 | MENUITEM_SETTING(q_3, &global_settings.eq_band3_q, dsp_set_coefs_callback); | ||
136 | MENUITEM_SETTING(q_4, &global_settings.eq_band4_q, dsp_set_coefs_callback); | ||
137 | |||
138 | MENUITEM_SETTING(gain_0, &global_settings.eq_band0_gain, dsp_set_coefs_callback); | ||
139 | MENUITEM_SETTING(gain_1, &global_settings.eq_band1_gain, dsp_set_coefs_callback); | ||
140 | MENUITEM_SETTING(gain_2, &global_settings.eq_band2_gain, dsp_set_coefs_callback); | ||
141 | MENUITEM_SETTING(gain_3, &global_settings.eq_band3_gain, dsp_set_coefs_callback); | ||
142 | MENUITEM_SETTING(gain_4, &global_settings.eq_band4_gain, dsp_set_coefs_callback); | ||
143 | |||
144 | MENUITEM_FUNCTION_DYNTEXT(gain_item_0, MENU_FUNC_USEPARAM, | 143 | MENUITEM_FUNCTION_DYNTEXT(gain_item_0, MENU_FUNC_USEPARAM, |
145 | do_option, (void*)&gain_0, | 144 | do_option, (void*)&gain_0, |
146 | gainitem_get_name, gainitem_speak_item, | 145 | gainitem_get_name, gainitem_speak_item, |
@@ -170,14 +169,16 @@ static const struct menu_item_ex *band_items[3][3] = { | |||
170 | { &cutoff_2, &q_2, &gain_2 }, | 169 | { &cutoff_2, &q_2, &gain_2 }, |
171 | { &cutoff_3, &q_3, &gain_3 } | 170 | { &cutoff_3, &q_3, &gain_3 } |
172 | }; | 171 | }; |
173 | char* centerband_get_name(int selected_item, void * data, char *buffer) | 172 | |
173 | static char* centerband_get_name(int selected_item, void * data, char *buffer) | ||
174 | { | 174 | { |
175 | (void)selected_item; | 175 | (void)selected_item; |
176 | int band = (intptr_t)data; | 176 | int band = (intptr_t)data; |
177 | snprintf(buffer, MAX_PATH, str(LANG_EQUALIZER_BAND_PEAK), band); | 177 | snprintf(buffer, MAX_PATH, str(LANG_EQUALIZER_BAND_PEAK), band); |
178 | return buffer; | 178 | return buffer; |
179 | } | 179 | } |
180 | int centerband_speak_item(int selected_item, void * data) | 180 | |
181 | static int centerband_speak_item(int selected_item, void * data) | ||
181 | { | 182 | { |
182 | (void)selected_item; | 183 | (void)selected_item; |
183 | int band = (intptr_t)data; | 184 | int band = (intptr_t)data; |
@@ -185,7 +186,8 @@ int centerband_speak_item(int selected_item, void * data) | |||
185 | talk_number(band, true); | 186 | talk_number(band, true); |
186 | return 0; | 187 | return 0; |
187 | } | 188 | } |
188 | int do_center_band_menu(void* param) | 189 | |
190 | static int do_center_band_menu(void* param) | ||
189 | { | 191 | { |
190 | int band = (intptr_t)param; | 192 | int band = (intptr_t)param; |
191 | struct menu_item_ex menu; | 193 | struct menu_item_ex menu; |
@@ -202,6 +204,7 @@ int do_center_band_menu(void* param) | |||
202 | do_menu(&menu, NULL, NULL, false); | 204 | do_menu(&menu, NULL, NULL, false); |
203 | return 0; | 205 | return 0; |
204 | } | 206 | } |
207 | |||
205 | MAKE_MENU(band_0_menu, ID2P(LANG_EQUALIZER_BAND_LOW_SHELF), NULL, | 208 | MAKE_MENU(band_0_menu, ID2P(LANG_EQUALIZER_BAND_LOW_SHELF), NULL, |
206 | Icon_EQ, &cutoff_0, &q_0, &gain_0); | 209 | Icon_EQ, &cutoff_0, &q_0, &gain_0); |
207 | MENUITEM_FUNCTION_DYNTEXT(band_1_menu, MENU_FUNC_USEPARAM, | 210 | MENUITEM_FUNCTION_DYNTEXT(band_1_menu, MENU_FUNC_USEPARAM, |
@@ -586,6 +589,7 @@ bool eq_menu_graphical(void) | |||
586 | screens[i].setfont(FONT_UI); | 589 | screens[i].setfont(FONT_UI); |
587 | screens[i].clear_display(); | 590 | screens[i].clear_display(); |
588 | } | 591 | } |
592 | |||
589 | return result; | 593 | return result; |
590 | } | 594 | } |
591 | 595 | ||
@@ -609,14 +613,15 @@ bool eq_browse_presets(void) | |||
609 | } | 613 | } |
610 | 614 | ||
611 | MENUITEM_FUNCTION(eq_graphical, 0, ID2P(LANG_EQUALIZER_GRAPHICAL), | 615 | MENUITEM_FUNCTION(eq_graphical, 0, ID2P(LANG_EQUALIZER_GRAPHICAL), |
612 | (int(*)(void))eq_menu_graphical, NULL, NULL, | 616 | (int(*)(void))eq_menu_graphical, NULL, lowlatency_callback, |
613 | Icon_EQ); | 617 | Icon_EQ); |
614 | MENUITEM_FUNCTION(eq_save, 0, ID2P(LANG_EQUALIZER_SAVE), | 618 | MENUITEM_FUNCTION(eq_save, 0, ID2P(LANG_EQUALIZER_SAVE), |
615 | (int(*)(void))eq_save_preset, NULL, NULL, Icon_NOICON); | 619 | (int(*)(void))eq_save_preset, NULL, NULL, Icon_NOICON); |
616 | MENUITEM_FUNCTION(eq_browse, 0, ID2P(LANG_EQUALIZER_BROWSE), | 620 | MENUITEM_FUNCTION(eq_browse, 0, ID2P(LANG_EQUALIZER_BROWSE), |
617 | (int(*)(void))eq_browse_presets, NULL, NULL, Icon_NOICON); | 621 | (int(*)(void))eq_browse_presets, NULL, lowlatency_callback, |
622 | Icon_NOICON); | ||
618 | 623 | ||
619 | MAKE_MENU(equalizer_menu, ID2P(LANG_EQUALIZER), lowlatency_callback, Icon_EQ, | 624 | MAKE_MENU(equalizer_menu, ID2P(LANG_EQUALIZER), NULL, Icon_EQ, |
620 | &eq_enable, &eq_graphical, &eq_precut, &gain_menu, | 625 | &eq_enable, &eq_graphical, &eq_precut, &gain_menu, |
621 | &advanced_eq_menu_, &eq_save, &eq_browse); | 626 | &advanced_eq_menu_, &eq_save, &eq_browse); |
622 | 627 | ||