diff options
author | Michael Hohmuth <sideral@rockbox.org> | 2011-05-09 12:59:46 +0000 |
---|---|---|
committer | Michael Hohmuth <sideral@rockbox.org> | 2011-05-09 12:59:46 +0000 |
commit | 84301c1e2de731099222dee991af8ef957cfecc5 (patch) | |
tree | 22950555d0d400e6a7d377495ae7ca55eb751ed9 /apps | |
parent | 9b7027232f2cab49e4854d56651388cf6c1461f0 (diff) | |
download | rockbox-84301c1e2de731099222dee991af8ef957cfecc5.tar.gz rockbox-84301c1e2de731099222dee991af8ef957cfecc5.zip |
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
Diffstat (limited to 'apps')
-rw-r--r-- | apps/gui/wps.c | 27 | ||||
-rw-r--r-- | apps/gui/wps.h | 4 | ||||
-rw-r--r-- | apps/misc.c | 17 |
3 files changed, 30 insertions, 18 deletions
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) | |||
119 | return skin_buf[screen]; | 119 | return skin_buf[screen]; |
120 | } | 120 | } |
121 | 121 | ||
122 | void pause_action(bool may_fade, bool updatewps) | ||
123 | { | ||
124 | int32_t newpos; | ||
125 | if (may_fade && global_settings.fade_on_stop) | ||
126 | fade(false, updatewps); | ||
127 | else | ||
128 | audio_pause(); | ||
129 | } | ||
130 | |||
131 | void unpause_action(bool may_fade, bool updatewps) | ||
132 | { | ||
133 | if (may_fade && global_settings.fade_on_stop) | ||
134 | fade(true, updatewps); | ||
135 | else | ||
136 | audio_resume(); | ||
137 | } | ||
138 | |||
122 | void fade(bool fade_in, bool updatewps) | 139 | void fade(bool fade_in, bool updatewps) |
123 | { | 140 | { |
124 | int fp_global_vol = global_settings.volume << 8; | 141 | int fp_global_vol = global_settings.volume << 8; |
@@ -667,18 +684,12 @@ void wps_do_playpause(bool updatewps) | |||
667 | if ( state->paused ) | 684 | if ( state->paused ) |
668 | { | 685 | { |
669 | state->paused = false; | 686 | state->paused = false; |
670 | if ( global_settings.fade_on_stop ) | 687 | unpause_action(true, updatewps); |
671 | fade(true, updatewps); | ||
672 | else | ||
673 | audio_resume(); | ||
674 | } | 688 | } |
675 | else | 689 | else |
676 | { | 690 | { |
677 | state->paused = true; | 691 | state->paused = true; |
678 | if ( global_settings.fade_on_stop ) | 692 | pause_action(true, updatewps); |
679 | fade(false, updatewps); | ||
680 | else | ||
681 | audio_pause(); | ||
682 | settings_save(); | 693 | settings_save(); |
683 | #if !defined(HAVE_RTC_RAM) && !defined(HAVE_SW_POWEROFF) | 694 | #if !defined(HAVE_RTC_RAM) && !defined(HAVE_SW_POWEROFF) |
684 | call_storage_idle_notifys(true); /* make sure resume info is saved */ | 695 | 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); | |||
30 | 30 | ||
31 | void gui_sync_wps_init(void) INIT_ATTR; | 31 | void gui_sync_wps_init(void) INIT_ATTR; |
32 | 32 | ||
33 | /* fade (if enabled) and pause the audio, optionally rewind a little */ | ||
34 | void pause_action(bool may_fade, bool updatewps); | ||
35 | void unpause_action(bool may_fade, bool updatewps); | ||
36 | |||
33 | /* fades the volume, e.g. on pause or stop */ | 37 | /* fades the volume, e.g. on pause or stop */ |
34 | void fade(bool fade_in, bool updatewps); | 38 | void fade(bool fade_in, bool updatewps); |
35 | 39 | ||
diff --git a/apps/misc.c b/apps/misc.c index 12d0c8d95a..d72d7a4da0 100644 --- a/apps/misc.c +++ b/apps/misc.c | |||
@@ -454,10 +454,7 @@ static void car_adapter_mode_processing(bool inserted) | |||
454 | if ((audio_status() & AUDIO_STATUS_PLAY) && | 454 | if ((audio_status() & AUDIO_STATUS_PLAY) && |
455 | !(audio_status() & AUDIO_STATUS_PAUSE)) | 455 | !(audio_status() & AUDIO_STATUS_PAUSE)) |
456 | { | 456 | { |
457 | if (global_settings.fade_on_stop) | 457 | pause_action(true, true); |
458 | fade(false, false); | ||
459 | else | ||
460 | audio_pause(); | ||
461 | } | 458 | } |
462 | waiting_to_resume_play = false; | 459 | waiting_to_resume_play = false; |
463 | } | 460 | } |
@@ -495,18 +492,18 @@ static void unplug_change(bool inserted) | |||
495 | int audio_stat = audio_status(); | 492 | int audio_stat = audio_status(); |
496 | if (inserted) | 493 | if (inserted) |
497 | { | 494 | { |
495 | backlight_on(); | ||
498 | if ((audio_stat & AUDIO_STATUS_PLAY) && | 496 | if ((audio_stat & AUDIO_STATUS_PLAY) && |
499 | headphone_caused_pause && | 497 | headphone_caused_pause && |
500 | global_settings.unplug_mode > 1 ) | 498 | global_settings.unplug_mode > 1 ) |
501 | audio_resume(); | 499 | unpause_action(true, true); |
502 | backlight_on(); | ||
503 | headphone_caused_pause = false; | 500 | headphone_caused_pause = false; |
504 | } else { | 501 | } else { |
505 | if ((audio_stat & AUDIO_STATUS_PLAY) && | 502 | if ((audio_stat & AUDIO_STATUS_PLAY) && |
506 | !(audio_stat & AUDIO_STATUS_PAUSE)) | 503 | !(audio_stat & AUDIO_STATUS_PAUSE)) |
507 | { | 504 | { |
508 | headphone_caused_pause = true; | 505 | headphone_caused_pause = true; |
509 | audio_pause(); | 506 | pause_action(false, false); |
510 | 507 | ||
511 | if (global_settings.unplug_rw) | 508 | if (global_settings.unplug_rw) |
512 | { | 509 | { |
@@ -584,7 +581,7 @@ long default_event_handler_ex(long event, void (*callback)(void *), void *parame | |||
584 | return SYS_CHARGER_DISCONNECTED; | 581 | return SYS_CHARGER_DISCONNECTED; |
585 | 582 | ||
586 | case SYS_CAR_ADAPTER_RESUME: | 583 | case SYS_CAR_ADAPTER_RESUME: |
587 | audio_resume(); | 584 | unpause_action(true, true); |
588 | return SYS_CAR_ADAPTER_RESUME; | 585 | return SYS_CAR_ADAPTER_RESUME; |
589 | #endif | 586 | #endif |
590 | #ifdef HAVE_HOTSWAP_STORAGE_AS_MAIN | 587 | #ifdef HAVE_HOTSWAP_STORAGE_AS_MAIN |
@@ -661,9 +658,9 @@ long default_event_handler_ex(long event, void (*callback)(void *), void *parame | |||
661 | if (status & AUDIO_STATUS_PLAY) | 658 | if (status & AUDIO_STATUS_PLAY) |
662 | { | 659 | { |
663 | if (status & AUDIO_STATUS_PAUSE) | 660 | if (status & AUDIO_STATUS_PAUSE) |
664 | audio_resume(); | 661 | unpause_action(true, true); |
665 | else | 662 | else |
666 | audio_pause(); | 663 | pause_action(true, true); |
667 | } | 664 | } |
668 | else | 665 | else |
669 | if (playlist_resume() != -1) | 666 | if (playlist_resume() != -1) |