blob: 2d3f3d17b25a96437f627f752f85e292e6483e2a [file] [log] [blame]
Jonathan Gordonfb628312007-02-12 14:22:35 +00001
2/***************************************************************************
3 * __________ __ ___.
4 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
5 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
6 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
7 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
8 * \/ \/ \/ \/ \/
Jonathan Gordon4e73b532007-02-13 00:32:17 +00009 * $Id$
Jonathan Gordonfb628312007-02-12 14:22:35 +000010 *
11 * Copyright (C) 2007 Jonathan Gordon
12 *
Daniel Stenberg2acc0ac2008-06-28 18:10:04 +000013 * This program is free software; you can redistribute it and/or
14 * modify it under the terms of the GNU General Public License
15 * as published by the Free Software Foundation; either version 2
16 * of the License, or (at your option) any later version.
Jonathan Gordonfb628312007-02-12 14:22:35 +000017 *
18 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19 * KIND, either express or implied.
20 *
21 ****************************************************************************/
22
23#include <stdbool.h>
24#include <stddef.h>
25#include <limits.h>
26#include "config.h"
27#include "lang.h"
28#include "action.h"
29#include "splash.h"
30#include "settings.h"
31#include "menu.h"
32#include "sound_menu.h"
33#include "kernel.h"
34#include "playlist.h"
35#include "dsp.h"
36#include "scrobbler.h"
37#include "audio.h"
Steve Bavinc9df8fd2008-03-28 11:24:24 +000038#include "cuesheet.h"
39#if CONFIG_CODEC == SWCODEC
40#include "playback.h"
41#endif
42
Jonathan Gordonfb628312007-02-12 14:22:35 +000043
44#if CONFIG_CODEC == SWCODEC
Bertrik Sikken56337842008-04-19 23:29:39 +000045static int setcrossfadeonexit_callback(int action,const struct menu_item_ex *this_item)
Jonathan Gordonfb628312007-02-12 14:22:35 +000046{
47 (void)this_item;
48 switch (action)
49 {
50 case ACTION_EXIT_MENUITEM: /* on exit */
51 audio_set_crossfade(global_settings.crossfade);
52 break;
53 }
54 return action;
55}
56
57#endif /* CONFIG_CODEC == SWCODEC */
58
59/***********************************/
60/* PLAYBACK MENU */
Bertrik Sikken56337842008-04-19 23:29:39 +000061static int playback_callback(int action,const struct menu_item_ex *this_item);
Jonathan Gordonfb628312007-02-12 14:22:35 +000062
63MENUITEM_SETTING(shuffle_item, &global_settings.playlist_shuffle, playback_callback);
64MENUITEM_SETTING(repeat_mode, &global_settings.repeat_mode, playback_callback);
65MENUITEM_SETTING(play_selected, &global_settings.play_selected, NULL);
Jonathan Gordonfb628312007-02-12 14:22:35 +000066
67MENUITEM_SETTING(ff_rewind_accel, &global_settings.ff_rewind_accel, NULL);
68MENUITEM_SETTING(ff_rewind_min_step, &global_settings.ff_rewind_min_step, NULL);
Jonathan Gordon02a87172007-03-03 13:52:14 +000069MAKE_MENU(ff_rewind_settings_menu, ID2P(LANG_WIND_MENU), 0, Icon_NOICON,
Jonathan Gordonfb628312007-02-12 14:22:35 +000070 &ff_rewind_min_step, &ff_rewind_accel);
Nils Wallménius0bfa3e72007-08-01 08:50:44 +000071#ifndef HAVE_FLASH_STORAGE
Jonathan Gordonfb628312007-02-12 14:22:35 +000072#if CONFIG_CODEC == SWCODEC
Bertrik Sikken56337842008-04-19 23:29:39 +000073static int buffermargin_callback(int action,const struct menu_item_ex *this_item)
Jonathan Gordonfb628312007-02-12 14:22:35 +000074{
75 (void)this_item;
76 switch (action)
77 {
78 case ACTION_EXIT_MENUITEM: /* on exit */
79 audio_set_buffer_margin(global_settings.buffer_margin);
80 break;
81 }
82 return action;
83}
84#else
85# define buffermargin_callback NULL
86#endif
87MENUITEM_SETTING(buffer_margin, &global_settings.buffer_margin,
88 buffermargin_callback);
Nils Wallménius0bfa3e72007-08-01 08:50:44 +000089#endif /*HAVE_FLASH_STORAGE */
Jonathan Gordonfb628312007-02-12 14:22:35 +000090MENUITEM_SETTING(fade_on_stop, &global_settings.fade_on_stop, NULL);
91MENUITEM_SETTING(party_mode, &global_settings.party_mode, NULL);
92
93#if CONFIG_CODEC == SWCODEC
94/* crossfade submenu */
95MENUITEM_SETTING(crossfade, &global_settings.crossfade, setcrossfadeonexit_callback);
96MENUITEM_SETTING(crossfade_fade_in_delay,
97 &global_settings.crossfade_fade_in_delay, setcrossfadeonexit_callback);
98MENUITEM_SETTING(crossfade_fade_in_duration,
99 &global_settings.crossfade_fade_in_duration, setcrossfadeonexit_callback);
100MENUITEM_SETTING(crossfade_fade_out_delay,
101 &global_settings.crossfade_fade_out_delay, setcrossfadeonexit_callback);
102MENUITEM_SETTING(crossfade_fade_out_duration,
103 &global_settings.crossfade_fade_out_duration, setcrossfadeonexit_callback);
104MENUITEM_SETTING(crossfade_fade_out_mixmode,
105 &global_settings.crossfade_fade_out_mixmode,NULL);
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);
110
111/* replay gain submenu */
112
Bertrik Sikken56337842008-04-19 23:29:39 +0000113static int replaygain_callback(int action,const struct menu_item_ex *this_item)
Jonathan Gordonfb628312007-02-12 14:22:35 +0000114{
115 (void)this_item;
116 switch (action)
117 {
Jonathan Gordon91cb68a2007-03-01 11:14:46 +0000118 case ACTION_EXIT_MENUITEM: /* on exit */
Michael Sevakisd4e904b2007-02-24 17:06:36 +0000119 dsp_set_replaygain();
Jonathan Gordonfb628312007-02-12 14:22:35 +0000120 break;
121 }
122 return action;
123}
124MENUITEM_SETTING(replaygain, &global_settings.replaygain ,replaygain_callback);
125MENUITEM_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,
Jonathan Gordonfb628312007-02-12 14:22:35 +0000129 &replaygain,&replaygain_noclip,
130 &replaygain_type,&replaygain_preamp);
131
132MENUITEM_SETTING(beep, &global_settings.beep ,NULL);
133#endif /* CONFIG_CODEC == SWCODEC */
134
135#ifdef HAVE_SPDIF_POWER
136MENUITEM_SETTING(spdif_enable, &global_settings.spdif_enable, NULL);
137#endif
Jonathan Gordonfb628312007-02-12 14:22:35 +0000138MENUITEM_SETTING(next_folder, &global_settings.next_folder, NULL);
Bertrik Sikken56337842008-04-19 23:29:39 +0000139static int audioscrobbler_callback(int action,const struct menu_item_ex *this_item)
Jonathan Gordonfb628312007-02-12 14:22:35 +0000140{
141 (void)this_item;
142 switch (action)
143 {
144 case ACTION_EXIT_MENUITEM: /* on exit */
145 if (!scrobbler_is_enabled() && global_settings.audioscrobbler)
Nils Wallménius5b769362007-08-06 13:08:36 +0000146 gui_syncsplash(HZ*2, ID2P(LANG_PLEASE_REBOOT));
Jonathan Gordonfb628312007-02-12 14:22:35 +0000147
148 if(scrobbler_is_enabled() && !global_settings.audioscrobbler)
149 scrobbler_shutdown();
150 break;
151 }
152 return action;
153}
154MENUITEM_SETTING(audioscrobbler, &global_settings.audioscrobbler, audioscrobbler_callback);
155
Nicolas Pennequin9f4bd872007-02-14 14:40:24 +0000156
Bertrik Sikken56337842008-04-19 23:29:39 +0000157static int cuesheet_callback(int action,const struct menu_item_ex *this_item)
Nicolas Pennequin9f4bd872007-02-14 14:40:24 +0000158{
159 (void)this_item;
160 switch (action)
161 {
162 case ACTION_EXIT_MENUITEM: /* on exit */
163 if (!cuesheet_is_enabled() && global_settings.cuesheet)
Nils Wallménius5b769362007-08-06 13:08:36 +0000164 gui_syncsplash(HZ*2, ID2P(LANG_PLEASE_REBOOT));
Nicolas Pennequin9f4bd872007-02-14 14:40:24 +0000165 break;
166 }
167 return action;
168}
169MENUITEM_SETTING(cuesheet, &global_settings.cuesheet, cuesheet_callback);
170
Jonathan Gordonfb628312007-02-12 14:22:35 +0000171#ifdef HAVE_HEADPHONE_DETECTION
172MENUITEM_SETTING(unplug_mode, &global_settings.unplug_mode, NULL);
173MENUITEM_SETTING(unplug_rw, &global_settings.unplug_rw, NULL);
174MENUITEM_SETTING(unplug_autoresume, &global_settings.unplug_autoresume, NULL);
Nils Wallméniusb3113672007-08-05 19:19:39 +0000175MAKE_MENU(unplug_menu, ID2P(LANG_HEADPHONE_UNPLUG), 0, Icon_NOICON,
Jonathan Gordonfb628312007-02-12 14:22:35 +0000176 &unplug_mode, &unplug_rw, &unplug_autoresume);
177#endif
178
Stéphane Doyonab0f7e12008-05-04 13:47:58 +0000179MENUITEM_SETTING(study_mode, &global_settings.study_mode, NULL);
180MENUITEM_SETTING(study_hop_step, &global_settings.study_hop_step, NULL);
181MAKE_MENU(study_mode_menu, ID2P(LANG_STUDY_MODE), 0, Icon_NOICON,
182 &study_mode, &study_hop_step);
183
Steve Bavin5f8bd632008-05-22 08:02:48 +0000184MAKE_MENU(playback_settings,ID2P(LANG_PLAYBACK),0,
Jonathan Gordon02a87172007-03-03 13:52:14 +0000185 Icon_Playback_menu,
Jonathan Gordon91cb68a2007-03-01 11:14:46 +0000186 &shuffle_item, &repeat_mode, &play_selected,
Nils Wallménius0bfa3e72007-08-01 08:50:44 +0000187 &ff_rewind_settings_menu,
188#ifndef HAVE_FLASH_STORAGE
189 &buffer_margin,
190#endif
191 &fade_on_stop, &party_mode,
Jonathan Gordonfb628312007-02-12 14:22:35 +0000192
193#if CONFIG_CODEC == SWCODEC
194 &crossfade_settings_menu, &replaygain_settings_menu, &beep,
195#endif
196
197#ifdef HAVE_SPDIF_POWER
198 &spdif_enable,
199#endif
Thom Johansen294ec1d2007-09-19 10:40:55 +0000200 &next_folder, &audioscrobbler, &cuesheet
Jonathan Gordonfb628312007-02-12 14:22:35 +0000201#ifdef HAVE_HEADPHONE_DETECTION
202 ,&unplug_menu
203#endif
Stéphane Doyonab0f7e12008-05-04 13:47:58 +0000204 ,&study_mode_menu
Jonathan Gordonfb628312007-02-12 14:22:35 +0000205 );
Jonathan Gordon1ebdd5b2007-02-17 14:39:02 +0000206
Bertrik Sikken56337842008-04-19 23:29:39 +0000207static int playback_callback(int action,const struct menu_item_ex *this_item)
Jonathan Gordonfb628312007-02-12 14:22:35 +0000208{
209 static bool old_shuffle = false;
210 static int old_repeat_mode = 0;
211 (void)this_item;
212 switch (action)
213 {
214 case ACTION_ENTER_MENUITEM:
Jonathan Gordonfb628312007-02-12 14:22:35 +0000215 if (this_item == &shuffle_item)
216 old_shuffle = global_settings.playlist_shuffle;
217 else if (this_item == &repeat_mode)
218 old_repeat_mode = global_settings.repeat_mode;
219 break;
220 case ACTION_EXIT_MENUITEM: /* on exit */
221 if ((this_item == &shuffle_item) &&
222 (old_shuffle != global_settings.playlist_shuffle)
223 && (audio_status() & AUDIO_STATUS_PLAY))
224 {
225#if CONFIG_CODEC == SWCODEC
Michael Sevakisd4e904b2007-02-24 17:06:36 +0000226 dsp_set_replaygain();
Jonathan Gordonfb628312007-02-12 14:22:35 +0000227#endif
228 if (global_settings.playlist_shuffle)
229 {
230 playlist_randomise(NULL, current_tick, true);
231 }
232 else
233 {
234 playlist_sort(NULL, true);
235 }
236 }
237 break;
238 }
239 return action;
240}
241/* PLAYBACK MENU */
242/***********************************/