blob: 4c4b29871ea4bf6ed6eeb400987b5bbb8a79c2fa [file] [log] [blame]
Jonathan Gordonfb628312007-02-12 14:22:35 +00001/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
Jonathan Gordon4e73b532007-02-13 00:32:17 +00008 * $Id$
Jonathan Gordonfb628312007-02-12 14:22:35 +00009 *
10 * Copyright (C) 2007 Jonathan Gordon
11 *
Daniel Stenberg2acc0ac2008-06-28 18:10:04 +000012 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
Jonathan Gordonfb628312007-02-12 14:22:35 +000016 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21
22#include <stdbool.h>
23#include <stddef.h>
24#include <limits.h>
25#include "config.h"
26#include "lang.h"
27#include "action.h"
28#include "splash.h"
29#include "settings.h"
30#include "menu.h"
31#include "sound_menu.h"
32#include "kernel.h"
33#include "playlist.h"
34#include "dsp.h"
35#include "scrobbler.h"
36#include "audio.h"
Thom Johansen4a7e0c72008-07-14 20:39:30 +000037#include "cuesheet.h"
38#if CONFIG_CODEC == SWCODEC
39#include "playback.h"
40#endif
Steve Bavinc9df8fd2008-03-28 11:24:24 +000041
Jonathan Gordonfb628312007-02-12 14:22:35 +000042
43#if CONFIG_CODEC == SWCODEC
Bertrik Sikken56337842008-04-19 23:29:39 +000044static int setcrossfadeonexit_callback(int action,const struct menu_item_ex *this_item)
Jonathan Gordonfb628312007-02-12 14:22:35 +000045{
46 (void)this_item;
47 switch (action)
48 {
49 case ACTION_EXIT_MENUITEM: /* on exit */
50 audio_set_crossfade(global_settings.crossfade);
51 break;
52 }
53 return action;
54}
55
56#endif /* CONFIG_CODEC == SWCODEC */
57
58/***********************************/
59/* PLAYBACK MENU */
Bertrik Sikken56337842008-04-19 23:29:39 +000060static int playback_callback(int action,const struct menu_item_ex *this_item);
Jonathan Gordonfb628312007-02-12 14:22:35 +000061
62MENUITEM_SETTING(shuffle_item, &global_settings.playlist_shuffle, playback_callback);
63MENUITEM_SETTING(repeat_mode, &global_settings.repeat_mode, playback_callback);
64MENUITEM_SETTING(play_selected, &global_settings.play_selected, NULL);
Jonathan Gordonfb628312007-02-12 14:22:35 +000065
66MENUITEM_SETTING(ff_rewind_accel, &global_settings.ff_rewind_accel, NULL);
67MENUITEM_SETTING(ff_rewind_min_step, &global_settings.ff_rewind_min_step, NULL);
Jonathan Gordon02a87172007-03-03 13:52:14 +000068MAKE_MENU(ff_rewind_settings_menu, ID2P(LANG_WIND_MENU), 0, Icon_NOICON,
Jonathan Gordonfb628312007-02-12 14:22:35 +000069 &ff_rewind_min_step, &ff_rewind_accel);
Frank Gevaerts46573012008-10-07 19:37:33 +000070#ifdef HAVE_DISK_STORAGE
Jonathan Gordonfb628312007-02-12 14:22:35 +000071#if CONFIG_CODEC == SWCODEC
Bertrik Sikken56337842008-04-19 23:29:39 +000072static int buffermargin_callback(int action,const struct menu_item_ex *this_item)
Jonathan Gordonfb628312007-02-12 14:22:35 +000073{
74 (void)this_item;
75 switch (action)
76 {
77 case ACTION_EXIT_MENUITEM: /* on exit */
78 audio_set_buffer_margin(global_settings.buffer_margin);
79 break;
80 }
81 return action;
82}
83#else
84# define buffermargin_callback NULL
85#endif
86MENUITEM_SETTING(buffer_margin, &global_settings.buffer_margin,
87 buffermargin_callback);
Frank Gevaerts46573012008-10-07 19:37:33 +000088#endif /*HAVE_DISK_STORAGE */
Jonathan Gordonfb628312007-02-12 14:22:35 +000089MENUITEM_SETTING(fade_on_stop, &global_settings.fade_on_stop, NULL);
90MENUITEM_SETTING(party_mode, &global_settings.party_mode, NULL);
91
92#if CONFIG_CODEC == SWCODEC
93/* crossfade submenu */
94MENUITEM_SETTING(crossfade, &global_settings.crossfade, setcrossfadeonexit_callback);
95MENUITEM_SETTING(crossfade_fade_in_delay,
96 &global_settings.crossfade_fade_in_delay, setcrossfadeonexit_callback);
97MENUITEM_SETTING(crossfade_fade_in_duration,
98 &global_settings.crossfade_fade_in_duration, setcrossfadeonexit_callback);
99MENUITEM_SETTING(crossfade_fade_out_delay,
100 &global_settings.crossfade_fade_out_delay, setcrossfadeonexit_callback);
101MENUITEM_SETTING(crossfade_fade_out_duration,
102 &global_settings.crossfade_fade_out_duration, setcrossfadeonexit_callback);
103MENUITEM_SETTING(crossfade_fade_out_mixmode,
104 &global_settings.crossfade_fade_out_mixmode,NULL);
Michael Giacomelli64699262009-08-11 02:05:38 +0000105#ifdef HAVE_CROSSFADE
Jonathan Gordon02a87172007-03-03 13:52:14 +0000106MAKE_MENU(crossfade_settings_menu,ID2P(LANG_CROSSFADE),0, Icon_NOICON,
Jonathan Gordonfb628312007-02-12 14:22:35 +0000107 &crossfade, &crossfade_fade_in_delay, &crossfade_fade_in_duration,
108 &crossfade_fade_out_delay, &crossfade_fade_out_duration,
109 &crossfade_fade_out_mixmode);
Michael Giacomelli47a09012009-08-11 01:09:05 +0000110#endif
Jonathan Gordonfb628312007-02-12 14:22:35 +0000111
112/* replay gain submenu */
113
Bertrik Sikken56337842008-04-19 23:29:39 +0000114static int replaygain_callback(int action,const struct menu_item_ex *this_item)
Jonathan Gordonfb628312007-02-12 14:22:35 +0000115{
116 (void)this_item;
117 switch (action)
118 {
Jonathan Gordon91cb68a2007-03-01 11:14:46 +0000119 case ACTION_EXIT_MENUITEM: /* on exit */
Michael Sevakisd4e904b2007-02-24 17:06:36 +0000120 dsp_set_replaygain();
Jonathan Gordonfb628312007-02-12 14:22:35 +0000121 break;
122 }
123 return action;
124}
Jonathan Gordonfb628312007-02-12 14:22:35 +0000125MENUITEM_SETTING(replaygain_noclip, &global_settings.replaygain_noclip ,replaygain_callback);
126MENUITEM_SETTING(replaygain_type, &global_settings.replaygain_type ,replaygain_callback);
127MENUITEM_SETTING(replaygain_preamp, &global_settings.replaygain_preamp ,replaygain_callback);
Jonathan Gordon02a87172007-03-03 13:52:14 +0000128MAKE_MENU(replaygain_settings_menu,ID2P(LANG_REPLAYGAIN),0, Icon_NOICON,
Alexander Levin8589fcb2009-06-20 21:13:24 +0000129 &replaygain_type, &replaygain_noclip, &replaygain_preamp);
Jonathan Gordonfb628312007-02-12 14:22:35 +0000130
131MENUITEM_SETTING(beep, &global_settings.beep ,NULL);
132#endif /* CONFIG_CODEC == SWCODEC */
133
134#ifdef HAVE_SPDIF_POWER
135MENUITEM_SETTING(spdif_enable, &global_settings.spdif_enable, NULL);
136#endif
Jonathan Gordonfb628312007-02-12 14:22:35 +0000137MENUITEM_SETTING(next_folder, &global_settings.next_folder, NULL);
Bertrik Sikken56337842008-04-19 23:29:39 +0000138static int audioscrobbler_callback(int action,const struct menu_item_ex *this_item)
Jonathan Gordonfb628312007-02-12 14:22:35 +0000139{
140 (void)this_item;
141 switch (action)
142 {
143 case ACTION_EXIT_MENUITEM: /* on exit */
144 if (!scrobbler_is_enabled() && global_settings.audioscrobbler)
Nils Wallménius01729e72008-08-15 08:27:39 +0000145 splash(HZ*2, ID2P(LANG_PLEASE_REBOOT));
Jonathan Gordonfb628312007-02-12 14:22:35 +0000146
147 if(scrobbler_is_enabled() && !global_settings.audioscrobbler)
148 scrobbler_shutdown();
149 break;
150 }
151 return action;
152}
153MENUITEM_SETTING(audioscrobbler, &global_settings.audioscrobbler, audioscrobbler_callback);
154
Nicolas Pennequin9f4bd872007-02-14 14:40:24 +0000155
Bertrik Sikken56337842008-04-19 23:29:39 +0000156static int cuesheet_callback(int action,const struct menu_item_ex *this_item)
Nicolas Pennequin9f4bd872007-02-14 14:40:24 +0000157{
158 (void)this_item;
159 switch (action)
160 {
161 case ACTION_EXIT_MENUITEM: /* on exit */
Jonathan Gordon24b136f2009-07-20 05:18:18 +0000162 if (global_settings.cuesheet)
Nils Wallménius01729e72008-08-15 08:27:39 +0000163 splash(HZ*2, ID2P(LANG_PLEASE_REBOOT));
Nicolas Pennequin9f4bd872007-02-14 14:40:24 +0000164 break;
165 }
166 return action;
167}
168MENUITEM_SETTING(cuesheet, &global_settings.cuesheet, cuesheet_callback);
169
Jonathan Gordonfb628312007-02-12 14:22:35 +0000170#ifdef HAVE_HEADPHONE_DETECTION
171MENUITEM_SETTING(unplug_mode, &global_settings.unplug_mode, NULL);
172MENUITEM_SETTING(unplug_rw, &global_settings.unplug_rw, NULL);
173MENUITEM_SETTING(unplug_autoresume, &global_settings.unplug_autoresume, NULL);
Nils Wallméniusb3113672007-08-05 19:19:39 +0000174MAKE_MENU(unplug_menu, ID2P(LANG_HEADPHONE_UNPLUG), 0, Icon_NOICON,
Jonathan Gordonfb628312007-02-12 14:22:35 +0000175 &unplug_mode, &unplug_rw, &unplug_autoresume);
176#endif
177
Thom Johansen4a7e0c72008-07-14 20:39:30 +0000178MENUITEM_SETTING(skip_length, &global_settings.skip_length, NULL);
Thomas Martitz62f3e952009-03-27 13:53:29 +0000179MENUITEM_SETTING(prevent_skip, &global_settings.prevent_skip, NULL);
Stéphane Doyonab0f7e12008-05-04 13:47:58 +0000180
Steve Bavin5f8bd632008-05-22 08:02:48 +0000181MAKE_MENU(playback_settings,ID2P(LANG_PLAYBACK),0,
Jonathan Gordon02a87172007-03-03 13:52:14 +0000182 Icon_Playback_menu,
Jonathan Gordon91cb68a2007-03-01 11:14:46 +0000183 &shuffle_item, &repeat_mode, &play_selected,
Nils Wallménius0bfa3e72007-08-01 08:50:44 +0000184 &ff_rewind_settings_menu,
Frank Gevaerts46573012008-10-07 19:37:33 +0000185#ifdef HAVE_DISK_STORAGE
Nils Wallménius0bfa3e72007-08-01 08:50:44 +0000186 &buffer_margin,
187#endif
188 &fade_on_stop, &party_mode,
Jonathan Gordonfb628312007-02-12 14:22:35 +0000189
Michael Giacomelli64699262009-08-11 02:05:38 +0000190#if CONFIG_CODEC == SWCODEC && defined(HAVE_CROSSFADE)
Michael Giacomelli88906e32009-08-11 02:18:22 +0000191 &crossfade_settings_menu,
192#endif
193
194#if CONFIG_CODEC == SWCODEC
195 &replaygain_settings_menu, &beep,
Jonathan Gordonfb628312007-02-12 14:22:35 +0000196#endif
197
198#ifdef HAVE_SPDIF_POWER
199 &spdif_enable,
200#endif
Thom Johansen294ec1d2007-09-19 10:40:55 +0000201 &next_folder, &audioscrobbler, &cuesheet
Jonathan Gordonfb628312007-02-12 14:22:35 +0000202#ifdef HAVE_HEADPHONE_DETECTION
203 ,&unplug_menu
204#endif
Thomas Martitz62f3e952009-03-27 13:53:29 +0000205 ,&skip_length, &prevent_skip,
Jonathan Gordonfb628312007-02-12 14:22:35 +0000206 );
Jonathan Gordon1ebdd5b2007-02-17 14:39:02 +0000207
Bertrik Sikken56337842008-04-19 23:29:39 +0000208static int playback_callback(int action,const struct menu_item_ex *this_item)
Jonathan Gordonfb628312007-02-12 14:22:35 +0000209{
210 static bool old_shuffle = false;
211 static int old_repeat_mode = 0;
212 (void)this_item;
213 switch (action)
214 {
215 case ACTION_ENTER_MENUITEM:
Jonathan Gordonfb628312007-02-12 14:22:35 +0000216 if (this_item == &shuffle_item)
217 old_shuffle = global_settings.playlist_shuffle;
218 else if (this_item == &repeat_mode)
219 old_repeat_mode = global_settings.repeat_mode;
220 break;
221 case ACTION_EXIT_MENUITEM: /* on exit */
222 if ((this_item == &shuffle_item) &&
223 (old_shuffle != global_settings.playlist_shuffle)
224 && (audio_status() & AUDIO_STATUS_PLAY))
225 {
226#if CONFIG_CODEC == SWCODEC
Michael Sevakisd4e904b2007-02-24 17:06:36 +0000227 dsp_set_replaygain();
Jonathan Gordonfb628312007-02-12 14:22:35 +0000228#endif
229 if (global_settings.playlist_shuffle)
230 {
231 playlist_randomise(NULL, current_tick, true);
232 }
233 else
234 {
235 playlist_sort(NULL, true);
236 }
237 }
238 break;
239 }
240 return action;
241}
242/* PLAYBACK MENU */
243/***********************************/