From cf42dd6b1256a4228cb9f37a3a6bbff7954020b4 Mon Sep 17 00:00:00 2001 From: Christian Soffke Date: Sat, 1 Feb 2025 15:19:00 +0100 Subject: [PATCH] powermgmt: adjust sleep timer behavior Responding to the bug report posted by iPodVT: https://forums.rockbox.org/index.php/topic,55180.msg255292 - An active sleep timer that runs out will now cause the player to shut down regardless of playback state - When playback state is paused or stopped, once the idle timer has run out, player will shut down, regardless of any running sleep timer Change-Id: I33de682a63ed1db76174eb2394ef5568f37cc677 --- firmware/powermgmt.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/firmware/powermgmt.c b/firmware/powermgmt.c index 1ec1a9eb5b..3405c75a20 100644 --- a/firmware/powermgmt.c +++ b/firmware/powermgmt.c @@ -990,10 +990,6 @@ void set_keypress_restarts_sleep_timer(bool enable) #ifndef BOOTLOADER static void handle_sleep_timer(void) { - if (!sleeptimer_active) - return; - - /* Handle sleeptimer */ if (TIME_AFTER(current_tick, sleeptimer_endtick)) { if (usb_inserted() #if CONFIG_CHARGING && !defined(HAVE_POWEROFF_WHILE_CHARGING) @@ -1055,9 +1051,8 @@ void handle_auto_poweroff(void) #endif !usb_inserted() && (audio_stat == 0 || - (audio_stat == (AUDIO_STATUS_PLAY | AUDIO_STATUS_PAUSE) && - !sleeptimer_active))) { - + audio_stat == (AUDIO_STATUS_PLAY | AUDIO_STATUS_PAUSE))) + { if (TIME_AFTER(tick, last_event_tick + timeout) #if !(CONFIG_PLATFORM & PLATFORM_HOSTED) && TIME_AFTER(tick, storage_last_disk_activity() + timeout) @@ -1065,7 +1060,9 @@ void handle_auto_poweroff(void) ) { sys_poweroff(); } - } else + } + + if (sleeptimer_active) handle_sleep_timer(); #endif }