summaryrefslogtreecommitdiff
path: root/apps/menus/playback_menu.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/menus/playback_menu.c')
-rw-r--r--apps/menus/playback_menu.c209
1 files changed, 209 insertions, 0 deletions
diff --git a/apps/menus/playback_menu.c b/apps/menus/playback_menu.c
new file mode 100644
index 0000000000..63a95b28ce
--- /dev/null
+++ b/apps/menus/playback_menu.c
@@ -0,0 +1,209 @@
1
2/***************************************************************************
3 * __________ __ ___.
4 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
5 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
6 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
7 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
8 * \/ \/ \/ \/ \/
9 * $Id: $
10 *
11 * Copyright (C) 2007 Jonathan Gordon
12 *
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.
15 *
16 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
17 * KIND, either express or implied.
18 *
19 ****************************************************************************/
20
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
37#if CONFIG_CODEC == SWCODEC
38int setcrossfadeonexit_callback(int action,const struct menu_item_ex *this_item)
39{
40 (void)this_item;
41 switch (action)
42 {
43 case ACTION_EXIT_MENUITEM: /* on exit */
44 audio_set_crossfade(global_settings.crossfade);
45 break;
46 }
47 return action;
48}
49
50#endif /* CONFIG_CODEC == SWCODEC */
51
52/***********************************/
53/* PLAYBACK MENU */
54int playback_callback(int action,const struct menu_item_ex *this_item);
55
56MENUITEM_SETTING(shuffle_item, &global_settings.playlist_shuffle, playback_callback);
57MENUITEM_SETTING(repeat_mode, &global_settings.repeat_mode, playback_callback);
58MENUITEM_SETTING(play_selected, &global_settings.play_selected, NULL);
59MENUITEM_SETTING(resume, &global_settings.resume, NULL);
60
61MENUITEM_SETTING(ff_rewind_accel, &global_settings.ff_rewind_accel, NULL);
62MENUITEM_SETTING(ff_rewind_min_step, &global_settings.ff_rewind_min_step, NULL);
63MAKE_MENU(ff_rewind_settings_menu, ID2P(LANG_WIND_MENU), 0,
64 &ff_rewind_min_step, &ff_rewind_accel);
65#if CONFIG_CODEC == SWCODEC
66int buffermargin_callback(int action,const struct menu_item_ex *this_item)
67{
68 (void)this_item;
69 switch (action)
70 {
71 case ACTION_EXIT_MENUITEM: /* on exit */
72 audio_set_buffer_margin(global_settings.buffer_margin);
73 break;
74 }
75 return action;
76}
77#else
78# define buffermargin_callback NULL
79#endif
80MENUITEM_SETTING(buffer_margin, &global_settings.buffer_margin,
81 buffermargin_callback);
82MENUITEM_SETTING(fade_on_stop, &global_settings.fade_on_stop, NULL);
83MENUITEM_SETTING(party_mode, &global_settings.party_mode, NULL);
84
85#if CONFIG_CODEC == SWCODEC
86/* crossfade submenu */
87MENUITEM_SETTING(crossfade, &global_settings.crossfade, setcrossfadeonexit_callback);
88MENUITEM_SETTING(crossfade_fade_in_delay,
89 &global_settings.crossfade_fade_in_delay, setcrossfadeonexit_callback);
90MENUITEM_SETTING(crossfade_fade_in_duration,
91 &global_settings.crossfade_fade_in_duration, setcrossfadeonexit_callback);
92MENUITEM_SETTING(crossfade_fade_out_delay,
93 &global_settings.crossfade_fade_out_delay, setcrossfadeonexit_callback);
94MENUITEM_SETTING(crossfade_fade_out_duration,
95 &global_settings.crossfade_fade_out_duration, setcrossfadeonexit_callback);
96MENUITEM_SETTING(crossfade_fade_out_mixmode,
97 &global_settings.crossfade_fade_out_mixmode,NULL);
98MAKE_MENU(crossfade_settings_menu,ID2P(LANG_CROSSFADE),0,
99 &crossfade, &crossfade_fade_in_delay, &crossfade_fade_in_duration,
100 &crossfade_fade_out_delay, &crossfade_fade_out_duration,
101 &crossfade_fade_out_mixmode);
102
103/* replay gain submenu */
104
105int replaygain_callback(int action,const struct menu_item_ex *this_item)
106{
107 (void)this_item;
108 switch (action)
109 {
110 case ACTION_EXIT_MENUITEM: /* on exit */
111 dsp_set_replaygain(true);
112 break;
113 }
114 return action;
115}
116MENUITEM_SETTING(replaygain, &global_settings.replaygain ,replaygain_callback);
117MENUITEM_SETTING(replaygain_noclip, &global_settings.replaygain_noclip ,replaygain_callback);
118MENUITEM_SETTING(replaygain_type, &global_settings.replaygain_type ,replaygain_callback);
119MENUITEM_SETTING(replaygain_preamp, &global_settings.replaygain_preamp ,replaygain_callback);
120MAKE_MENU(replaygain_settings_menu,ID2P(LANG_REPLAYGAIN),0,
121 &replaygain,&replaygain_noclip,
122 &replaygain_type,&replaygain_preamp);
123
124MENUITEM_SETTING(beep, &global_settings.beep ,NULL);
125#endif /* CONFIG_CODEC == SWCODEC */
126
127#ifdef HAVE_SPDIF_POWER
128MENUITEM_SETTING(spdif_enable, &global_settings.spdif_enable, NULL);
129#endif
130MENUITEM_SETTING(id3_v1_first, &global_settings.id3_v1_first, NULL);
131MENUITEM_SETTING(next_folder, &global_settings.next_folder, NULL);
132int audioscrobbler_callback(int action,const struct menu_item_ex *this_item)
133{
134 (void)this_item;
135 switch (action)
136 {
137 case ACTION_EXIT_MENUITEM: /* on exit */
138 if (!scrobbler_is_enabled() && global_settings.audioscrobbler)
139 gui_syncsplash(HZ*2, true, str(LANG_PLEASE_REBOOT));
140
141 if(scrobbler_is_enabled() && !global_settings.audioscrobbler)
142 scrobbler_shutdown();
143 break;
144 }
145 return action;
146}
147MENUITEM_SETTING(audioscrobbler, &global_settings.audioscrobbler, audioscrobbler_callback);
148
149#ifdef HAVE_HEADPHONE_DETECTION
150MENUITEM_SETTING(unplug_mode, &global_settings.unplug_mode, NULL);
151MENUITEM_SETTING(unplug_rw, &global_settings.unplug_rw, NULL);
152MENUITEM_SETTING(unplug_autoresume, &global_settings.unplug_autoresume, NULL);
153MAKE_MENU(unplug_menu, ID2P(LANG_UNPLUG), 0,
154 &unplug_mode, &unplug_rw, &unplug_autoresume);
155#endif
156
157MAKE_MENU(playback_menu_item,ID2P(LANG_PLAYBACK),0,
158 &shuffle_item, &repeat_mode, &play_selected, &resume,
159 &ff_rewind_settings_menu,
160 &buffer_margin, &fade_on_stop, &party_mode,
161
162#if CONFIG_CODEC == SWCODEC
163 &crossfade_settings_menu, &replaygain_settings_menu, &beep,
164#endif
165
166#ifdef HAVE_SPDIF_POWER
167 &spdif_enable,
168#endif
169 &id3_v1_first, &next_folder, &audioscrobbler
170#ifdef HAVE_HEADPHONE_DETECTION
171 ,&unplug_menu
172#endif
173 );
174int playback_callback(int action,const struct menu_item_ex *this_item)
175{
176 static bool old_shuffle = false;
177 static int old_repeat_mode = 0;
178 (void)this_item;
179 switch (action)
180 {
181 case ACTION_ENTER_MENUITEM:
182 if (this_item == &shuffle_item)
183 old_shuffle = global_settings.playlist_shuffle;
184 else if (this_item == &repeat_mode)
185 old_repeat_mode = global_settings.repeat_mode;
186 break;
187 case ACTION_EXIT_MENUITEM: /* on exit */
188 if ((this_item == &shuffle_item) &&
189 (old_shuffle != global_settings.playlist_shuffle)
190 && (audio_status() & AUDIO_STATUS_PLAY))
191 {
192#if CONFIG_CODEC == SWCODEC
193 dsp_set_replaygain(true);
194#endif
195 if (global_settings.playlist_shuffle)
196 {
197 playlist_randomise(NULL, current_tick, true);
198 }
199 else
200 {
201 playlist_sort(NULL, true);
202 }
203 }
204 break;
205 }
206 return action;
207}
208/* PLAYBACK MENU */
209/***********************************/