diff options
author | Michael Sevakis <jethead71@rockbox.org> | 2007-02-07 04:24:21 +0000 |
---|---|---|
committer | Michael Sevakis <jethead71@rockbox.org> | 2007-02-07 04:24:21 +0000 |
commit | eed62f1657f4f2b08571f0bd2b1827f3a71dac87 (patch) | |
tree | 1023d721c59e29150f445bbba25a0e11bed4c1ae /apps/recorder/radio.c | |
parent | ff3bb3aa18e71860d644a50632088ec282968de4 (diff) | |
download | rockbox-eed62f1657f4f2b08571f0bd2b1827f3a71dac87.tar.gz rockbox-eed62f1657f4f2b08571f0bd2b1827f3a71dac87.zip |
Change the radio screen and recording screen to use the global_status structure for state. I guess global_status had been added already and I missed it. :D
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@12222 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/recorder/radio.c')
-rw-r--r-- | apps/recorder/radio.c | 51 |
1 files changed, 23 insertions, 28 deletions
diff --git a/apps/recorder/radio.c b/apps/recorder/radio.c index dc533cf017..97d6266a02 100644 --- a/apps/recorder/radio.c +++ b/apps/recorder/radio.c | |||
@@ -114,9 +114,6 @@ 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 | |||
120 | #define MAX_PRESETS 64 | 117 | #define MAX_PRESETS 64 |
121 | static bool presets_loaded = false, presets_changed = false; | 118 | static bool presets_loaded = false, presets_changed = false; |
122 | static struct fmstation presets[MAX_PRESETS]; | 119 | static struct fmstation presets[MAX_PRESETS]; |
@@ -185,14 +182,11 @@ void radio_init(void) | |||
185 | radio_stop(); | 182 | radio_stop(); |
186 | } | 183 | } |
187 | 184 | ||
185 | /* For powermgmt.c to check status for shutdown since it can't access | ||
186 | the global_status structure directly. */ | ||
188 | int get_radio_status(void) | 187 | int get_radio_status(void) |
189 | { | 188 | { |
190 | return radio_status; | 189 | return global_status.radio_status; |
191 | } | ||
192 | |||
193 | bool in_radio_screen(void) | ||
194 | { | ||
195 | return in_screen; | ||
196 | } | 190 | } |
197 | 191 | ||
198 | /* secret flag for starting paused - prevents unmute */ | 192 | /* secret flag for starting paused - prevents unmute */ |
@@ -202,14 +196,14 @@ void radio_start(void) | |||
202 | bool start_paused; | 196 | bool start_paused; |
203 | int mute_timeout; | 197 | int mute_timeout; |
204 | 198 | ||
205 | if(radio_status == FMRADIO_PLAYING) | 199 | if(global_status.radio_status == FMRADIO_PLAYING) |
206 | return; | 200 | return; |
207 | 201 | ||
208 | start_paused = radio_status & FMRADIO_START_PAUSED; | 202 | start_paused = global_status.radio_status & FMRADIO_START_PAUSED; |
209 | /* clear flag before any yielding */ | 203 | /* clear flag before any yielding */ |
210 | radio_status &= ~FMRADIO_START_PAUSED; | 204 | global_status.radio_status &= ~FMRADIO_START_PAUSED; |
211 | 205 | ||
212 | if(radio_status == FMRADIO_OFF) | 206 | if(global_status.radio_status == FMRADIO_OFF) |
213 | radio_power(true); | 207 | radio_power(true); |
214 | 208 | ||
215 | curr_freq = global_status.last_frequency | 209 | curr_freq = global_status.last_frequency |
@@ -219,7 +213,7 @@ void radio_start(void) | |||
219 | radio_set(RADIO_SLEEP, 0); /* wake up the tuner */ | 213 | radio_set(RADIO_SLEEP, 0); /* wake up the tuner */ |
220 | radio_set(RADIO_FREQUENCY, curr_freq); | 214 | radio_set(RADIO_FREQUENCY, curr_freq); |
221 | 215 | ||
222 | if(radio_status == FMRADIO_OFF) | 216 | if(global_status.radio_status == FMRADIO_OFF) |
223 | { | 217 | { |
224 | radio_set(RADIO_IF_MEASUREMENT, 0); | 218 | radio_set(RADIO_IF_MEASUREMENT, 0); |
225 | radio_set(RADIO_SENSITIVITY, 0); | 219 | radio_set(RADIO_SENSITIVITY, 0); |
@@ -248,34 +242,34 @@ void radio_start(void) | |||
248 | if(!start_paused) | 242 | if(!start_paused) |
249 | radio_set(RADIO_MUTE, 0); | 243 | radio_set(RADIO_MUTE, 0); |
250 | 244 | ||
251 | radio_status = FMRADIO_PLAYING; | 245 | global_status.radio_status = FMRADIO_PLAYING; |
252 | } /* radio_start */ | 246 | } /* radio_start */ |
253 | 247 | ||
254 | void radio_pause(void) | 248 | void radio_pause(void) |
255 | { | 249 | { |
256 | if(radio_status == FMRADIO_PAUSED) | 250 | if(global_status.radio_status == FMRADIO_PAUSED) |
257 | return; | 251 | return; |
258 | 252 | ||
259 | if(radio_status == FMRADIO_OFF) | 253 | if(global_status.radio_status == FMRADIO_OFF) |
260 | { | 254 | { |
261 | radio_status |= FMRADIO_START_PAUSED; | 255 | global_status.radio_status |= FMRADIO_START_PAUSED; |
262 | radio_start(); | 256 | radio_start(); |
263 | } | 257 | } |
264 | 258 | ||
265 | radio_set(RADIO_MUTE, 1); | 259 | radio_set(RADIO_MUTE, 1); |
266 | radio_set(RADIO_SLEEP, 1); | 260 | radio_set(RADIO_SLEEP, 1); |
267 | 261 | ||
268 | radio_status = FMRADIO_PAUSED; | 262 | global_status.radio_status = FMRADIO_PAUSED; |
269 | } /* radio_pause */ | 263 | } /* radio_pause */ |
270 | 264 | ||
271 | void radio_stop(void) | 265 | void radio_stop(void) |
272 | { | 266 | { |
273 | if(radio_status == FMRADIO_OFF) | 267 | if(global_status.radio_status == FMRADIO_OFF) |
274 | return; | 268 | return; |
275 | 269 | ||
276 | radio_set(RADIO_MUTE, 1); | 270 | radio_set(RADIO_MUTE, 1); |
277 | radio_set(RADIO_SLEEP, 1); /* low power mode, if available */ | 271 | radio_set(RADIO_SLEEP, 1); /* low power mode, if available */ |
278 | radio_status = FMRADIO_OFF; | 272 | global_status.radio_status = FMRADIO_OFF; |
279 | radio_power(false); /* status update, power off if avail. */ | 273 | radio_power(false); /* status update, power off if avail. */ |
280 | } /* radio_stop */ | 274 | } /* radio_stop */ |
281 | 275 | ||
@@ -397,7 +391,7 @@ bool radio_screen(void) | |||
397 | gui_buttonbar_set_display(&buttonbar, &(screens[SCREEN_MAIN]) ); | 391 | gui_buttonbar_set_display(&buttonbar, &(screens[SCREEN_MAIN]) ); |
398 | #endif | 392 | #endif |
399 | /* change status to "in screen" */ | 393 | /* change status to "in screen" */ |
400 | in_screen = true; | 394 | global_status.in_radio_screen = true; |
401 | 395 | ||
402 | /* always display status bar in radio screen for now */ | 396 | /* always display status bar in radio screen for now */ |
403 | global_settings.statusbar = true; | 397 | global_settings.statusbar = true; |
@@ -422,7 +416,7 @@ bool radio_screen(void) | |||
422 | } | 416 | } |
423 | 417 | ||
424 | #ifndef SIMULATOR | 418 | #ifndef SIMULATOR |
425 | if(radio_status == FMRADIO_OFF) | 419 | if(global_status.radio_status == FMRADIO_OFF) |
426 | audio_stop(); | 420 | audio_stop(); |
427 | 421 | ||
428 | #if CONFIG_CODEC != SWCODEC | 422 | #if CONFIG_CODEC != SWCODEC |
@@ -449,10 +443,11 @@ bool radio_screen(void) | |||
449 | 443 | ||
450 | /* turn on radio */ | 444 | /* turn on radio */ |
451 | #if CONFIG_CODEC == SWCODEC | 445 | #if CONFIG_CODEC == SWCODEC |
452 | rec_set_source(AUDIO_SRC_FMRADIO, (radio_status == FMRADIO_PAUSED) ? | 446 | rec_set_source(AUDIO_SRC_FMRADIO, |
447 | (global_status.radio_status == FMRADIO_PAUSED) ? | ||
453 | SRCF_FMRADIO_PAUSED : SRCF_FMRADIO_PLAYING); | 448 | SRCF_FMRADIO_PAUSED : SRCF_FMRADIO_PLAYING); |
454 | #else | 449 | #else |
455 | if (radio_status == FMRADIO_OFF) | 450 | if (global_status.radio_status == FMRADIO_OFF) |
456 | radio_start(); | 451 | radio_start(); |
457 | #endif | 452 | #endif |
458 | 453 | ||
@@ -676,7 +671,7 @@ bool radio_screen(void) | |||
676 | break; | 671 | break; |
677 | 672 | ||
678 | case ACTION_FM_PLAY: | 673 | case ACTION_FM_PLAY: |
679 | if (radio_status == FMRADIO_PLAYING) | 674 | if (global_status.radio_status == FMRADIO_PLAYING) |
680 | radio_pause(); | 675 | radio_pause(); |
681 | else | 676 | else |
682 | radio_start(); | 677 | radio_start(); |
@@ -819,7 +814,7 @@ bool radio_screen(void) | |||
819 | timeout = current_tick + HZ; | 814 | timeout = current_tick + HZ; |
820 | 815 | ||
821 | /* keep "mono" from always being displayed when paused */ | 816 | /* keep "mono" from always being displayed when paused */ |
822 | if (radio_status != FMRADIO_PAUSED) | 817 | if (global_status.radio_status != FMRADIO_PAUSED) |
823 | { | 818 | { |
824 | stereo = radio_get(RADIO_STEREO) && | 819 | stereo = radio_get(RADIO_STEREO) && |
825 | !global_settings.fm_force_mono; | 820 | !global_settings.fm_force_mono; |
@@ -962,7 +957,7 @@ bool radio_screen(void) | |||
962 | /* restore status bar settings */ | 957 | /* restore status bar settings */ |
963 | global_settings.statusbar = statusbar; | 958 | global_settings.statusbar = statusbar; |
964 | 959 | ||
965 | in_screen = false; | 960 | global_status.in_radio_screen = false; |
966 | 961 | ||
967 | return have_recorded; | 962 | return have_recorded; |
968 | } /* radio_screen */ | 963 | } /* radio_screen */ |