slightly rework peakmeter handling to make it cleaner and be able to be used in conditionals

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@25913 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Jonathan Gordon 2010-05-09 13:01:59 +00:00
parent 382c23e10d
commit 38ef849d06
5 changed files with 35 additions and 40 deletions

View file

@ -630,6 +630,10 @@ static bool evaluate_conditional(struct gui_wps *gwps, int *token_index)
struct progressbar *bar = (struct progressbar*)data->tokens[i].value.data;
bar->draw = false;
}
else if (data->tokens[i].type == WPS_TOKEN_PEAKMETER)
{
data->peak_meter_enabled = false;
}
#endif
#ifdef HAVE_ALBUMART
if (data->albumart && data->tokens[i].type == WPS_TOKEN_ALBUMART_DISPLAY)
@ -692,6 +696,9 @@ static bool get_line(struct gui_wps *gwps,
break;
#ifdef HAVE_LCD_BITMAP
case WPS_TOKEN_PEAKMETER:
data->peak_meter_enabled = true;
break;
case WPS_TOKEN_VOLUMEBAR:
case WPS_TOKEN_BATTERY_PERCENTBAR:
case WPS_TOKEN_PROGRESSBAR:
@ -1083,19 +1090,6 @@ static bool skin_redraw(struct gui_wps *gwps, unsigned refresh_mode)
bool update_line, new_subline_refresh;
#ifdef HAVE_LCD_BITMAP
/* to find out wether the peak meter is enabled we
assume it wasn't until we find a line that contains
the peak meter. We can't use peak_meter_enabled itself
because that would mean to turn off the meter thread
temporarily. (That shouldn't matter unless yield
or sleep is called but who knows...)
*/
bool enable_pm = false;
#endif
/* reset to first subline if refresh all flag is set */
if (refresh_mode == WPS_REFRESH_ALL)
{
@ -1226,27 +1220,27 @@ static bool skin_redraw(struct gui_wps *gwps, unsigned refresh_mode)
/* peakmeter */
if (flags & vp_refresh_mode & WPS_REFRESH_PEAK_METER)
{
/* the peakmeter should be alone on its line */
update_line = false;
int h = font_get(skin_viewport->vp.font)->height;
int peak_meter_y = line_count* h;
/* The user might decide to have the peak meter in the last
line so that it is only displayed if no status bar is
visible. If so we neither want do draw nor enable the
peak meter. */
if (peak_meter_y + h <= skin_viewport->vp.y+skin_viewport->vp.height) {
/* found a line with a peak meter -> remember that we must
enable it later */
enable_pm = true;
peak_meter_enabled = true;
peak_meter_screen(gwps->display, 0, peak_meter_y,
MIN(h, skin_viewport->vp.y+skin_viewport->vp.height - peak_meter_y));
if (!data->peak_meter_enabled)
{
peak_meter_enable(false);
}
else
{
peak_meter_enabled = false;
/* the peakmeter should be alone on its line */
update_line = false;
int h = font_get(skin_viewport->vp.font)->height;
int peak_meter_y = line_count* h;
/* The user might decide to have the peak meter in the last
line so that it is only displayed if no status bar is
visible. If so we neither want do draw nor enable the
peak meter. */
if (peak_meter_y + h <= skin_viewport->vp.y+skin_viewport->vp.height) {
peak_meter_enable(true);
peak_meter_screen(gwps->display, 0, peak_meter_y,
MIN(h, skin_viewport->vp.y+skin_viewport->vp.height - peak_meter_y));
}
}
}
@ -1302,9 +1296,6 @@ static bool skin_redraw(struct gui_wps *gwps, unsigned refresh_mode)
#endif
}
#ifdef HAVE_LCD_BITMAP
data->peak_meter_enabled = enable_pm;
#endif
/* Restore the default viewport */
display->set_viewport(NULL);

View file

@ -78,7 +78,11 @@ static long pm_clip_timeout_r;
/* Temporarily en- / disables peak meter. This is especially for external
applications to detect if the peak_meter is in use and needs drawing at all */
bool peak_meter_enabled = true;
static bool peak_meter_enabled = true;
void peak_meter_enable(bool enable)
{
peak_meter_enabled = enable;
}
/** Parameters **/
/* Range */

View file

@ -32,7 +32,7 @@ extern int pm_get_clipcount(void);
extern void pm_reset_clipcount(void);
extern void pm_activate_clipcount(bool active);
extern bool peak_meter_enabled;
extern void peak_meter_enable(bool enable);
extern void peak_meter_playback(bool playback);
extern int peak_meter_draw_get_btn(int action_context, int x[], int y[],

View file

@ -548,7 +548,7 @@ int radio_screen(void)
/* Yes, we use the D/A for monitoring */
peak_meter_playback(true);
peak_meter_enabled = true;
peak_meter_enable(true);
rec_init_recording_options(&rec_options);
rec_options.rec_source = AUDIO_SRC_LINEIN;

View file

@ -698,7 +698,7 @@ void rec_set_source(int source, unsigned flags)
/* Set peakmeters for recording or reset to playback */
peak_meter_playback((flags & SRCF_RECORDING) == 0);
peak_meter_enabled = true;
peak_meter_enable(true);
}
#endif /* CONFIG_CODEC == SWCODEC && !defined (SIMULATOR) */
@ -1099,7 +1099,7 @@ bool recording_screen(bool no_source)
buffer */
#else
/* Yes, we use the D/A for monitoring */
peak_meter_enabled = true;
peak_meter_enable(true);
peak_meter_playback(true);
#endif
@ -1549,7 +1549,7 @@ bool recording_screen(bool no_source)
{
#if CONFIG_CODEC != SWCODEC
peak_meter_playback(true);
peak_meter_enabled = false;
peak_meter_enable(false);
#endif
done = 1;
}