From 0f17532c9ddb2282c385ce6ad501a2e5d94acbe5 Mon Sep 17 00:00:00 2001 From: Michael Sevakis Date: Thu, 8 Feb 2007 10:36:49 +0000 Subject: Revert the changes using global status for the screen states. It should wait for a more comprehensive plan to maximize benefit if any can be had. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@12231 a1c6a512-1295-4272-9138-f99709370657 --- apps/filetree.c | 2 +- apps/gui/statusbar.c | 5 +++-- apps/recorder/radio.c | 48 +++++++++++++++++++++++++++-------------------- apps/recorder/radio.h | 1 + apps/recorder/recording.c | 11 +++++++++-- apps/recorder/recording.h | 1 + apps/settings.c | 19 +------------------ apps/settings.h | 8 -------- apps/status.c | 5 +++-- 9 files changed, 47 insertions(+), 53 deletions(-) (limited to 'apps') diff --git a/apps/filetree.c b/apps/filetree.c index 4a68d00f8b..10174dbb31 100644 --- a/apps/filetree.c +++ b/apps/filetree.c @@ -445,7 +445,7 @@ int ft_enter(struct tree_context* c) { set_file(buf, global_settings.fmr_file, MAX_FILENAME); radio_load_presets(global_settings.fmr_file); - if(!global_status.in_radio_screen) + if(!in_radio_screen()) radio_screen(); } /* diff --git a/apps/gui/statusbar.c b/apps/gui/statusbar.c index f1943f3356..d3f4813e37 100644 --- a/apps/gui/statusbar.c +++ b/apps/gui/statusbar.c @@ -258,7 +258,8 @@ void gui_statusbar_draw(struct gui_statusbar * bar, bool force_redraw) #endif #ifdef HAVE_RECORDING /* turn off volume display in recording screen */ - if (!global_status.in_recording_screen) + bool recscreen_on = in_recording_screen(); + if (!recscreen_on) #endif bar->redraw_volume = gui_statusbar_icon_volume(bar, bar->info.volume); gui_statusbar_icon_play_state(display, current_playmode() + Icon_Play); @@ -266,7 +267,7 @@ void gui_statusbar_draw(struct gui_statusbar * bar, bool force_redraw) #ifdef HAVE_RECORDING /* If in recording screen, replace repeat mode, volume and shuffle icons with recording info */ - if (global_status.in_recording_screen) + if (recscreen_on) gui_statusbar_icon_recording_info(display); else #endif 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; static int curr_freq; static int radio_mode = RADIO_SCAN_MODE; +static int radio_status = FMRADIO_OFF; +static bool in_screen = false; + #define MAX_PRESETS 64 static bool presets_loaded = false, presets_changed = false; static struct fmstation presets[MAX_PRESETS]; @@ -186,9 +189,14 @@ void radio_init(void) the global_status structure directly. */ int get_radio_status(void) { - return global_status.radio_status; + return radio_status; } +bool in_radio_screen(void) +{ + return in_screen; +} + /* secret flag for starting paused - prevents unmute */ #define FMRADIO_START_PAUSED 0x8000 void radio_start(void) @@ -196,14 +204,14 @@ void radio_start(void) bool start_paused; int mute_timeout; - if(global_status.radio_status == FMRADIO_PLAYING) + if(radio_status == FMRADIO_PLAYING) return; - start_paused = global_status.radio_status & FMRADIO_START_PAUSED; + start_paused = radio_status & FMRADIO_START_PAUSED; /* clear flag before any yielding */ - global_status.radio_status &= ~FMRADIO_START_PAUSED; + radio_status &= ~FMRADIO_START_PAUSED; - if(global_status.radio_status == FMRADIO_OFF) + if(radio_status == FMRADIO_OFF) radio_power(true); curr_freq = global_status.last_frequency @@ -213,7 +221,7 @@ void radio_start(void) radio_set(RADIO_SLEEP, 0); /* wake up the tuner */ radio_set(RADIO_FREQUENCY, curr_freq); - if(global_status.radio_status == FMRADIO_OFF) + if(radio_status == FMRADIO_OFF) { radio_set(RADIO_IF_MEASUREMENT, 0); radio_set(RADIO_SENSITIVITY, 0); @@ -242,34 +250,34 @@ void radio_start(void) if(!start_paused) radio_set(RADIO_MUTE, 0); - global_status.radio_status = FMRADIO_PLAYING; + radio_status = FMRADIO_PLAYING; } /* radio_start */ void radio_pause(void) { - if(global_status.radio_status == FMRADIO_PAUSED) + if(radio_status == FMRADIO_PAUSED) return; - if(global_status.radio_status == FMRADIO_OFF) + if(radio_status == FMRADIO_OFF) { - global_status.radio_status |= FMRADIO_START_PAUSED; + radio_status |= FMRADIO_START_PAUSED; radio_start(); } radio_set(RADIO_MUTE, 1); radio_set(RADIO_SLEEP, 1); - global_status.radio_status = FMRADIO_PAUSED; + radio_status = FMRADIO_PAUSED; } /* radio_pause */ void radio_stop(void) { - if(global_status.radio_status == FMRADIO_OFF) + if(radio_status == FMRADIO_OFF) return; radio_set(RADIO_MUTE, 1); radio_set(RADIO_SLEEP, 1); /* low power mode, if available */ - global_status.radio_status = FMRADIO_OFF; + radio_status = FMRADIO_OFF; radio_power(false); /* status update, power off if avail. */ } /* radio_stop */ @@ -391,7 +399,7 @@ bool radio_screen(void) gui_buttonbar_set_display(&buttonbar, &(screens[SCREEN_MAIN]) ); #endif /* change status to "in screen" */ - global_status.in_radio_screen = true; + in_screen = true; /* always display status bar in radio screen for now */ global_settings.statusbar = true; @@ -416,7 +424,7 @@ bool radio_screen(void) } #ifndef SIMULATOR - if(global_status.radio_status == FMRADIO_OFF) + if(radio_status == FMRADIO_OFF) audio_stop(); #if CONFIG_CODEC != SWCODEC @@ -444,10 +452,10 @@ bool radio_screen(void) /* turn on radio */ #if CONFIG_CODEC == SWCODEC rec_set_source(AUDIO_SRC_FMRADIO, - (global_status.radio_status == FMRADIO_PAUSED) ? + (radio_status == FMRADIO_PAUSED) ? SRCF_FMRADIO_PAUSED : SRCF_FMRADIO_PLAYING); #else - if (global_status.radio_status == FMRADIO_OFF) + if (radio_status == FMRADIO_OFF) radio_start(); #endif @@ -671,7 +679,7 @@ bool radio_screen(void) break; case ACTION_FM_PLAY: - if (global_status.radio_status == FMRADIO_PLAYING) + if (radio_status == FMRADIO_PLAYING) radio_pause(); else radio_start(); @@ -814,7 +822,7 @@ bool radio_screen(void) timeout = current_tick + HZ; /* keep "mono" from always being displayed when paused */ - if (global_status.radio_status != FMRADIO_PAUSED) + if (radio_status != FMRADIO_PAUSED) { stereo = radio_get(RADIO_STEREO) && !global_settings.fm_force_mono; @@ -957,7 +965,7 @@ bool radio_screen(void) /* restore status bar settings */ global_settings.statusbar = statusbar; - global_status.in_radio_screen = false; + in_screen = false; return have_recorded; } /* 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); void radio_pause(void); void radio_stop(void); bool radio_hardware_present(void); +bool in_radio_screen(void); #define MAX_FMPRESET_LEN 27 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 @@ #include "radio.h" #ifdef HAVE_RECORDING +static bool in_screen = false; + +bool in_recording_screen(void) +{ + return in_screen; +} + #define PM_HEIGHT ((LCD_HEIGHT >= 72) ? 2 : 1) #if CONFIG_KEYPAD == RECORDER_PAD @@ -794,7 +801,7 @@ bool recording_screen(bool no_source) struct audio_recording_options rec_options; - global_status.in_recording_screen = true; + in_screen = true; cursor = 0; #if (CONFIG_LED == LED_REAL) && !defined(SIMULATOR) ata_set_led_enabled(false); @@ -1764,7 +1771,7 @@ bool recording_screen(bool no_source) peak_meter_trigger(false); peak_meter_set_trigger_listener(NULL); - global_status.in_recording_screen = false; + in_screen = false; sound_settings_apply(); 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 @@ #define RECORDING_H #include "audio.h" +bool in_recording_screen(void); bool recording_screen(bool no_source); char *rec_create_filename(char *buf); int rec_create_directory(void); diff --git a/apps/settings.c b/apps/settings.c index 42a66ace8b..8c92b84dad 100644 --- a/apps/settings.c +++ b/apps/settings.c @@ -74,21 +74,7 @@ void dac_line_in(bool enable); #endif struct user_settings global_settings; - -/* Initial values for globally needed state data that shouldn't be saved - or reset should be defined here and not in settings_list */ - -struct system_status global_status = -{ - .runtime = 0, /* this will be overwritten when nvram settings are loaded */ -#ifdef CONFIG_TUNER - .in_radio_screen = false, - .radio_status = FMRADIO_OFF, -#endif -#ifdef HAVE_RECORDING - .in_recording_screen = false, -#endif -}; +struct system_status global_status; #ifdef HAVE_RECORDING const char rec_base_directory[] = REC_BASE_DIR; @@ -919,9 +905,6 @@ void settings_reset(void) { #if defined (HAVE_RECORDING) && CONFIG_CODEC == SWCODEC enc_global_settings_reset(); #endif -#ifdef HAVE_RECORDING - global_status.in_recording_screen = false; -#endif } /** Changing setting values **/ diff --git a/apps/settings.h b/apps/settings.h index 21fd341cd4..0411f6e7db 100644 --- a/apps/settings.h +++ b/apps/settings.h @@ -268,14 +268,6 @@ struct system_status #ifdef CONFIG_TUNER int last_frequency; /* Last frequency for resuming, in FREQ_STEP units, relative to MIN_FREQ */ - bool in_radio_screen; /* Currently in radio screen? - Set by radio_screen. */ - int radio_status; /* Current radio status (off, playing, paused) - Set by radio control functions. */ -#endif -#ifdef HAVE_RECORDING - bool in_recording_screen; /* Currently in recording screen? - Set by recording_screen. */ #endif }; diff --git a/apps/status.c b/apps/status.c index d03cb98157..3f46607ed1 100644 --- a/apps/status.c +++ b/apps/status.c @@ -97,10 +97,11 @@ int current_playmode(void) #endif #ifdef CONFIG_TUNER - if(global_status.radio_status & FMRADIO_PLAYING) + audio_stat = get_radio_status(); + if(audio_stat & FMRADIO_PLAYING) return STATUS_RADIO; - if(global_status.radio_status & FMRADIO_PAUSED) + if(audio_stat & FMRADIO_PAUSED) return STATUS_RADIO_PAUSE; #endif -- cgit v1.2.3