diff --git a/apps/SOURCES b/apps/SOURCES index 364faa3205..39b68ce6a6 100644 --- a/apps/SOURCES +++ b/apps/SOURCES @@ -16,6 +16,9 @@ menus/menu_common.c menus/display_menu.c menus/theme_menu.c menus/plugin_menu.c +#if CONFIG_TUNER +menus/radio_menu.c +#endif #if CONFIG_CODEC == SWCODEC #ifdef HAVE_WM8978 menus/audiohw_eq_menu.c diff --git a/apps/menus/exported_menus.h b/apps/menus/exported_menus.h index 3d253e7dd9..568791b1f0 100644 --- a/apps/menus/exported_menus.h +++ b/apps/menus/exported_menus.h @@ -30,17 +30,20 @@ extern const struct menu_item_ex playback_settings, /* playback_menu.c */ #ifdef HAVE_RECORDING recording_settings, /* recording_menu.c */ + recording_settings_menu, #ifdef HAVE_LCD_BITMAP peak_meter_menu, /* also used from within recording_menu */ #endif #endif sound_settings, /* sound_menu.c */ settings_menu_item, /* settings_menu.c */ + bookmark_settings_menu, playlist_settings, /* playlist_menu.c */ equalizer_menu, /* eq_menu.c */ #ifdef AUDIOHW_HAVE_EQ audiohw_eq_tone_controls, /* audiohw_eq_menu.c */ #endif + radio_settings_menu, /* radio_menu.c */ theme_menu; /* theme_menu.c */ struct browse_folder_info { diff --git a/apps/menus/radio_menu.c b/apps/menus/radio_menu.c new file mode 100644 index 0000000000..2a15fe8ee5 --- /dev/null +++ b/apps/menus/radio_menu.c @@ -0,0 +1,145 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2003 Linus Nielsen Feltzing + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + +#include +#include "config.h" +#include "menu.h" +#include "icon.h" +#include "radio.h" +#include "lang.h" +#include "settings.h" +#include "presets.h" +#include "exported_menus.h" +#include "recording.h" /* recording_screen() */ +#include "sound_menu.h" /* recording_menu() */ + + +#if defined(HAVE_FMRADIO_REC) && CONFIG_CODEC == SWCODEC +#define FM_RECORDING_SCREEN +static int fm_recording_screen(void) +{ + bool ret; + + /* switch recording source to FMRADIO for the duration */ + int rec_source = global_settings.rec_source; + global_settings.rec_source = AUDIO_SRC_FMRADIO; + ret = recording_screen(true); + + /* safe to reset as changing sources is prohibited here */ + global_settings.rec_source = rec_source; + + return ret; +} + +MENUITEM_FUNCTION(recscreen_item, 0, ID2P(LANG_RECORDING), + fm_recording_screen, NULL, NULL, Icon_Recording); +#endif /* defined(HAVE_FMRADIO_REC) && CONFIG_CODEC == SWCODEC */ + +#if defined(HAVE_FMRADIO_REC) || CONFIG_CODEC != SWCODEC +#define FM_RECORDING_SETTINGS +static int fm_recording_settings(void) +{ + bool ret = recording_menu(true); + +#if CONFIG_CODEC != SWCODEC + if (!ret) + { + struct audio_recording_options rec_options; + rec_init_recording_options(&rec_options); + rec_options.rec_source = AUDIO_SRC_LINEIN; + rec_set_recording_options(&rec_options); + } +#endif + + return ret; +} + +MENUITEM_FUNCTION(recsettings_item, 0, ID2P(LANG_RECORDING_SETTINGS), + fm_recording_settings, NULL, NULL, Icon_Recording); +#endif /* defined(HAVE_FMRADIO_REC) || CONFIG_CODEC != SWCODEC */ + +#ifndef FM_PRESET +MENUITEM_FUNCTION(radio_presets_item, 0, ID2P(LANG_PRESET), + handle_radio_presets, NULL, NULL, Icon_NOICON); +#endif +#ifndef FM_PRESET_ADD +MENUITEM_FUNCTION(radio_addpreset_item, 0, ID2P(LANG_FM_ADD_PRESET), + handle_radio_add_preset, NULL, NULL, Icon_NOICON); +#endif + +MENUITEM_FUNCTION(presetload_item, 0, ID2P(LANG_FM_PRESET_LOAD), + preset_list_load, NULL, NULL, Icon_NOICON); +MENUITEM_FUNCTION(presetsave_item, 0, ID2P(LANG_FM_PRESET_SAVE), + preset_list_save, NULL, NULL, Icon_NOICON); +MENUITEM_FUNCTION(presetclear_item, 0, ID2P(LANG_FM_PRESET_CLEAR), + preset_list_clear, NULL, NULL, Icon_NOICON); + +MENUITEM_SETTING(set_region, &global_settings.fm_region, NULL); +MENUITEM_SETTING(force_mono, &global_settings.fm_force_mono, NULL); + +#ifndef FM_MODE +extern int radio_mode; +static char* get_mode_text(int selected_item, void * data, char *buffer) +{ + (void)selected_item; + (void)data; + snprintf(buffer, MAX_PATH, "%s %s", str(LANG_MODE), + radio_mode ? str(LANG_PRESET) : + str(LANG_RADIO_SCAN_MODE)); + return buffer; +} +static int toggle_radio_mode(void) +{ + radio_mode = (radio_mode == RADIO_SCAN_MODE) ? + RADIO_PRESET_MODE : RADIO_SCAN_MODE; + return 0; +} +MENUITEM_FUNCTION_DYNTEXT(radio_mode_item, 0, + toggle_radio_mode, NULL, + get_mode_text, NULL, NULL, NULL, Icon_NOICON); +#endif + +MENUITEM_FUNCTION(scan_presets_item, MENU_FUNC_USEPARAM, + ID2P(LANG_FM_SCAN_PRESETS), + presets_scan, NULL, NULL, Icon_NOICON); + +MAKE_MENU(radio_settings_menu, ID2P(LANG_FM_MENU), NULL, + Icon_Radio_screen, +#ifndef FM_PRESET + &radio_presets_item, +#endif +#ifndef FM_PRESET_ADD + &radio_addpreset_item, +#endif + &presetload_item, &presetsave_item, &presetclear_item, + &force_mono, +#ifndef FM_MODE + &radio_mode_item, +#endif + &set_region, &sound_settings, +#ifdef FM_RECORDING_SCREEN + &recscreen_item, +#endif +#ifdef FM_RECORDING_SETTINGS + &recsettings_item, +#endif + &scan_presets_item); + diff --git a/apps/radio/radio.c b/apps/radio/radio.c index 7cc676b9a4..d1a94ac295 100644 --- a/apps/radio/radio.c +++ b/apps/radio/radio.c @@ -19,38 +19,28 @@ * ****************************************************************************/ -#include "config.h" #include #include #include -#include "settings.h" -#include "button.h" -#include "status.h" -#include "thread.h" -#include "audio.h" -#include "mp3_playback.h" -#include "ctype.h" -#include "file.h" -#include "general.h" -#include "errno.h" -#include "string-extra.h" +#include "config.h" #include "system.h" +#include "settings.h" +#include "status.h" +#include "audio.h" +#include "general.h" #include "radio.h" #include "menu.h" +#include "menus/exported_menus.h" #include "misc.h" -#include "keyboard.h" #include "screens.h" #include "peakmeter.h" #include "lang.h" -#include "font.h" -#include "sound_menu.h" #ifdef HAVE_RECORDING #include "recording.h" #endif #ifdef IPOD_ACCESSORY_PROTOCOL #include "iap.h" #endif -#include "appevents.h" #include "talk.h" #include "tuner.h" #include "power.h" @@ -58,17 +48,12 @@ #include "screen_access.h" #include "splash.h" #include "yesno.h" -#include "buttonbar.h" #include "tree.h" #include "dir.h" #include "action.h" -#include "list.h" -#include "menus/exported_menus.h" -#include "root_menu.h" #include "viewport.h" #include "skin_engine/skin_engine.h" #include "statusbar-skinned.h" -#include "buffering.h" #if CONFIG_CODEC == SWCODEC #include "playback.h" #endif @@ -146,12 +131,9 @@ /* presets.c needs these so keep unstatic or redo the whole thing! */ int curr_freq; /* current frequency in Hz */ - -static bool radio_menu(void); - int radio_mode = RADIO_SCAN_MODE; -static int search_dir = 0; +static int search_dir = 0; static int radio_status = FMRADIO_OFF; static bool in_screen = false; @@ -642,7 +624,7 @@ void radio_screen(void) case ACTION_FM_MENU: fms_fix_displays(FMS_EXIT); - radio_menu(); + do_menu(&radio_settings_menu, NULL, NULL, false); preset_set_current(preset_find(curr_freq)); fms_fix_displays(FMS_ENTER); update_type = SKIN_REFRESH_ALL; @@ -902,128 +884,4 @@ void set_radio_region(int region) (void)region; } -MENUITEM_SETTING(set_region, &global_settings.fm_region, NULL); -MENUITEM_SETTING(force_mono, &global_settings.fm_force_mono, NULL); - -#ifndef FM_MODE -static char* get_mode_text(int selected_item, void * data, char *buffer) -{ - (void)selected_item; - (void)data; - snprintf(buffer, MAX_PATH, "%s %s", str(LANG_MODE), - radio_mode ? str(LANG_PRESET) : - str(LANG_RADIO_SCAN_MODE)); - return buffer; -} -static int toggle_radio_mode(void) -{ - radio_mode = (radio_mode == RADIO_SCAN_MODE) ? - RADIO_PRESET_MODE : RADIO_SCAN_MODE; - return 0; -} -MENUITEM_FUNCTION_DYNTEXT(radio_mode_item, 0, - toggle_radio_mode, NULL, - get_mode_text, NULL, NULL, NULL, Icon_NOICON); -#endif - - - -#ifdef HAVE_RECORDING - -#if defined(HAVE_FMRADIO_REC) && CONFIG_CODEC == SWCODEC -#define FM_RECORDING_SCREEN -static int fm_recording_screen(void) -{ - bool ret; - - /* switch recording source to FMRADIO for the duration */ - int rec_source = global_settings.rec_source; - global_settings.rec_source = AUDIO_SRC_FMRADIO; - ret = recording_screen(true); - - /* safe to reset as changing sources is prohibited here */ - global_settings.rec_source = rec_source; - - return ret; -} - -#endif /* defined(HAVE_FMRADIO_REC) && CONFIG_CODEC == SWCODEC */ - -#if defined(HAVE_FMRADIO_REC) || CONFIG_CODEC != SWCODEC -#define FM_RECORDING_SETTINGS -static int fm_recording_settings(void) -{ - bool ret = recording_menu(true); - -#if CONFIG_CODEC != SWCODEC - if (!ret) - { - struct audio_recording_options rec_options; - rec_init_recording_options(&rec_options); - rec_options.rec_source = AUDIO_SRC_LINEIN; - rec_set_recording_options(&rec_options); - } -#endif - - return ret; -} - -#endif /* defined(HAVE_FMRADIO_REC) || CONFIG_CODEC != SWCODEC */ -#endif /* HAVE_RECORDING */ - -#ifdef FM_RECORDING_SCREEN -MENUITEM_FUNCTION(recscreen_item, 0, ID2P(LANG_RECORDING), - fm_recording_screen, NULL, NULL, Icon_Recording); -#endif -#ifdef FM_RECORDING_SETTINGS -MENUITEM_FUNCTION(recsettings_item, 0, ID2P(LANG_RECORDING_SETTINGS), - fm_recording_settings, NULL, NULL, Icon_Recording); -#endif -#ifndef FM_PRESET -MENUITEM_FUNCTION(radio_presets_item, 0, ID2P(LANG_PRESET), - handle_radio_presets, NULL, NULL, Icon_NOICON); -#endif -#ifndef FM_PRESET_ADD -MENUITEM_FUNCTION(radio_addpreset_item, 0, ID2P(LANG_FM_ADD_PRESET), - handle_radio_add_preset, NULL, NULL, Icon_NOICON); -#endif - -MENUITEM_FUNCTION(presetload_item, 0, ID2P(LANG_FM_PRESET_LOAD), - preset_list_load, NULL, NULL, Icon_NOICON); -MENUITEM_FUNCTION(presetsave_item, 0, ID2P(LANG_FM_PRESET_SAVE), - preset_list_save, NULL, NULL, Icon_NOICON); -MENUITEM_FUNCTION(presetclear_item, 0, ID2P(LANG_FM_PRESET_CLEAR), - preset_list_clear, NULL, NULL, Icon_NOICON); -MENUITEM_FUNCTION(scan_presets_item, MENU_FUNC_USEPARAM, - ID2P(LANG_FM_SCAN_PRESETS), - presets_scan, NULL, NULL, Icon_NOICON); - -MAKE_MENU(radio_settings_menu, ID2P(LANG_FM_MENU), NULL, - Icon_Radio_screen, -#ifndef FM_PRESET - &radio_presets_item, -#endif -#ifndef FM_PRESET_ADD - &radio_addpreset_item, -#endif - &presetload_item, &presetsave_item, &presetclear_item, - &force_mono, -#ifndef FM_MODE - &radio_mode_item, -#endif - &set_region, &sound_settings, -#ifdef FM_RECORDING_SCREEN - &recscreen_item, -#endif -#ifdef FM_RECORDING_SETTINGS - &recsettings_item, -#endif - &scan_presets_item); -/* main menu of the radio screen */ -static bool radio_menu(void) -{ - return do_menu(&radio_settings_menu, NULL, NULL, false) == - MENU_ATTACHED_USB; -} - #endif diff --git a/apps/root_menu.c b/apps/root_menu.c index 79b7afffe8..7d2c800e61 100644 --- a/apps/root_menu.c +++ b/apps/root_menu.c @@ -363,9 +363,6 @@ extern struct menu_item_ex #endif main_menu_, manage_settings, - recording_settings_menu, - radio_settings_menu, - bookmark_settings_menu, plugin_menu, playlist_options, info_menu,