Jonathan Gordon | fb62831 | 2007-02-12 14:22:35 +0000 | [diff] [blame] | 1 | /*************************************************************************** |
| 2 | * __________ __ ___. |
| 3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ |
| 4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / |
| 5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < |
| 6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ |
| 7 | * \/ \/ \/ \/ \/ |
Jonathan Gordon | 4e73b53 | 2007-02-13 00:32:17 +0000 | [diff] [blame] | 8 | * $Id$ |
Jonathan Gordon | fb62831 | 2007-02-12 14:22:35 +0000 | [diff] [blame] | 9 | * |
| 10 | * Copyright (C) 2007 Jonathan Gordon |
| 11 | * |
Daniel Stenberg | 2acc0ac | 2008-06-28 18:10:04 +0000 | [diff] [blame] | 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. |
Jonathan Gordon | fb62831 | 2007-02-12 14:22:35 +0000 | [diff] [blame] | 16 | * |
| 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 Johansen | 4a7e0c7 | 2008-07-14 20:39:30 +0000 | [diff] [blame] | 37 | #include "cuesheet.h" |
| 38 | #if CONFIG_CODEC == SWCODEC |
| 39 | #include "playback.h" |
| 40 | #endif |
Steve Bavin | c9df8fd | 2008-03-28 11:24:24 +0000 | [diff] [blame] | 41 | |
Jonathan Gordon | fb62831 | 2007-02-12 14:22:35 +0000 | [diff] [blame] | 42 | |
Jeffrey Goode | 9e09534 | 2009-11-10 03:46:08 +0000 | [diff] [blame] | 43 | #if (CONFIG_CODEC == SWCODEC) && defined(HAVE_CROSSFADE) |
Bertrik Sikken | 5633784 | 2008-04-19 23:29:39 +0000 | [diff] [blame] | 44 | static int setcrossfadeonexit_callback(int action,const struct menu_item_ex *this_item) |
Jonathan Gordon | fb62831 | 2007-02-12 14:22:35 +0000 | [diff] [blame] | 45 | { |
| 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 Sikken | 5633784 | 2008-04-19 23:29:39 +0000 | [diff] [blame] | 60 | static int playback_callback(int action,const struct menu_item_ex *this_item); |
Jonathan Gordon | fb62831 | 2007-02-12 14:22:35 +0000 | [diff] [blame] | 61 | |
| 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); |
Jonathan Gordon | fb62831 | 2007-02-12 14:22:35 +0000 | [diff] [blame] | 65 | |
| 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); |
Jonathan Gordon | 02a8717 | 2007-03-03 13:52:14 +0000 | [diff] [blame] | 68 | MAKE_MENU(ff_rewind_settings_menu, ID2P(LANG_WIND_MENU), 0, Icon_NOICON, |
Jonathan Gordon | fb62831 | 2007-02-12 14:22:35 +0000 | [diff] [blame] | 69 | &ff_rewind_min_step, &ff_rewind_accel); |
Frank Gevaerts | 4657301 | 2008-10-07 19:37:33 +0000 | [diff] [blame] | 70 | #ifdef HAVE_DISK_STORAGE |
Jonathan Gordon | fb62831 | 2007-02-12 14:22:35 +0000 | [diff] [blame] | 71 | #if CONFIG_CODEC == SWCODEC |
Bertrik Sikken | 5633784 | 2008-04-19 23:29:39 +0000 | [diff] [blame] | 72 | static int buffermargin_callback(int action,const struct menu_item_ex *this_item) |
Jonathan Gordon | fb62831 | 2007-02-12 14:22:35 +0000 | [diff] [blame] | 73 | { |
| 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 |
| 86 | MENUITEM_SETTING(buffer_margin, &global_settings.buffer_margin, |
| 87 | buffermargin_callback); |
Frank Gevaerts | 4657301 | 2008-10-07 19:37:33 +0000 | [diff] [blame] | 88 | #endif /*HAVE_DISK_STORAGE */ |
Jonathan Gordon | fb62831 | 2007-02-12 14:22:35 +0000 | [diff] [blame] | 89 | MENUITEM_SETTING(fade_on_stop, &global_settings.fade_on_stop, NULL); |
| 90 | MENUITEM_SETTING(party_mode, &global_settings.party_mode, NULL); |
| 91 | |
| 92 | #if CONFIG_CODEC == SWCODEC |
Jeffrey Goode | 9e09534 | 2009-11-10 03:46:08 +0000 | [diff] [blame] | 93 | #ifdef HAVE_CROSSFADE |
Jonathan Gordon | fb62831 | 2007-02-12 14:22:35 +0000 | [diff] [blame] | 94 | /* crossfade submenu */ |
| 95 | MENUITEM_SETTING(crossfade, &global_settings.crossfade, setcrossfadeonexit_callback); |
| 96 | MENUITEM_SETTING(crossfade_fade_in_delay, |
Jeffrey Goode | 9e09534 | 2009-11-10 03:46:08 +0000 | [diff] [blame] | 97 | &global_settings.crossfade_fade_in_delay, NULL); |
Jonathan Gordon | fb62831 | 2007-02-12 14:22:35 +0000 | [diff] [blame] | 98 | MENUITEM_SETTING(crossfade_fade_in_duration, |
Jeffrey Goode | 9e09534 | 2009-11-10 03:46:08 +0000 | [diff] [blame] | 99 | &global_settings.crossfade_fade_in_duration, NULL); |
Jonathan Gordon | fb62831 | 2007-02-12 14:22:35 +0000 | [diff] [blame] | 100 | MENUITEM_SETTING(crossfade_fade_out_delay, |
| 101 | &global_settings.crossfade_fade_out_delay, setcrossfadeonexit_callback); |
| 102 | MENUITEM_SETTING(crossfade_fade_out_duration, |
| 103 | &global_settings.crossfade_fade_out_duration, setcrossfadeonexit_callback); |
| 104 | MENUITEM_SETTING(crossfade_fade_out_mixmode, |
| 105 | &global_settings.crossfade_fade_out_mixmode,NULL); |
Jonathan Gordon | 02a8717 | 2007-03-03 13:52:14 +0000 | [diff] [blame] | 106 | MAKE_MENU(crossfade_settings_menu,ID2P(LANG_CROSSFADE),0, Icon_NOICON, |
Jonathan Gordon | fb62831 | 2007-02-12 14:22:35 +0000 | [diff] [blame] | 107 | &crossfade, &crossfade_fade_in_delay, &crossfade_fade_in_duration, |
| 108 | &crossfade_fade_out_delay, &crossfade_fade_out_duration, |
| 109 | &crossfade_fade_out_mixmode); |
Michael Giacomelli | 47a0901 | 2009-08-11 01:09:05 +0000 | [diff] [blame] | 110 | #endif |
Jonathan Gordon | fb62831 | 2007-02-12 14:22:35 +0000 | [diff] [blame] | 111 | |
| 112 | /* replay gain submenu */ |
| 113 | |
Bertrik Sikken | 5633784 | 2008-04-19 23:29:39 +0000 | [diff] [blame] | 114 | static int replaygain_callback(int action,const struct menu_item_ex *this_item) |
Jonathan Gordon | fb62831 | 2007-02-12 14:22:35 +0000 | [diff] [blame] | 115 | { |
| 116 | (void)this_item; |
| 117 | switch (action) |
| 118 | { |
Jonathan Gordon | 91cb68a | 2007-03-01 11:14:46 +0000 | [diff] [blame] | 119 | case ACTION_EXIT_MENUITEM: /* on exit */ |
Michael Sevakis | d4e904b | 2007-02-24 17:06:36 +0000 | [diff] [blame] | 120 | dsp_set_replaygain(); |
Jonathan Gordon | fb62831 | 2007-02-12 14:22:35 +0000 | [diff] [blame] | 121 | break; |
| 122 | } |
| 123 | return action; |
| 124 | } |
Jonathan Gordon | fb62831 | 2007-02-12 14:22:35 +0000 | [diff] [blame] | 125 | MENUITEM_SETTING(replaygain_noclip, &global_settings.replaygain_noclip ,replaygain_callback); |
| 126 | MENUITEM_SETTING(replaygain_type, &global_settings.replaygain_type ,replaygain_callback); |
| 127 | MENUITEM_SETTING(replaygain_preamp, &global_settings.replaygain_preamp ,replaygain_callback); |
Jonathan Gordon | 02a8717 | 2007-03-03 13:52:14 +0000 | [diff] [blame] | 128 | MAKE_MENU(replaygain_settings_menu,ID2P(LANG_REPLAYGAIN),0, Icon_NOICON, |
Alexander Levin | 8589fcb | 2009-06-20 21:13:24 +0000 | [diff] [blame] | 129 | &replaygain_type, &replaygain_noclip, &replaygain_preamp); |
Jonathan Gordon | fb62831 | 2007-02-12 14:22:35 +0000 | [diff] [blame] | 130 | |
| 131 | MENUITEM_SETTING(beep, &global_settings.beep ,NULL); |
| 132 | #endif /* CONFIG_CODEC == SWCODEC */ |
| 133 | |
| 134 | #ifdef HAVE_SPDIF_POWER |
| 135 | MENUITEM_SETTING(spdif_enable, &global_settings.spdif_enable, NULL); |
| 136 | #endif |
Jonathan Gordon | fb62831 | 2007-02-12 14:22:35 +0000 | [diff] [blame] | 137 | MENUITEM_SETTING(next_folder, &global_settings.next_folder, NULL); |
Bertrik Sikken | 5633784 | 2008-04-19 23:29:39 +0000 | [diff] [blame] | 138 | static int audioscrobbler_callback(int action,const struct menu_item_ex *this_item) |
Jonathan Gordon | fb62831 | 2007-02-12 14:22:35 +0000 | [diff] [blame] | 139 | { |
| 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énius | 01729e7 | 2008-08-15 08:27:39 +0000 | [diff] [blame] | 145 | splash(HZ*2, ID2P(LANG_PLEASE_REBOOT)); |
Jonathan Gordon | fb62831 | 2007-02-12 14:22:35 +0000 | [diff] [blame] | 146 | |
| 147 | if(scrobbler_is_enabled() && !global_settings.audioscrobbler) |
| 148 | scrobbler_shutdown(); |
| 149 | break; |
| 150 | } |
| 151 | return action; |
| 152 | } |
| 153 | MENUITEM_SETTING(audioscrobbler, &global_settings.audioscrobbler, audioscrobbler_callback); |
| 154 | |
Nicolas Pennequin | 9f4bd87 | 2007-02-14 14:40:24 +0000 | [diff] [blame] | 155 | |
Bertrik Sikken | 5633784 | 2008-04-19 23:29:39 +0000 | [diff] [blame] | 156 | static int cuesheet_callback(int action,const struct menu_item_ex *this_item) |
Nicolas Pennequin | 9f4bd87 | 2007-02-14 14:40:24 +0000 | [diff] [blame] | 157 | { |
| 158 | (void)this_item; |
| 159 | switch (action) |
| 160 | { |
| 161 | case ACTION_EXIT_MENUITEM: /* on exit */ |
Michael Sevakis | c537d59 | 2011-04-27 03:08:23 +0000 | [diff] [blame^] | 162 | #if CONFIG_CODEC == SWCODEC |
| 163 | audio_set_cuesheet(global_settings.cuesheet); |
| 164 | #else |
Jonathan Gordon | 24b136f | 2009-07-20 05:18:18 +0000 | [diff] [blame] | 165 | if (global_settings.cuesheet) |
Nils Wallménius | 01729e7 | 2008-08-15 08:27:39 +0000 | [diff] [blame] | 166 | splash(HZ*2, ID2P(LANG_PLEASE_REBOOT)); |
Nicolas Pennequin | 9f4bd87 | 2007-02-14 14:40:24 +0000 | [diff] [blame] | 167 | break; |
Michael Sevakis | c537d59 | 2011-04-27 03:08:23 +0000 | [diff] [blame^] | 168 | #endif |
Nicolas Pennequin | 9f4bd87 | 2007-02-14 14:40:24 +0000 | [diff] [blame] | 169 | } |
| 170 | return action; |
| 171 | } |
| 172 | MENUITEM_SETTING(cuesheet, &global_settings.cuesheet, cuesheet_callback); |
| 173 | |
Jonathan Gordon | fb62831 | 2007-02-12 14:22:35 +0000 | [diff] [blame] | 174 | #ifdef HAVE_HEADPHONE_DETECTION |
| 175 | MENUITEM_SETTING(unplug_mode, &global_settings.unplug_mode, NULL); |
| 176 | MENUITEM_SETTING(unplug_rw, &global_settings.unplug_rw, NULL); |
| 177 | MENUITEM_SETTING(unplug_autoresume, &global_settings.unplug_autoresume, NULL); |
Nils Wallménius | b311367 | 2007-08-05 19:19:39 +0000 | [diff] [blame] | 178 | MAKE_MENU(unplug_menu, ID2P(LANG_HEADPHONE_UNPLUG), 0, Icon_NOICON, |
Jonathan Gordon | fb62831 | 2007-02-12 14:22:35 +0000 | [diff] [blame] | 179 | &unplug_mode, &unplug_rw, &unplug_autoresume); |
| 180 | #endif |
| 181 | |
Thom Johansen | 4a7e0c7 | 2008-07-14 20:39:30 +0000 | [diff] [blame] | 182 | MENUITEM_SETTING(skip_length, &global_settings.skip_length, NULL); |
Thomas Martitz | 62f3e95 | 2009-03-27 13:53:29 +0000 | [diff] [blame] | 183 | MENUITEM_SETTING(prevent_skip, &global_settings.prevent_skip, NULL); |
Magnus Holmgren | 15be66a | 2010-04-24 14:19:04 +0000 | [diff] [blame] | 184 | #if CONFIG_CODEC == SWCODEC |
Magnus Holmgren | d38093d | 2010-04-24 14:10:28 +0000 | [diff] [blame] | 185 | MENUITEM_SETTING(resume_rewind, &global_settings.resume_rewind, NULL); |
Magnus Holmgren | 15be66a | 2010-04-24 14:19:04 +0000 | [diff] [blame] | 186 | #endif |
Stéphane Doyon | ab0f7e1 | 2008-05-04 13:47:58 +0000 | [diff] [blame] | 187 | |
Steve Bavin | 5f8bd63 | 2008-05-22 08:02:48 +0000 | [diff] [blame] | 188 | MAKE_MENU(playback_settings,ID2P(LANG_PLAYBACK),0, |
Jonathan Gordon | 02a8717 | 2007-03-03 13:52:14 +0000 | [diff] [blame] | 189 | Icon_Playback_menu, |
Jonathan Gordon | 91cb68a | 2007-03-01 11:14:46 +0000 | [diff] [blame] | 190 | &shuffle_item, &repeat_mode, &play_selected, |
Nils Wallménius | 0bfa3e7 | 2007-08-01 08:50:44 +0000 | [diff] [blame] | 191 | &ff_rewind_settings_menu, |
Frank Gevaerts | 4657301 | 2008-10-07 19:37:33 +0000 | [diff] [blame] | 192 | #ifdef HAVE_DISK_STORAGE |
Nils Wallménius | 0bfa3e7 | 2007-08-01 08:50:44 +0000 | [diff] [blame] | 193 | &buffer_margin, |
| 194 | #endif |
| 195 | &fade_on_stop, &party_mode, |
Jonathan Gordon | fb62831 | 2007-02-12 14:22:35 +0000 | [diff] [blame] | 196 | |
Jeffrey Goode | 9e09534 | 2009-11-10 03:46:08 +0000 | [diff] [blame] | 197 | #if (CONFIG_CODEC == SWCODEC) && defined(HAVE_CROSSFADE) |
Michael Giacomelli | 88906e3 | 2009-08-11 02:18:22 +0000 | [diff] [blame] | 198 | &crossfade_settings_menu, |
| 199 | #endif |
| 200 | |
| 201 | #if CONFIG_CODEC == SWCODEC |
| 202 | &replaygain_settings_menu, &beep, |
Jonathan Gordon | fb62831 | 2007-02-12 14:22:35 +0000 | [diff] [blame] | 203 | #endif |
| 204 | |
| 205 | #ifdef HAVE_SPDIF_POWER |
| 206 | &spdif_enable, |
| 207 | #endif |
Thom Johansen | 294ec1d | 2007-09-19 10:40:55 +0000 | [diff] [blame] | 208 | &next_folder, &audioscrobbler, &cuesheet |
Jonathan Gordon | fb62831 | 2007-02-12 14:22:35 +0000 | [diff] [blame] | 209 | #ifdef HAVE_HEADPHONE_DETECTION |
| 210 | ,&unplug_menu |
| 211 | #endif |
Thomas Martitz | 62f3e95 | 2009-03-27 13:53:29 +0000 | [diff] [blame] | 212 | ,&skip_length, &prevent_skip, |
Magnus Holmgren | d38093d | 2010-04-24 14:10:28 +0000 | [diff] [blame] | 213 | |
| 214 | #if CONFIG_CODEC == SWCODEC |
| 215 | &resume_rewind, |
| 216 | #endif |
Jonathan Gordon | fb62831 | 2007-02-12 14:22:35 +0000 | [diff] [blame] | 217 | ); |
Jonathan Gordon | 1ebdd5b | 2007-02-17 14:39:02 +0000 | [diff] [blame] | 218 | |
Bertrik Sikken | 5633784 | 2008-04-19 23:29:39 +0000 | [diff] [blame] | 219 | static int playback_callback(int action,const struct menu_item_ex *this_item) |
Jonathan Gordon | fb62831 | 2007-02-12 14:22:35 +0000 | [diff] [blame] | 220 | { |
| 221 | static bool old_shuffle = false; |
Jonathan Gordon | fb62831 | 2007-02-12 14:22:35 +0000 | [diff] [blame] | 222 | switch (action) |
| 223 | { |
| 224 | case ACTION_ENTER_MENUITEM: |
Jonathan Gordon | fb62831 | 2007-02-12 14:22:35 +0000 | [diff] [blame] | 225 | if (this_item == &shuffle_item) |
| 226 | old_shuffle = global_settings.playlist_shuffle; |
Jonathan Gordon | fb62831 | 2007-02-12 14:22:35 +0000 | [diff] [blame] | 227 | break; |
| 228 | case ACTION_EXIT_MENUITEM: /* on exit */ |
| 229 | if ((this_item == &shuffle_item) && |
| 230 | (old_shuffle != global_settings.playlist_shuffle) |
| 231 | && (audio_status() & AUDIO_STATUS_PLAY)) |
| 232 | { |
| 233 | #if CONFIG_CODEC == SWCODEC |
Michael Sevakis | d4e904b | 2007-02-24 17:06:36 +0000 | [diff] [blame] | 234 | dsp_set_replaygain(); |
Jonathan Gordon | fb62831 | 2007-02-12 14:22:35 +0000 | [diff] [blame] | 235 | #endif |
| 236 | if (global_settings.playlist_shuffle) |
| 237 | { |
| 238 | playlist_randomise(NULL, current_tick, true); |
| 239 | } |
| 240 | else |
| 241 | { |
| 242 | playlist_sort(NULL, true); |
| 243 | } |
| 244 | } |
| 245 | break; |
| 246 | } |
| 247 | return action; |
| 248 | } |
| 249 | /* PLAYBACK MENU */ |
| 250 | /***********************************/ |