diff options
Diffstat (limited to 'apps/radio/radio.c')
-rw-r--r-- | apps/radio/radio.c | 152 |
1 files changed, 5 insertions, 147 deletions
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 @@ | |||
19 | * | 19 | * |
20 | ****************************************************************************/ | 20 | ****************************************************************************/ |
21 | 21 | ||
22 | #include "config.h" | ||
23 | #include <stdio.h> | 22 | #include <stdio.h> |
24 | #include <stdbool.h> | 23 | #include <stdbool.h> |
25 | #include <stdlib.h> | 24 | #include <stdlib.h> |
25 | #include "config.h" | ||
26 | #include "system.h" | ||
26 | #include "settings.h" | 27 | #include "settings.h" |
27 | #include "button.h" | ||
28 | #include "status.h" | 28 | #include "status.h" |
29 | #include "thread.h" | ||
30 | #include "audio.h" | 29 | #include "audio.h" |
31 | #include "mp3_playback.h" | ||
32 | #include "ctype.h" | ||
33 | #include "file.h" | ||
34 | #include "general.h" | 30 | #include "general.h" |
35 | #include "errno.h" | ||
36 | #include "string-extra.h" | ||
37 | #include "system.h" | ||
38 | #include "radio.h" | 31 | #include "radio.h" |
39 | #include "menu.h" | 32 | #include "menu.h" |
33 | #include "menus/exported_menus.h" | ||
40 | #include "misc.h" | 34 | #include "misc.h" |
41 | #include "keyboard.h" | ||
42 | #include "screens.h" | 35 | #include "screens.h" |
43 | #include "peakmeter.h" | 36 | #include "peakmeter.h" |
44 | #include "lang.h" | 37 | #include "lang.h" |
45 | #include "font.h" | ||
46 | #include "sound_menu.h" | ||
47 | #ifdef HAVE_RECORDING | 38 | #ifdef HAVE_RECORDING |
48 | #include "recording.h" | 39 | #include "recording.h" |
49 | #endif | 40 | #endif |
50 | #ifdef IPOD_ACCESSORY_PROTOCOL | 41 | #ifdef IPOD_ACCESSORY_PROTOCOL |
51 | #include "iap.h" | 42 | #include "iap.h" |
52 | #endif | 43 | #endif |
53 | #include "appevents.h" | ||
54 | #include "talk.h" | 44 | #include "talk.h" |
55 | #include "tuner.h" | 45 | #include "tuner.h" |
56 | #include "power.h" | 46 | #include "power.h" |
@@ -58,17 +48,12 @@ | |||
58 | #include "screen_access.h" | 48 | #include "screen_access.h" |
59 | #include "splash.h" | 49 | #include "splash.h" |
60 | #include "yesno.h" | 50 | #include "yesno.h" |
61 | #include "buttonbar.h" | ||
62 | #include "tree.h" | 51 | #include "tree.h" |
63 | #include "dir.h" | 52 | #include "dir.h" |
64 | #include "action.h" | 53 | #include "action.h" |
65 | #include "list.h" | ||
66 | #include "menus/exported_menus.h" | ||
67 | #include "root_menu.h" | ||
68 | #include "viewport.h" | 54 | #include "viewport.h" |
69 | #include "skin_engine/skin_engine.h" | 55 | #include "skin_engine/skin_engine.h" |
70 | #include "statusbar-skinned.h" | 56 | #include "statusbar-skinned.h" |
71 | #include "buffering.h" | ||
72 | #if CONFIG_CODEC == SWCODEC | 57 | #if CONFIG_CODEC == SWCODEC |
73 | #include "playback.h" | 58 | #include "playback.h" |
74 | #endif | 59 | #endif |
@@ -146,12 +131,9 @@ | |||
146 | 131 | ||
147 | /* presets.c needs these so keep unstatic or redo the whole thing! */ | 132 | /* presets.c needs these so keep unstatic or redo the whole thing! */ |
148 | int curr_freq; /* current frequency in Hz */ | 133 | int curr_freq; /* current frequency in Hz */ |
149 | |||
150 | static bool radio_menu(void); | ||
151 | |||
152 | int radio_mode = RADIO_SCAN_MODE; | 134 | int radio_mode = RADIO_SCAN_MODE; |
153 | static int search_dir = 0; | ||
154 | 135 | ||
136 | static int search_dir = 0; | ||
155 | static int radio_status = FMRADIO_OFF; | 137 | static int radio_status = FMRADIO_OFF; |
156 | static bool in_screen = false; | 138 | static bool in_screen = false; |
157 | 139 | ||
@@ -642,7 +624,7 @@ void radio_screen(void) | |||
642 | 624 | ||
643 | case ACTION_FM_MENU: | 625 | case ACTION_FM_MENU: |
644 | fms_fix_displays(FMS_EXIT); | 626 | fms_fix_displays(FMS_EXIT); |
645 | radio_menu(); | 627 | do_menu(&radio_settings_menu, NULL, NULL, false); |
646 | preset_set_current(preset_find(curr_freq)); | 628 | preset_set_current(preset_find(curr_freq)); |
647 | fms_fix_displays(FMS_ENTER); | 629 | fms_fix_displays(FMS_ENTER); |
648 | update_type = SKIN_REFRESH_ALL; | 630 | update_type = SKIN_REFRESH_ALL; |
@@ -902,128 +884,4 @@ void set_radio_region(int region) | |||
902 | (void)region; | 884 | (void)region; |
903 | } | 885 | } |
904 | 886 | ||
905 | MENUITEM_SETTING(set_region, &global_settings.fm_region, NULL); | ||
906 | MENUITEM_SETTING(force_mono, &global_settings.fm_force_mono, NULL); | ||
907 | |||
908 | #ifndef FM_MODE | ||
909 | static char* get_mode_text(int selected_item, void * data, char *buffer) | ||
910 | { | ||
911 | (void)selected_item; | ||
912 | (void)data; | ||
913 | snprintf(buffer, MAX_PATH, "%s %s", str(LANG_MODE), | ||
914 | radio_mode ? str(LANG_PRESET) : | ||
915 | str(LANG_RADIO_SCAN_MODE)); | ||
916 | return buffer; | ||
917 | } | ||
918 | static int toggle_radio_mode(void) | ||
919 | { | ||
920 | radio_mode = (radio_mode == RADIO_SCAN_MODE) ? | ||
921 | RADIO_PRESET_MODE : RADIO_SCAN_MODE; | ||
922 | return 0; | ||
923 | } | ||
924 | MENUITEM_FUNCTION_DYNTEXT(radio_mode_item, 0, | ||
925 | toggle_radio_mode, NULL, | ||
926 | get_mode_text, NULL, NULL, NULL, Icon_NOICON); | ||
927 | #endif | ||
928 | |||
929 | |||
930 | |||
931 | #ifdef HAVE_RECORDING | ||
932 | |||
933 | #if defined(HAVE_FMRADIO_REC) && CONFIG_CODEC == SWCODEC | ||
934 | #define FM_RECORDING_SCREEN | ||
935 | static int fm_recording_screen(void) | ||
936 | { | ||
937 | bool ret; | ||
938 | |||
939 | /* switch recording source to FMRADIO for the duration */ | ||
940 | int rec_source = global_settings.rec_source; | ||
941 | global_settings.rec_source = AUDIO_SRC_FMRADIO; | ||
942 | ret = recording_screen(true); | ||
943 | |||
944 | /* safe to reset as changing sources is prohibited here */ | ||
945 | global_settings.rec_source = rec_source; | ||
946 | |||
947 | return ret; | ||
948 | } | ||
949 | |||
950 | #endif /* defined(HAVE_FMRADIO_REC) && CONFIG_CODEC == SWCODEC */ | ||
951 | |||
952 | #if defined(HAVE_FMRADIO_REC) || CONFIG_CODEC != SWCODEC | ||
953 | #define FM_RECORDING_SETTINGS | ||
954 | static int fm_recording_settings(void) | ||
955 | { | ||
956 | bool ret = recording_menu(true); | ||
957 | |||
958 | #if CONFIG_CODEC != SWCODEC | ||
959 | if (!ret) | ||
960 | { | ||
961 | struct audio_recording_options rec_options; | ||
962 | rec_init_recording_options(&rec_options); | ||
963 | rec_options.rec_source = AUDIO_SRC_LINEIN; | ||
964 | rec_set_recording_options(&rec_options); | ||
965 | } | ||
966 | #endif | ||
967 | |||
968 | return ret; | ||
969 | } | ||
970 | |||
971 | #endif /* defined(HAVE_FMRADIO_REC) || CONFIG_CODEC != SWCODEC */ | ||
972 | #endif /* HAVE_RECORDING */ | ||
973 | |||
974 | #ifdef FM_RECORDING_SCREEN | ||
975 | MENUITEM_FUNCTION(recscreen_item, 0, ID2P(LANG_RECORDING), | ||
976 | fm_recording_screen, NULL, NULL, Icon_Recording); | ||
977 | #endif | ||
978 | #ifdef FM_RECORDING_SETTINGS | ||
979 | MENUITEM_FUNCTION(recsettings_item, 0, ID2P(LANG_RECORDING_SETTINGS), | ||
980 | fm_recording_settings, NULL, NULL, Icon_Recording); | ||
981 | #endif | ||
982 | #ifndef FM_PRESET | ||
983 | MENUITEM_FUNCTION(radio_presets_item, 0, ID2P(LANG_PRESET), | ||
984 | handle_radio_presets, NULL, NULL, Icon_NOICON); | ||
985 | #endif | ||
986 | #ifndef FM_PRESET_ADD | ||
987 | MENUITEM_FUNCTION(radio_addpreset_item, 0, ID2P(LANG_FM_ADD_PRESET), | ||
988 | handle_radio_add_preset, NULL, NULL, Icon_NOICON); | ||
989 | #endif | ||
990 | |||
991 | MENUITEM_FUNCTION(presetload_item, 0, ID2P(LANG_FM_PRESET_LOAD), | ||
992 | preset_list_load, NULL, NULL, Icon_NOICON); | ||
993 | MENUITEM_FUNCTION(presetsave_item, 0, ID2P(LANG_FM_PRESET_SAVE), | ||
994 | preset_list_save, NULL, NULL, Icon_NOICON); | ||
995 | MENUITEM_FUNCTION(presetclear_item, 0, ID2P(LANG_FM_PRESET_CLEAR), | ||
996 | preset_list_clear, NULL, NULL, Icon_NOICON); | ||
997 | MENUITEM_FUNCTION(scan_presets_item, MENU_FUNC_USEPARAM, | ||
998 | ID2P(LANG_FM_SCAN_PRESETS), | ||
999 | presets_scan, NULL, NULL, Icon_NOICON); | ||
1000 | |||
1001 | MAKE_MENU(radio_settings_menu, ID2P(LANG_FM_MENU), NULL, | ||
1002 | Icon_Radio_screen, | ||
1003 | #ifndef FM_PRESET | ||
1004 | &radio_presets_item, | ||
1005 | #endif | ||
1006 | #ifndef FM_PRESET_ADD | ||
1007 | &radio_addpreset_item, | ||
1008 | #endif | ||
1009 | &presetload_item, &presetsave_item, &presetclear_item, | ||
1010 | &force_mono, | ||
1011 | #ifndef FM_MODE | ||
1012 | &radio_mode_item, | ||
1013 | #endif | ||
1014 | &set_region, &sound_settings, | ||
1015 | #ifdef FM_RECORDING_SCREEN | ||
1016 | &recscreen_item, | ||
1017 | #endif | ||
1018 | #ifdef FM_RECORDING_SETTINGS | ||
1019 | &recsettings_item, | ||
1020 | #endif | ||
1021 | &scan_presets_item); | ||
1022 | /* main menu of the radio screen */ | ||
1023 | static bool radio_menu(void) | ||
1024 | { | ||
1025 | return do_menu(&radio_settings_menu, NULL, NULL, false) == | ||
1026 | MENU_ATTACHED_USB; | ||
1027 | } | ||
1028 | |||
1029 | #endif | 887 | #endif |