From ce3f0f46778ca03a63f1abcd99b301f9a0ae346a Mon Sep 17 00:00:00 2001 From: sideral Date: Mon, 9 May 2011 12:59:46 +0000 Subject: [PATCH] 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 ++++ apps/misc.c | 17 +++++++---------- docs/CREDITS | 1 + 4 files changed, 31 insertions(+), 18 deletions(-) diff --git a/apps/gui/wps.c b/apps/gui/wps.c index 069df09c3..cf6ec2deb 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 7438f1ac7..87a5a2348 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); diff --git a/apps/misc.c b/apps/misc.c index 12d0c8d95..d72d7a4da 100644 --- a/apps/misc.c +++ b/apps/misc.c @@ -454,10 +454,7 @@ static void car_adapter_mode_processing(bool inserted) if ((audio_status() & AUDIO_STATUS_PLAY) && !(audio_status() & AUDIO_STATUS_PAUSE)) { - if (global_settings.fade_on_stop) - fade(false, false); - else - audio_pause(); + pause_action(true, true); } waiting_to_resume_play = false; } @@ -495,18 +492,18 @@ static void unplug_change(bool inserted) int audio_stat = audio_status(); if (inserted) { + backlight_on(); if ((audio_stat & AUDIO_STATUS_PLAY) && headphone_caused_pause && global_settings.unplug_mode > 1 ) - audio_resume(); - backlight_on(); + unpause_action(true, true); headphone_caused_pause = false; } else { if ((audio_stat & AUDIO_STATUS_PLAY) && !(audio_stat & AUDIO_STATUS_PAUSE)) { headphone_caused_pause = true; - audio_pause(); + pause_action(false, false); if (global_settings.unplug_rw) { @@ -584,7 +581,7 @@ long default_event_handler_ex(long event, void (*callback)(void *), void *parame return SYS_CHARGER_DISCONNECTED; case SYS_CAR_ADAPTER_RESUME: - audio_resume(); + unpause_action(true, true); return SYS_CAR_ADAPTER_RESUME; #endif #ifdef HAVE_HOTSWAP_STORAGE_AS_MAIN @@ -661,9 +658,9 @@ long default_event_handler_ex(long event, void (*callback)(void *), void *parame if (status & AUDIO_STATUS_PLAY) { if (status & AUDIO_STATUS_PAUSE) - audio_resume(); + unpause_action(true, true); else - audio_pause(); + pause_action(true, true); } else if (playlist_resume() != -1) diff --git a/docs/CREDITS b/docs/CREDITS index c1a611e84..ab2a061d3 100644 --- a/docs/CREDITS +++ b/docs/CREDITS @@ -594,6 +594,7 @@ Sergiu Rotaru NoƩ Lojkine Ophir Lojkine Stephan Grossklass +John Morris The libmad team The wavpack team -- 2.11.4.GIT