make sure closing the application aborts the remaining HttpGet objects. Should fix...
[Rockbox.git] / apps / menus / playback_menu.c
blob0d4162c5843b9b0aa85d1030449c16e0f8448c4e
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"
38 #if CONFIG_CODEC == SWCODEC
39 int setcrossfadeonexit_callback(int action,const struct menu_item_ex *this_item)
41 (void)this_item;
42 switch (action)
44 case ACTION_EXIT_MENUITEM: /* on exit */
45 audio_set_crossfade(global_settings.crossfade);
46 break;
48 return action;
51 #endif /* CONFIG_CODEC == SWCODEC */
53 /***********************************/
54 /* PLAYBACK MENU */
55 int playback_callback(int action,const struct menu_item_ex *this_item);
57 MENUITEM_SETTING(shuffle_item, &global_settings.playlist_shuffle, playback_callback);
58 MENUITEM_SETTING(repeat_mode, &global_settings.repeat_mode, playback_callback);
59 MENUITEM_SETTING(play_selected, &global_settings.play_selected, NULL);
61 MENUITEM_SETTING(ff_rewind_accel, &global_settings.ff_rewind_accel, NULL);
62 MENUITEM_SETTING(ff_rewind_min_step, &global_settings.ff_rewind_min_step, NULL);
63 MAKE_MENU(ff_rewind_settings_menu, ID2P(LANG_WIND_MENU), 0, Icon_NOICON,
64 &ff_rewind_min_step, &ff_rewind_accel);
65 #ifndef HAVE_FLASH_STORAGE
66 #if CONFIG_CODEC == SWCODEC
67 int buffermargin_callback(int action,const struct menu_item_ex *this_item)
69 (void)this_item;
70 switch (action)
72 case ACTION_EXIT_MENUITEM: /* on exit */
73 audio_set_buffer_margin(global_settings.buffer_margin);
74 break;
76 return action;
78 #else
79 # define buffermargin_callback NULL
80 #endif
81 MENUITEM_SETTING(buffer_margin, &global_settings.buffer_margin,
82 buffermargin_callback);
83 #endif /*HAVE_FLASH_STORAGE */
84 MENUITEM_SETTING(fade_on_stop, &global_settings.fade_on_stop, NULL);
85 MENUITEM_SETTING(party_mode, &global_settings.party_mode, NULL);
87 #if CONFIG_CODEC == SWCODEC
88 /* crossfade submenu */
89 MENUITEM_SETTING(crossfade, &global_settings.crossfade, setcrossfadeonexit_callback);
90 MENUITEM_SETTING(crossfade_fade_in_delay,
91 &global_settings.crossfade_fade_in_delay, setcrossfadeonexit_callback);
92 MENUITEM_SETTING(crossfade_fade_in_duration,
93 &global_settings.crossfade_fade_in_duration, setcrossfadeonexit_callback);
94 MENUITEM_SETTING(crossfade_fade_out_delay,
95 &global_settings.crossfade_fade_out_delay, setcrossfadeonexit_callback);
96 MENUITEM_SETTING(crossfade_fade_out_duration,
97 &global_settings.crossfade_fade_out_duration, setcrossfadeonexit_callback);
98 MENUITEM_SETTING(crossfade_fade_out_mixmode,
99 &global_settings.crossfade_fade_out_mixmode,NULL);
100 MAKE_MENU(crossfade_settings_menu,ID2P(LANG_CROSSFADE),0, Icon_NOICON,
101 &crossfade, &crossfade_fade_in_delay, &crossfade_fade_in_duration,
102 &crossfade_fade_out_delay, &crossfade_fade_out_duration,
103 &crossfade_fade_out_mixmode);
105 /* replay gain submenu */
107 int replaygain_callback(int action,const struct menu_item_ex *this_item)
109 (void)this_item;
110 switch (action)
112 case ACTION_EXIT_MENUITEM: /* on exit */
113 dsp_set_replaygain();
114 break;
116 return action;
118 MENUITEM_SETTING(replaygain, &global_settings.replaygain ,replaygain_callback);
119 MENUITEM_SETTING(replaygain_noclip, &global_settings.replaygain_noclip ,replaygain_callback);
120 MENUITEM_SETTING(replaygain_type, &global_settings.replaygain_type ,replaygain_callback);
121 MENUITEM_SETTING(replaygain_preamp, &global_settings.replaygain_preamp ,replaygain_callback);
122 MAKE_MENU(replaygain_settings_menu,ID2P(LANG_REPLAYGAIN),0, Icon_NOICON,
123 &replaygain,&replaygain_noclip,
124 &replaygain_type,&replaygain_preamp);
126 MENUITEM_SETTING(beep, &global_settings.beep ,NULL);
127 #endif /* CONFIG_CODEC == SWCODEC */
129 #ifdef HAVE_SPDIF_POWER
130 MENUITEM_SETTING(spdif_enable, &global_settings.spdif_enable, NULL);
131 #endif
132 MENUITEM_SETTING(id3_v1_first, &global_settings.id3_v1_first, NULL);
133 MENUITEM_SETTING(next_folder, &global_settings.next_folder, NULL);
134 int audioscrobbler_callback(int action,const struct menu_item_ex *this_item)
136 (void)this_item;
137 switch (action)
139 case ACTION_EXIT_MENUITEM: /* on exit */
140 if (!scrobbler_is_enabled() && global_settings.audioscrobbler)
141 gui_syncsplash(HZ*2, ID2P(LANG_PLEASE_REBOOT));
143 if(scrobbler_is_enabled() && !global_settings.audioscrobbler)
144 scrobbler_shutdown();
145 break;
147 return action;
149 MENUITEM_SETTING(audioscrobbler, &global_settings.audioscrobbler, audioscrobbler_callback);
152 int cuesheet_callback(int action,const struct menu_item_ex *this_item)
154 (void)this_item;
155 switch (action)
157 case ACTION_EXIT_MENUITEM: /* on exit */
158 if (!cuesheet_is_enabled() && global_settings.cuesheet)
159 gui_syncsplash(HZ*2, ID2P(LANG_PLEASE_REBOOT));
160 break;
162 return action;
164 MENUITEM_SETTING(cuesheet, &global_settings.cuesheet, cuesheet_callback);
166 #ifdef HAVE_HEADPHONE_DETECTION
167 MENUITEM_SETTING(unplug_mode, &global_settings.unplug_mode, NULL);
168 MENUITEM_SETTING(unplug_rw, &global_settings.unplug_rw, NULL);
169 MENUITEM_SETTING(unplug_autoresume, &global_settings.unplug_autoresume, NULL);
170 MAKE_MENU(unplug_menu, ID2P(LANG_HEADPHONE_UNPLUG), 0, Icon_NOICON,
171 &unplug_mode, &unplug_rw, &unplug_autoresume);
172 #endif
174 MAKE_MENU(playback_menu_item,ID2P(LANG_PLAYBACK),0,
175 Icon_Playback_menu,
176 &shuffle_item, &repeat_mode, &play_selected,
177 &ff_rewind_settings_menu,
178 #ifndef HAVE_FLASH_STORAGE
179 &buffer_margin,
180 #endif
181 &fade_on_stop, &party_mode,
183 #if CONFIG_CODEC == SWCODEC
184 &crossfade_settings_menu, &replaygain_settings_menu, &beep,
185 #endif
187 #ifdef HAVE_SPDIF_POWER
188 &spdif_enable,
189 #endif
190 &id3_v1_first, &next_folder, &audioscrobbler, &cuesheet
191 #ifdef HAVE_HEADPHONE_DETECTION
192 ,&unplug_menu
193 #endif
196 int playback_callback(int action,const struct menu_item_ex *this_item)
198 static bool old_shuffle = false;
199 static int old_repeat_mode = 0;
200 (void)this_item;
201 switch (action)
203 case ACTION_ENTER_MENUITEM:
204 if (this_item == &shuffle_item)
205 old_shuffle = global_settings.playlist_shuffle;
206 else if (this_item == &repeat_mode)
207 old_repeat_mode = global_settings.repeat_mode;
208 break;
209 case ACTION_EXIT_MENUITEM: /* on exit */
210 if ((this_item == &shuffle_item) &&
211 (old_shuffle != global_settings.playlist_shuffle)
212 && (audio_status() & AUDIO_STATUS_PLAY))
214 #if CONFIG_CODEC == SWCODEC
215 dsp_set_replaygain();
216 #endif
217 if (global_settings.playlist_shuffle)
219 playlist_randomise(NULL, current_tick, true);
221 else
223 playlist_sort(NULL, true);
226 break;
228 return action;
230 /* PLAYBACK MENU */
231 /***********************************/