1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2007 Jonathan Gordon
12 * 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.
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
20 ****************************************************************************/
31 #include "sound_menu.h"
35 #include "scrobbler.h"
38 #if CONFIG_CODEC == SWCODEC
43 #if CONFIG_CODEC == SWCODEC
44 static int setcrossfadeonexit_callback(int action
,const struct menu_item_ex
*this_item
)
49 case ACTION_EXIT_MENUITEM
: /* on exit */
50 audio_set_crossfade(global_settings
.crossfade
);
56 #endif /* CONFIG_CODEC == SWCODEC */
58 /***********************************/
60 static int playback_callback(int action
,const struct menu_item_ex
*this_item
);
62 MENUITEM_SETTING(shuffle_item
, &global_settings
.playlist_shuffle
, playback_callback
);
63 MENUITEM_SETTING(repeat_mode
, &global_settings
.repeat_mode
, playback_callback
);
64 MENUITEM_SETTING(play_selected
, &global_settings
.play_selected
, NULL
);
66 MENUITEM_SETTING(ff_rewind_accel
, &global_settings
.ff_rewind_accel
, NULL
);
67 MENUITEM_SETTING(ff_rewind_min_step
, &global_settings
.ff_rewind_min_step
, NULL
);
68 MAKE_MENU(ff_rewind_settings_menu
, ID2P(LANG_WIND_MENU
), 0, Icon_NOICON
,
69 &ff_rewind_min_step
, &ff_rewind_accel
);
70 #ifdef HAVE_DISK_STORAGE
71 #if CONFIG_CODEC == SWCODEC
72 static int buffermargin_callback(int action
,const struct menu_item_ex
*this_item
)
77 case ACTION_EXIT_MENUITEM
: /* on exit */
78 audio_set_buffer_margin(global_settings
.buffer_margin
);
84 # define buffermargin_callback NULL
86 MENUITEM_SETTING(buffer_margin
, &global_settings
.buffer_margin
,
87 buffermargin_callback
);
88 #endif /*HAVE_DISK_STORAGE */
89 MENUITEM_SETTING(fade_on_stop
, &global_settings
.fade_on_stop
, NULL
);
90 MENUITEM_SETTING(party_mode
, &global_settings
.party_mode
, NULL
);
92 #if CONFIG_CODEC == SWCODEC
93 /* crossfade submenu */
94 MENUITEM_SETTING(crossfade
, &global_settings
.crossfade
, setcrossfadeonexit_callback
);
95 MENUITEM_SETTING(crossfade_fade_in_delay
,
96 &global_settings
.crossfade_fade_in_delay
, setcrossfadeonexit_callback
);
97 MENUITEM_SETTING(crossfade_fade_in_duration
,
98 &global_settings
.crossfade_fade_in_duration
, setcrossfadeonexit_callback
);
99 MENUITEM_SETTING(crossfade_fade_out_delay
,
100 &global_settings
.crossfade_fade_out_delay
, setcrossfadeonexit_callback
);
101 MENUITEM_SETTING(crossfade_fade_out_duration
,
102 &global_settings
.crossfade_fade_out_duration
, setcrossfadeonexit_callback
);
103 MENUITEM_SETTING(crossfade_fade_out_mixmode
,
104 &global_settings
.crossfade_fade_out_mixmode
,NULL
);
105 MAKE_MENU(crossfade_settings_menu
,ID2P(LANG_CROSSFADE
),0, Icon_NOICON
,
106 &crossfade
, &crossfade_fade_in_delay
, &crossfade_fade_in_duration
,
107 &crossfade_fade_out_delay
, &crossfade_fade_out_duration
,
108 &crossfade_fade_out_mixmode
);
110 /* replay gain submenu */
112 static int replaygain_callback(int action
,const struct menu_item_ex
*this_item
)
117 case ACTION_EXIT_MENUITEM
: /* on exit */
118 dsp_set_replaygain();
123 MENUITEM_SETTING(replaygain
, &global_settings
.replaygain
,replaygain_callback
);
124 MENUITEM_SETTING(replaygain_noclip
, &global_settings
.replaygain_noclip
,replaygain_callback
);
125 MENUITEM_SETTING(replaygain_type
, &global_settings
.replaygain_type
,replaygain_callback
);
126 MENUITEM_SETTING(replaygain_preamp
, &global_settings
.replaygain_preamp
,replaygain_callback
);
127 MAKE_MENU(replaygain_settings_menu
,ID2P(LANG_REPLAYGAIN
),0, Icon_NOICON
,
128 &replaygain
,&replaygain_noclip
,
129 &replaygain_type
,&replaygain_preamp
);
131 MENUITEM_SETTING(beep
, &global_settings
.beep
,NULL
);
132 #endif /* CONFIG_CODEC == SWCODEC */
134 #ifdef HAVE_SPDIF_POWER
135 MENUITEM_SETTING(spdif_enable
, &global_settings
.spdif_enable
, NULL
);
137 MENUITEM_SETTING(next_folder
, &global_settings
.next_folder
, NULL
);
138 static int audioscrobbler_callback(int action
,const struct menu_item_ex
*this_item
)
143 case ACTION_EXIT_MENUITEM
: /* on exit */
144 if (!scrobbler_is_enabled() && global_settings
.audioscrobbler
)
145 splash(HZ
*2, ID2P(LANG_PLEASE_REBOOT
));
147 if(scrobbler_is_enabled() && !global_settings
.audioscrobbler
)
148 scrobbler_shutdown();
153 MENUITEM_SETTING(audioscrobbler
, &global_settings
.audioscrobbler
, audioscrobbler_callback
);
156 static int cuesheet_callback(int action
,const struct menu_item_ex
*this_item
)
161 case ACTION_EXIT_MENUITEM
: /* on exit */
162 if (!cuesheet_is_enabled() && global_settings
.cuesheet
)
163 splash(HZ
*2, ID2P(LANG_PLEASE_REBOOT
));
168 MENUITEM_SETTING(cuesheet
, &global_settings
.cuesheet
, cuesheet_callback
);
170 #ifdef HAVE_HEADPHONE_DETECTION
171 MENUITEM_SETTING(unplug_mode
, &global_settings
.unplug_mode
, NULL
);
172 MENUITEM_SETTING(unplug_rw
, &global_settings
.unplug_rw
, NULL
);
173 MENUITEM_SETTING(unplug_autoresume
, &global_settings
.unplug_autoresume
, NULL
);
174 MAKE_MENU(unplug_menu
, ID2P(LANG_HEADPHONE_UNPLUG
), 0, Icon_NOICON
,
175 &unplug_mode
, &unplug_rw
, &unplug_autoresume
);
178 MENUITEM_SETTING(skip_length
, &global_settings
.skip_length
, NULL
);
180 MAKE_MENU(playback_settings
,ID2P(LANG_PLAYBACK
),0,
182 &shuffle_item
, &repeat_mode
, &play_selected
,
183 &ff_rewind_settings_menu
,
184 #ifdef HAVE_DISK_STORAGE
187 &fade_on_stop
, &party_mode
,
189 #if CONFIG_CODEC == SWCODEC
190 &crossfade_settings_menu
, &replaygain_settings_menu
, &beep
,
193 #ifdef HAVE_SPDIF_POWER
196 &next_folder
, &audioscrobbler
, &cuesheet
197 #ifdef HAVE_HEADPHONE_DETECTION
203 static int playback_callback(int action
,const struct menu_item_ex
*this_item
)
205 static bool old_shuffle
= false;
206 static int old_repeat_mode
= 0;
210 case ACTION_ENTER_MENUITEM
:
211 if (this_item
== &shuffle_item
)
212 old_shuffle
= global_settings
.playlist_shuffle
;
213 else if (this_item
== &repeat_mode
)
214 old_repeat_mode
= global_settings
.repeat_mode
;
216 case ACTION_EXIT_MENUITEM
: /* on exit */
217 if ((this_item
== &shuffle_item
) &&
218 (old_shuffle
!= global_settings
.playlist_shuffle
)
219 && (audio_status() & AUDIO_STATUS_PLAY
))
221 #if CONFIG_CODEC == SWCODEC
222 dsp_set_replaygain();
224 if (global_settings
.playlist_shuffle
)
226 playlist_randomise(NULL
, current_tick
, true);
230 playlist_sort(NULL
, true);
238 /***********************************/