summaryrefslogtreecommitdiff
path: root/apps/recorder/radio.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/recorder/radio.c')
-rw-r--r--apps/recorder/radio.c48
1 files changed, 28 insertions, 20 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;
114static int curr_freq; 114static int curr_freq;
115static int radio_mode = RADIO_SCAN_MODE; 115static int radio_mode = RADIO_SCAN_MODE;
116 116
117static int radio_status = FMRADIO_OFF;
118static bool in_screen = false;
119
117#define MAX_PRESETS 64 120#define MAX_PRESETS 64
118static bool presets_loaded = false, presets_changed = false; 121static bool presets_loaded = false, presets_changed = false;
119static struct fmstation presets[MAX_PRESETS]; 122static 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. */
187int get_radio_status(void) 190int get_radio_status(void)
188{ 191{
189 return global_status.radio_status; 192 return radio_status;
190} 193}
191 194
195bool 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
194void radio_start(void) 202void 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
248void radio_pause(void) 256void 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
265void radio_stop(void) 273void 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 */