Jonathan Gordon | fb62831 | 2007-02-12 14:22:35 +0000 | [diff] [blame] | 1 | |
| 2 | /*************************************************************************** |
| 3 | * __________ __ ___. |
| 4 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ |
| 5 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / |
| 6 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < |
| 7 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ |
| 8 | * \/ \/ \/ \/ \/ |
Jonathan Gordon | 4e73b53 | 2007-02-13 00:32:17 +0000 | [diff] [blame] | 9 | * $Id$ |
Jonathan Gordon | fb62831 | 2007-02-12 14:22:35 +0000 | [diff] [blame] | 10 | * |
| 11 | * Copyright (C) 2007 Jonathan Gordon |
| 12 | * |
Daniel Stenberg | 2acc0ac | 2008-06-28 18:10:04 +0000 | [diff] [blame^] | 13 | * 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 Gordon | fb62831 | 2007-02-12 14:22:35 +0000 | [diff] [blame] | 17 | * |
| 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 Bavin | c9df8fd | 2008-03-28 11:24:24 +0000 | [diff] [blame] | 38 | #include "cuesheet.h"
|
| 39 | #if CONFIG_CODEC == SWCODEC
|
| 40 | #include "playback.h"
|
| 41 | #endif
|
| 42 | |
Jonathan Gordon | fb62831 | 2007-02-12 14:22:35 +0000 | [diff] [blame] | 43 | |
| 44 | #if CONFIG_CODEC == SWCODEC |
Bertrik Sikken | 5633784 | 2008-04-19 23:29:39 +0000 | [diff] [blame] | 45 | 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] | 46 | { |
| 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 Sikken | 5633784 | 2008-04-19 23:29:39 +0000 | [diff] [blame] | 61 | 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] | 62 | |
| 63 | MENUITEM_SETTING(shuffle_item, &global_settings.playlist_shuffle, playback_callback); |
| 64 | MENUITEM_SETTING(repeat_mode, &global_settings.repeat_mode, playback_callback); |
| 65 | MENUITEM_SETTING(play_selected, &global_settings.play_selected, NULL); |
Jonathan Gordon | fb62831 | 2007-02-12 14:22:35 +0000 | [diff] [blame] | 66 | |
| 67 | MENUITEM_SETTING(ff_rewind_accel, &global_settings.ff_rewind_accel, NULL); |
| 68 | 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] | 69 | 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] | 70 | &ff_rewind_min_step, &ff_rewind_accel); |
Nils Wallménius | 0bfa3e7 | 2007-08-01 08:50:44 +0000 | [diff] [blame] | 71 | #ifndef HAVE_FLASH_STORAGE |
Jonathan Gordon | fb62831 | 2007-02-12 14:22:35 +0000 | [diff] [blame] | 72 | #if CONFIG_CODEC == SWCODEC |
Bertrik Sikken | 5633784 | 2008-04-19 23:29:39 +0000 | [diff] [blame] | 73 | 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] | 74 | { |
| 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 |
| 87 | MENUITEM_SETTING(buffer_margin, &global_settings.buffer_margin, |
| 88 | buffermargin_callback); |
Nils Wallménius | 0bfa3e7 | 2007-08-01 08:50:44 +0000 | [diff] [blame] | 89 | #endif /*HAVE_FLASH_STORAGE */ |
Jonathan Gordon | fb62831 | 2007-02-12 14:22:35 +0000 | [diff] [blame] | 90 | MENUITEM_SETTING(fade_on_stop, &global_settings.fade_on_stop, NULL); |
| 91 | MENUITEM_SETTING(party_mode, &global_settings.party_mode, NULL); |
| 92 | |
| 93 | #if CONFIG_CODEC == SWCODEC |
| 94 | /* crossfade submenu */ |
| 95 | MENUITEM_SETTING(crossfade, &global_settings.crossfade, setcrossfadeonexit_callback); |
| 96 | MENUITEM_SETTING(crossfade_fade_in_delay, |
| 97 | &global_settings.crossfade_fade_in_delay, setcrossfadeonexit_callback); |
| 98 | MENUITEM_SETTING(crossfade_fade_in_duration, |
| 99 | &global_settings.crossfade_fade_in_duration, setcrossfadeonexit_callback); |
| 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); |
| 110 | |
| 111 | /* replay gain submenu */ |
| 112 | |
Bertrik Sikken | 5633784 | 2008-04-19 23:29:39 +0000 | [diff] [blame] | 113 | 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] | 114 | { |
| 115 | (void)this_item; |
| 116 | switch (action) |
| 117 | { |
Jonathan Gordon | 91cb68a | 2007-03-01 11:14:46 +0000 | [diff] [blame] | 118 | case ACTION_EXIT_MENUITEM: /* on exit */ |
Michael Sevakis | d4e904b | 2007-02-24 17:06:36 +0000 | [diff] [blame] | 119 | dsp_set_replaygain(); |
Jonathan Gordon | fb62831 | 2007-02-12 14:22:35 +0000 | [diff] [blame] | 120 | break; |
| 121 | } |
| 122 | return action; |
| 123 | } |
| 124 | MENUITEM_SETTING(replaygain, &global_settings.replaygain ,replaygain_callback); |
| 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, |
Jonathan Gordon | fb62831 | 2007-02-12 14:22:35 +0000 | [diff] [blame] | 129 | &replaygain,&replaygain_noclip, |
| 130 | &replaygain_type,&replaygain_preamp); |
| 131 | |
| 132 | MENUITEM_SETTING(beep, &global_settings.beep ,NULL); |
| 133 | #endif /* CONFIG_CODEC == SWCODEC */ |
| 134 | |
| 135 | #ifdef HAVE_SPDIF_POWER |
| 136 | MENUITEM_SETTING(spdif_enable, &global_settings.spdif_enable, NULL); |
| 137 | #endif |
Jonathan Gordon | fb62831 | 2007-02-12 14:22:35 +0000 | [diff] [blame] | 138 | MENUITEM_SETTING(next_folder, &global_settings.next_folder, NULL); |
Bertrik Sikken | 5633784 | 2008-04-19 23:29:39 +0000 | [diff] [blame] | 139 | 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] | 140 | { |
| 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énius | 5b76936 | 2007-08-06 13:08:36 +0000 | [diff] [blame] | 146 | gui_syncsplash(HZ*2, ID2P(LANG_PLEASE_REBOOT)); |
Jonathan Gordon | fb62831 | 2007-02-12 14:22:35 +0000 | [diff] [blame] | 147 | |
| 148 | if(scrobbler_is_enabled() && !global_settings.audioscrobbler) |
| 149 | scrobbler_shutdown(); |
| 150 | break; |
| 151 | } |
| 152 | return action; |
| 153 | } |
| 154 | MENUITEM_SETTING(audioscrobbler, &global_settings.audioscrobbler, audioscrobbler_callback); |
| 155 | |
Nicolas Pennequin | 9f4bd87 | 2007-02-14 14:40:24 +0000 | [diff] [blame] | 156 | |
Bertrik Sikken | 5633784 | 2008-04-19 23:29:39 +0000 | [diff] [blame] | 157 | 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] | 158 | { |
| 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énius | 5b76936 | 2007-08-06 13:08:36 +0000 | [diff] [blame] | 164 | gui_syncsplash(HZ*2, ID2P(LANG_PLEASE_REBOOT)); |
Nicolas Pennequin | 9f4bd87 | 2007-02-14 14:40:24 +0000 | [diff] [blame] | 165 | break; |
| 166 | } |
| 167 | return action; |
| 168 | } |
| 169 | MENUITEM_SETTING(cuesheet, &global_settings.cuesheet, cuesheet_callback); |
| 170 | |
Jonathan Gordon | fb62831 | 2007-02-12 14:22:35 +0000 | [diff] [blame] | 171 | #ifdef HAVE_HEADPHONE_DETECTION |
| 172 | MENUITEM_SETTING(unplug_mode, &global_settings.unplug_mode, NULL); |
| 173 | MENUITEM_SETTING(unplug_rw, &global_settings.unplug_rw, NULL); |
| 174 | MENUITEM_SETTING(unplug_autoresume, &global_settings.unplug_autoresume, NULL); |
Nils Wallménius | b311367 | 2007-08-05 19:19:39 +0000 | [diff] [blame] | 175 | MAKE_MENU(unplug_menu, ID2P(LANG_HEADPHONE_UNPLUG), 0, Icon_NOICON, |
Jonathan Gordon | fb62831 | 2007-02-12 14:22:35 +0000 | [diff] [blame] | 176 | &unplug_mode, &unplug_rw, &unplug_autoresume); |
| 177 | #endif |
| 178 | |
Stéphane Doyon | ab0f7e1 | 2008-05-04 13:47:58 +0000 | [diff] [blame] | 179 | MENUITEM_SETTING(study_mode, &global_settings.study_mode, NULL); |
| 180 | MENUITEM_SETTING(study_hop_step, &global_settings.study_hop_step, NULL); |
| 181 | MAKE_MENU(study_mode_menu, ID2P(LANG_STUDY_MODE), 0, Icon_NOICON, |
| 182 | &study_mode, &study_hop_step); |
| 183 | |
Steve Bavin | 5f8bd63 | 2008-05-22 08:02:48 +0000 | [diff] [blame] | 184 | MAKE_MENU(playback_settings,ID2P(LANG_PLAYBACK),0, |
Jonathan Gordon | 02a8717 | 2007-03-03 13:52:14 +0000 | [diff] [blame] | 185 | Icon_Playback_menu, |
Jonathan Gordon | 91cb68a | 2007-03-01 11:14:46 +0000 | [diff] [blame] | 186 | &shuffle_item, &repeat_mode, &play_selected, |
Nils Wallménius | 0bfa3e7 | 2007-08-01 08:50:44 +0000 | [diff] [blame] | 187 | &ff_rewind_settings_menu, |
| 188 | #ifndef HAVE_FLASH_STORAGE |
| 189 | &buffer_margin, |
| 190 | #endif |
| 191 | &fade_on_stop, &party_mode, |
Jonathan Gordon | fb62831 | 2007-02-12 14:22:35 +0000 | [diff] [blame] | 192 | |
| 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 Johansen | 294ec1d | 2007-09-19 10:40:55 +0000 | [diff] [blame] | 200 | &next_folder, &audioscrobbler, &cuesheet |
Jonathan Gordon | fb62831 | 2007-02-12 14:22:35 +0000 | [diff] [blame] | 201 | #ifdef HAVE_HEADPHONE_DETECTION |
| 202 | ,&unplug_menu |
| 203 | #endif |
Stéphane Doyon | ab0f7e1 | 2008-05-04 13:47:58 +0000 | [diff] [blame] | 204 | ,&study_mode_menu |
Jonathan Gordon | fb62831 | 2007-02-12 14:22:35 +0000 | [diff] [blame] | 205 | ); |
Jonathan Gordon | 1ebdd5b | 2007-02-17 14:39:02 +0000 | [diff] [blame] | 206 | |
Bertrik Sikken | 5633784 | 2008-04-19 23:29:39 +0000 | [diff] [blame] | 207 | 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] | 208 | { |
| 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 Gordon | fb62831 | 2007-02-12 14:22:35 +0000 | [diff] [blame] | 215 | 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 Sevakis | d4e904b | 2007-02-24 17:06:36 +0000 | [diff] [blame] | 226 | dsp_set_replaygain(); |
Jonathan Gordon | fb62831 | 2007-02-12 14:22:35 +0000 | [diff] [blame] | 227 | #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 | /***********************************/ |