Move language resources to a separate file. Only build and include langs when buildin...
[Rockbox.git] / apps / menus / playback_menu.c
blob408537e8cf2f9776ebbee872236ce96bf39e7e26
2 /***************************************************************************
3 * __________ __ ___.
4 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
5 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
6 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
7 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
8 * \/ \/ \/ \/ \/
9 * $Id$
11 * Copyright (C) 2007 Jonathan Gordon
13 * All files in this archive are subject to the GNU General Public License.
14 * See the file COPYING in the source tree root for full license agreement.
16 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
17 * KIND, either express or implied.
19 ****************************************************************************/
21 #include <stdbool.h>
22 #include <stddef.h>
23 #include <limits.h>
24 #include "config.h"
25 #include "lang.h"
26 #include "action.h"
27 #include "splash.h"
28 #include "settings.h"
29 #include "menu.h"
30 #include "sound_menu.h"
31 #include "kernel.h"
32 #include "playlist.h"
33 #include "dsp.h"
34 #include "scrobbler.h"
35 #include "audio.h"
36 #include "cuesheet.h"
37 #if CONFIG_CODEC == SWCODEC
38 #include "playback.h"
39 #endif
42 #if CONFIG_CODEC == SWCODEC
43 static int setcrossfadeonexit_callback(int action,const struct menu_item_ex *this_item)
45 (void)this_item;
46 switch (action)
48 case ACTION_EXIT_MENUITEM: /* on exit */
49 audio_set_crossfade(global_settings.crossfade);
50 break;
52 return action;
55 #endif /* CONFIG_CODEC == SWCODEC */
57 /***********************************/
58 /* PLAYBACK MENU */
59 static int playback_callback(int action,const struct menu_item_ex *this_item);
61 MENUITEM_SETTING(shuffle_item, &global_settings.playlist_shuffle, playback_callback);
62 MENUITEM_SETTING(repeat_mode, &global_settings.repeat_mode, playback_callback);
63 MENUITEM_SETTING(play_selected, &global_settings.play_selected, NULL);
65 MENUITEM_SETTING(ff_rewind_accel, &global_settings.ff_rewind_accel, NULL);
66 MENUITEM_SETTING(ff_rewind_min_step, &global_settings.ff_rewind_min_step, NULL);
67 MAKE_MENU(ff_rewind_settings_menu, ID2P(LANG_WIND_MENU), 0, Icon_NOICON,
68 &ff_rewind_min_step, &ff_rewind_accel);
69 #ifndef HAVE_FLASH_STORAGE
70 #if CONFIG_CODEC == SWCODEC
71 static int buffermargin_callback(int action,const struct menu_item_ex *this_item)
73 (void)this_item;
74 switch (action)
76 case ACTION_EXIT_MENUITEM: /* on exit */
77 audio_set_buffer_margin(global_settings.buffer_margin);
78 break;
80 return action;
82 #else
83 # define buffermargin_callback NULL
84 #endif
85 MENUITEM_SETTING(buffer_margin, &global_settings.buffer_margin,
86 buffermargin_callback);
87 #endif /*HAVE_FLASH_STORAGE */
88 MENUITEM_SETTING(fade_on_stop, &global_settings.fade_on_stop, NULL);
89 MENUITEM_SETTING(party_mode, &global_settings.party_mode, NULL);
91 #if CONFIG_CODEC == SWCODEC
92 /* crossfade submenu */
93 MENUITEM_SETTING(crossfade, &global_settings.crossfade, setcrossfadeonexit_callback);
94 MENUITEM_SETTING(crossfade_fade_in_delay,
95 &global_settings.crossfade_fade_in_delay, setcrossfadeonexit_callback);
96 MENUITEM_SETTING(crossfade_fade_in_duration,
97 &global_settings.crossfade_fade_in_duration, setcrossfadeonexit_callback);
98 MENUITEM_SETTING(crossfade_fade_out_delay,
99 &global_settings.crossfade_fade_out_delay, setcrossfadeonexit_callback);
100 MENUITEM_SETTING(crossfade_fade_out_duration,
101 &global_settings.crossfade_fade_out_duration, setcrossfadeonexit_callback);
102 MENUITEM_SETTING(crossfade_fade_out_mixmode,
103 &global_settings.crossfade_fade_out_mixmode,NULL);
104 MAKE_MENU(crossfade_settings_menu,ID2P(LANG_CROSSFADE),0, Icon_NOICON,
105 &crossfade, &crossfade_fade_in_delay, &crossfade_fade_in_duration,
106 &crossfade_fade_out_delay, &crossfade_fade_out_duration,
107 &crossfade_fade_out_mixmode);
109 /* replay gain submenu */
111 static int replaygain_callback(int action,const struct menu_item_ex *this_item)
113 (void)this_item;
114 switch (action)
116 case ACTION_EXIT_MENUITEM: /* on exit */
117 dsp_set_replaygain();
118 break;
120 return action;
122 MENUITEM_SETTING(replaygain, &global_settings.replaygain ,replaygain_callback);
123 MENUITEM_SETTING(replaygain_noclip, &global_settings.replaygain_noclip ,replaygain_callback);
124 MENUITEM_SETTING(replaygain_type, &global_settings.replaygain_type ,replaygain_callback);
125 MENUITEM_SETTING(replaygain_preamp, &global_settings.replaygain_preamp ,replaygain_callback);
126 MAKE_MENU(replaygain_settings_menu,ID2P(LANG_REPLAYGAIN),0, Icon_NOICON,
127 &replaygain,&replaygain_noclip,
128 &replaygain_type,&replaygain_preamp);
130 MENUITEM_SETTING(beep, &global_settings.beep ,NULL);
131 #endif /* CONFIG_CODEC == SWCODEC */
133 #ifdef HAVE_SPDIF_POWER
134 MENUITEM_SETTING(spdif_enable, &global_settings.spdif_enable, NULL);
135 #endif
136 MENUITEM_SETTING(next_folder, &global_settings.next_folder, NULL);
137 static int audioscrobbler_callback(int action,const struct menu_item_ex *this_item)
139 (void)this_item;
140 switch (action)
142 case ACTION_EXIT_MENUITEM: /* on exit */
143 if (!scrobbler_is_enabled() && global_settings.audioscrobbler)
144 gui_syncsplash(HZ*2, ID2P(LANG_PLEASE_REBOOT));
146 if(scrobbler_is_enabled() && !global_settings.audioscrobbler)
147 scrobbler_shutdown();
148 break;
150 return action;
152 MENUITEM_SETTING(audioscrobbler, &global_settings.audioscrobbler, audioscrobbler_callback);
155 static int cuesheet_callback(int action,const struct menu_item_ex *this_item)
157 (void)this_item;
158 switch (action)
160 case ACTION_EXIT_MENUITEM: /* on exit */
161 if (!cuesheet_is_enabled() && global_settings.cuesheet)
162 gui_syncsplash(HZ*2, ID2P(LANG_PLEASE_REBOOT));
163 break;
165 return action;
167 MENUITEM_SETTING(cuesheet, &global_settings.cuesheet, cuesheet_callback);
169 #ifdef HAVE_HEADPHONE_DETECTION
170 MENUITEM_SETTING(unplug_mode, &global_settings.unplug_mode, NULL);
171 MENUITEM_SETTING(unplug_rw, &global_settings.unplug_rw, NULL);
172 MENUITEM_SETTING(unplug_autoresume, &global_settings.unplug_autoresume, NULL);
173 MAKE_MENU(unplug_menu, ID2P(LANG_HEADPHONE_UNPLUG), 0, Icon_NOICON,
174 &unplug_mode, &unplug_rw, &unplug_autoresume);
175 #endif
177 MENUITEM_SETTING(study_mode, &global_settings.study_mode, NULL);
178 MENUITEM_SETTING(study_hop_step, &global_settings.study_hop_step, NULL);
179 MAKE_MENU(study_mode_menu, ID2P(LANG_STUDY_MODE), 0, Icon_NOICON,
180 &study_mode, &study_hop_step);
182 MAKE_MENU(playback_settings,ID2P(LANG_PLAYBACK),0,
183 Icon_Playback_menu,
184 &shuffle_item, &repeat_mode, &play_selected,
185 &ff_rewind_settings_menu,
186 #ifndef HAVE_FLASH_STORAGE
187 &buffer_margin,
188 #endif
189 &fade_on_stop, &party_mode,
191 #if CONFIG_CODEC == SWCODEC
192 &crossfade_settings_menu, &replaygain_settings_menu, &beep,
193 #endif
195 #ifdef HAVE_SPDIF_POWER
196 &spdif_enable,
197 #endif
198 &next_folder, &audioscrobbler, &cuesheet
199 #ifdef HAVE_HEADPHONE_DETECTION
200 ,&unplug_menu
201 #endif
202 ,&study_mode_menu
205 static int playback_callback(int action,const struct menu_item_ex *this_item)
207 static bool old_shuffle = false;
208 static int old_repeat_mode = 0;
209 (void)this_item;
210 switch (action)
212 case ACTION_ENTER_MENUITEM:
213 if (this_item == &shuffle_item)
214 old_shuffle = global_settings.playlist_shuffle;
215 else if (this_item == &repeat_mode)
216 old_repeat_mode = global_settings.repeat_mode;
217 break;
218 case ACTION_EXIT_MENUITEM: /* on exit */
219 if ((this_item == &shuffle_item) &&
220 (old_shuffle != global_settings.playlist_shuffle)
221 && (audio_status() & AUDIO_STATUS_PLAY))
223 #if CONFIG_CODEC == SWCODEC
224 dsp_set_replaygain();
225 #endif
226 if (global_settings.playlist_shuffle)
228 playlist_randomise(NULL, current_tick, true);
230 else
232 playlist_sort(NULL, true);
235 break;
237 return action;
239 /* PLAYBACK MENU */
240 /***********************************/