diff options
Diffstat (limited to 'apps/recorder')
-rw-r--r-- | apps/recorder/radio.c | 48 | ||||
-rw-r--r-- | apps/recorder/radio.h | 1 | ||||
-rw-r--r-- | apps/recorder/recording.c | 11 | ||||
-rw-r--r-- | apps/recorder/recording.h | 1 |
4 files changed, 39 insertions, 22 deletions
diff --git a/apps/recorder/radio.c b/apps/recorder/radio.c index 97d6266a02..a1821de58f 100644 --- a/apps/recorder/radio.c +++ b/apps/recorder/radio.c | |||
@@ -114,6 +114,9 @@ static int curr_preset = -1; | |||
114 | static int curr_freq; | 114 | static int curr_freq; |
115 | static int radio_mode = RADIO_SCAN_MODE; | 115 | static int radio_mode = RADIO_SCAN_MODE; |
116 | 116 | ||
117 | static int radio_status = FMRADIO_OFF; | ||
118 | static bool in_screen = false; | ||
119 | |||
117 | #define MAX_PRESETS 64 | 120 | #define MAX_PRESETS 64 |
118 | static bool presets_loaded = false, presets_changed = false; | 121 | static bool presets_loaded = false, presets_changed = false; |
119 | static struct fmstation presets[MAX_PRESETS]; | 122 | static struct fmstation presets[MAX_PRESETS]; |
@@ -186,9 +189,14 @@ void radio_init(void) | |||
186 | the global_status structure directly. */ | 189 | the global_status structure directly. */ |
187 | int get_radio_status(void) | 190 | int get_radio_status(void) |
188 | { | 191 | { |
189 | return global_status.radio_status; | 192 | return radio_status; |
190 | } | 193 | } |
191 | 194 | ||
195 | bool in_radio_screen(void) | ||
196 | { | ||
197 | return in_screen; | ||
198 | } | ||
199 | |||
192 | /* secret flag for starting paused - prevents unmute */ | 200 | /* secret flag for starting paused - prevents unmute */ |
193 | #define FMRADIO_START_PAUSED 0x8000 | 201 | #define FMRADIO_START_PAUSED 0x8000 |
194 | void radio_start(void) | 202 | void radio_start(void) |
@@ -196,14 +204,14 @@ void radio_start(void) | |||
196 | bool start_paused; | 204 | bool start_paused; |
197 | int mute_timeout; | 205 | int mute_timeout; |
198 | 206 | ||
199 | if(global_status.radio_status == FMRADIO_PLAYING) | 207 | if(radio_status == FMRADIO_PLAYING) |
200 | return; | 208 | return; |
201 | 209 | ||
202 | start_paused = global_status.radio_status & FMRADIO_START_PAUSED; | 210 | start_paused = radio_status & FMRADIO_START_PAUSED; |
203 | /* clear flag before any yielding */ | 211 | /* clear flag before any yielding */ |
204 | global_status.radio_status &= ~FMRADIO_START_PAUSED; | 212 | radio_status &= ~FMRADIO_START_PAUSED; |
205 | 213 | ||
206 | if(global_status.radio_status == FMRADIO_OFF) | 214 | if(radio_status == FMRADIO_OFF) |
207 | radio_power(true); | 215 | radio_power(true); |
208 | 216 | ||
209 | curr_freq = global_status.last_frequency | 217 | curr_freq = global_status.last_frequency |
@@ -213,7 +221,7 @@ void radio_start(void) | |||
213 | radio_set(RADIO_SLEEP, 0); /* wake up the tuner */ | 221 | radio_set(RADIO_SLEEP, 0); /* wake up the tuner */ |
214 | radio_set(RADIO_FREQUENCY, curr_freq); | 222 | radio_set(RADIO_FREQUENCY, curr_freq); |
215 | 223 | ||
216 | if(global_status.radio_status == FMRADIO_OFF) | 224 | if(radio_status == FMRADIO_OFF) |
217 | { | 225 | { |
218 | radio_set(RADIO_IF_MEASUREMENT, 0); | 226 | radio_set(RADIO_IF_MEASUREMENT, 0); |
219 | radio_set(RADIO_SENSITIVITY, 0); | 227 | radio_set(RADIO_SENSITIVITY, 0); |
@@ -242,34 +250,34 @@ void radio_start(void) | |||
242 | if(!start_paused) | 250 | if(!start_paused) |
243 | radio_set(RADIO_MUTE, 0); | 251 | radio_set(RADIO_MUTE, 0); |
244 | 252 | ||
245 | global_status.radio_status = FMRADIO_PLAYING; | 253 | radio_status = FMRADIO_PLAYING; |
246 | } /* radio_start */ | 254 | } /* radio_start */ |
247 | 255 | ||
248 | void radio_pause(void) | 256 | void radio_pause(void) |
249 | { | 257 | { |
250 | if(global_status.radio_status == FMRADIO_PAUSED) | 258 | if(radio_status == FMRADIO_PAUSED) |
251 | return; | 259 | return; |
252 | 260 | ||
253 | if(global_status.radio_status == FMRADIO_OFF) | 261 | if(radio_status == FMRADIO_OFF) |
254 | { | 262 | { |
255 | global_status.radio_status |= FMRADIO_START_PAUSED; | 263 | radio_status |= FMRADIO_START_PAUSED; |
256 | radio_start(); | 264 | radio_start(); |
257 | } | 265 | } |
258 | 266 | ||
259 | radio_set(RADIO_MUTE, 1); | 267 | radio_set(RADIO_MUTE, 1); |
260 | radio_set(RADIO_SLEEP, 1); | 268 | radio_set(RADIO_SLEEP, 1); |
261 | 269 | ||
262 | global_status.radio_status = FMRADIO_PAUSED; | 270 | radio_status = FMRADIO_PAUSED; |
263 | } /* radio_pause */ | 271 | } /* radio_pause */ |
264 | 272 | ||
265 | void radio_stop(void) | 273 | void radio_stop(void) |
266 | { | 274 | { |
267 | if(global_status.radio_status == FMRADIO_OFF) | 275 | if(radio_status == FMRADIO_OFF) |
268 | return; | 276 | return; |
269 | 277 | ||
270 | radio_set(RADIO_MUTE, 1); | 278 | radio_set(RADIO_MUTE, 1); |
271 | radio_set(RADIO_SLEEP, 1); /* low power mode, if available */ | 279 | radio_set(RADIO_SLEEP, 1); /* low power mode, if available */ |
272 | global_status.radio_status = FMRADIO_OFF; | 280 | radio_status = FMRADIO_OFF; |
273 | radio_power(false); /* status update, power off if avail. */ | 281 | radio_power(false); /* status update, power off if avail. */ |
274 | } /* radio_stop */ | 282 | } /* radio_stop */ |
275 | 283 | ||
@@ -391,7 +399,7 @@ bool radio_screen(void) | |||
391 | gui_buttonbar_set_display(&buttonbar, &(screens[SCREEN_MAIN]) ); | 399 | gui_buttonbar_set_display(&buttonbar, &(screens[SCREEN_MAIN]) ); |
392 | #endif | 400 | #endif |
393 | /* change status to "in screen" */ | 401 | /* change status to "in screen" */ |
394 | global_status.in_radio_screen = true; | 402 | in_screen = true; |
395 | 403 | ||
396 | /* always display status bar in radio screen for now */ | 404 | /* always display status bar in radio screen for now */ |
397 | global_settings.statusbar = true; | 405 | global_settings.statusbar = true; |
@@ -416,7 +424,7 @@ bool radio_screen(void) | |||
416 | } | 424 | } |
417 | 425 | ||
418 | #ifndef SIMULATOR | 426 | #ifndef SIMULATOR |
419 | if(global_status.radio_status == FMRADIO_OFF) | 427 | if(radio_status == FMRADIO_OFF) |
420 | audio_stop(); | 428 | audio_stop(); |
421 | 429 | ||
422 | #if CONFIG_CODEC != SWCODEC | 430 | #if CONFIG_CODEC != SWCODEC |
@@ -444,10 +452,10 @@ bool radio_screen(void) | |||
444 | /* turn on radio */ | 452 | /* turn on radio */ |
445 | #if CONFIG_CODEC == SWCODEC | 453 | #if CONFIG_CODEC == SWCODEC |
446 | rec_set_source(AUDIO_SRC_FMRADIO, | 454 | rec_set_source(AUDIO_SRC_FMRADIO, |
447 | (global_status.radio_status == FMRADIO_PAUSED) ? | 455 | (radio_status == FMRADIO_PAUSED) ? |
448 | SRCF_FMRADIO_PAUSED : SRCF_FMRADIO_PLAYING); | 456 | SRCF_FMRADIO_PAUSED : SRCF_FMRADIO_PLAYING); |
449 | #else | 457 | #else |
450 | if (global_status.radio_status == FMRADIO_OFF) | 458 | if (radio_status == FMRADIO_OFF) |
451 | radio_start(); | 459 | radio_start(); |
452 | #endif | 460 | #endif |
453 | 461 | ||
@@ -671,7 +679,7 @@ bool radio_screen(void) | |||
671 | break; | 679 | break; |
672 | 680 | ||
673 | case ACTION_FM_PLAY: | 681 | case ACTION_FM_PLAY: |
674 | if (global_status.radio_status == FMRADIO_PLAYING) | 682 | if (radio_status == FMRADIO_PLAYING) |
675 | radio_pause(); | 683 | radio_pause(); |
676 | else | 684 | else |
677 | radio_start(); | 685 | radio_start(); |
@@ -814,7 +822,7 @@ bool radio_screen(void) | |||
814 | timeout = current_tick + HZ; | 822 | timeout = current_tick + HZ; |
815 | 823 | ||
816 | /* keep "mono" from always being displayed when paused */ | 824 | /* keep "mono" from always being displayed when paused */ |
817 | if (global_status.radio_status != FMRADIO_PAUSED) | 825 | if (radio_status != FMRADIO_PAUSED) |
818 | { | 826 | { |
819 | stereo = radio_get(RADIO_STEREO) && | 827 | stereo = radio_get(RADIO_STEREO) && |
820 | !global_settings.fm_force_mono; | 828 | !global_settings.fm_force_mono; |
@@ -957,7 +965,7 @@ bool radio_screen(void) | |||
957 | /* restore status bar settings */ | 965 | /* restore status bar settings */ |
958 | global_settings.statusbar = statusbar; | 966 | global_settings.statusbar = statusbar; |
959 | 967 | ||
960 | global_status.in_radio_screen = false; | 968 | in_screen = false; |
961 | 969 | ||
962 | return have_recorded; | 970 | return have_recorded; |
963 | } /* radio_screen */ | 971 | } /* radio_screen */ |
diff --git a/apps/recorder/radio.h b/apps/recorder/radio.h index 0bfda3bccf..a4f9f1a978 100644 --- a/apps/recorder/radio.h +++ b/apps/recorder/radio.h | |||
@@ -31,6 +31,7 @@ void radio_start(void); | |||
31 | void radio_pause(void); | 31 | void radio_pause(void); |
32 | void radio_stop(void); | 32 | void radio_stop(void); |
33 | bool radio_hardware_present(void); | 33 | bool radio_hardware_present(void); |
34 | bool in_radio_screen(void); | ||
34 | 35 | ||
35 | #define MAX_FMPRESET_LEN 27 | 36 | #define MAX_FMPRESET_LEN 27 |
36 | 37 | ||
diff --git a/apps/recorder/recording.c b/apps/recorder/recording.c index a0a929f3a6..eb6f9b20ca 100644 --- a/apps/recorder/recording.c +++ b/apps/recorder/recording.c | |||
@@ -70,6 +70,13 @@ | |||
70 | #include "radio.h" | 70 | #include "radio.h" |
71 | #ifdef HAVE_RECORDING | 71 | #ifdef HAVE_RECORDING |
72 | 72 | ||
73 | static bool in_screen = false; | ||
74 | |||
75 | bool in_recording_screen(void) | ||
76 | { | ||
77 | return in_screen; | ||
78 | } | ||
79 | |||
73 | #define PM_HEIGHT ((LCD_HEIGHT >= 72) ? 2 : 1) | 80 | #define PM_HEIGHT ((LCD_HEIGHT >= 72) ? 2 : 1) |
74 | 81 | ||
75 | #if CONFIG_KEYPAD == RECORDER_PAD | 82 | #if CONFIG_KEYPAD == RECORDER_PAD |
@@ -794,7 +801,7 @@ bool recording_screen(bool no_source) | |||
794 | 801 | ||
795 | struct audio_recording_options rec_options; | 802 | struct audio_recording_options rec_options; |
796 | 803 | ||
797 | global_status.in_recording_screen = true; | 804 | in_screen = true; |
798 | cursor = 0; | 805 | cursor = 0; |
799 | #if (CONFIG_LED == LED_REAL) && !defined(SIMULATOR) | 806 | #if (CONFIG_LED == LED_REAL) && !defined(SIMULATOR) |
800 | ata_set_led_enabled(false); | 807 | ata_set_led_enabled(false); |
@@ -1764,7 +1771,7 @@ bool recording_screen(bool no_source) | |||
1764 | peak_meter_trigger(false); | 1771 | peak_meter_trigger(false); |
1765 | peak_meter_set_trigger_listener(NULL); | 1772 | peak_meter_set_trigger_listener(NULL); |
1766 | 1773 | ||
1767 | global_status.in_recording_screen = false; | 1774 | in_screen = false; |
1768 | sound_settings_apply(); | 1775 | sound_settings_apply(); |
1769 | 1776 | ||
1770 | FOR_NB_SCREENS(i) | 1777 | FOR_NB_SCREENS(i) |
diff --git a/apps/recorder/recording.h b/apps/recorder/recording.h index e78af50671..1921074d26 100644 --- a/apps/recorder/recording.h +++ b/apps/recorder/recording.h | |||
@@ -20,6 +20,7 @@ | |||
20 | #define RECORDING_H | 20 | #define RECORDING_H |
21 | #include "audio.h" | 21 | #include "audio.h" |
22 | 22 | ||
23 | bool in_recording_screen(void); | ||
23 | bool recording_screen(bool no_source); | 24 | bool recording_screen(bool no_source); |
24 | char *rec_create_filename(char *buf); | 25 | char *rec_create_filename(char *buf); |
25 | int rec_create_directory(void); | 26 | int rec_create_directory(void); |