From 84301c1e2de731099222dee991af8ef957cfecc5 Mon Sep 17 00:00:00 2001 From: Michael Hohmuth Date: Mon, 9 May 2011 12:59:46 +0000 Subject: FS#11931 part 1: Make fade in/out behavior more consistent across the various causes of pause and unpause. Patch by John Morris. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29844 a1c6a512-1295-4272-9138-f99709370657 --- apps/gui/wps.c | 27 +++++++++++++++++++-------- apps/gui/wps.h | 4 ++++ 2 files changed, 23 insertions(+), 8 deletions(-) (limited to 'apps/gui') diff --git a/apps/gui/wps.c b/apps/gui/wps.c index 069df09c36..cf6ec2deb4 100644 --- a/apps/gui/wps.c +++ b/apps/gui/wps.c @@ -119,6 +119,23 @@ char* wps_default_skin(enum screen_type screen) return skin_buf[screen]; } +void pause_action(bool may_fade, bool updatewps) +{ + int32_t newpos; + if (may_fade && global_settings.fade_on_stop) + fade(false, updatewps); + else + audio_pause(); +} + +void unpause_action(bool may_fade, bool updatewps) +{ + if (may_fade && global_settings.fade_on_stop) + fade(true, updatewps); + else + audio_resume(); +} + void fade(bool fade_in, bool updatewps) { int fp_global_vol = global_settings.volume << 8; @@ -667,18 +684,12 @@ void wps_do_playpause(bool updatewps) if ( state->paused ) { state->paused = false; - if ( global_settings.fade_on_stop ) - fade(true, updatewps); - else - audio_resume(); + unpause_action(true, updatewps); } else { state->paused = true; - if ( global_settings.fade_on_stop ) - fade(false, updatewps); - else - audio_pause(); + pause_action(true, updatewps); settings_save(); #if !defined(HAVE_RTC_RAM) && !defined(HAVE_SW_POWEROFF) call_storage_idle_notifys(true); /* make sure resume info is saved */ diff --git a/apps/gui/wps.h b/apps/gui/wps.h index 7438f1ac7b..87a5a23487 100644 --- a/apps/gui/wps.h +++ b/apps/gui/wps.h @@ -30,6 +30,10 @@ void wps_data_load(enum screen_type, const char *, bool); void gui_sync_wps_init(void) INIT_ATTR; +/* fade (if enabled) and pause the audio, optionally rewind a little */ +void pause_action(bool may_fade, bool updatewps); +void unpause_action(bool may_fade, bool updatewps); + /* fades the volume, e.g. on pause or stop */ void fade(bool fade_in, bool updatewps); -- cgit v1.2.3