From 3953211531b382ad23b82f35223c0ca82ed9814f Mon Sep 17 00:00:00 2001 From: Björn Stenberg Date: Fri, 17 Oct 2003 14:05:32 +0000 Subject: Fixes sleep timer when connected to charger (patch #769591 by Henrik Backe) git-svn-id: svn://svn.rockbox.org/rockbox/trunk@3975 a1c6a512-1295-4272-9138-f99709370657 --- apps/wps.c | 14 ++++++++++---- firmware/powermgmt.c | 24 +++++++++++++++++------- 2 files changed, 27 insertions(+), 11 deletions(-) diff --git a/apps/wps.c b/apps/wps.c index d41413c179..f34ec81d9c 100644 --- a/apps/wps.c +++ b/apps/wps.c @@ -738,6 +738,12 @@ int wps_show(void) continue; } + /* Exit if mpeg has stopped playing. This can happen if using the + sleep timer with the charger plugged or if starting a recording + from F1 */ + if (!mpeg_status()) + exit = true; + switch(button) { case BUTTON_ON: @@ -882,10 +888,6 @@ int wps_show(void) if (menu()) return SYS_USB_CONNECTED; - /* if user recorded, playback is stopped and we should exit */ - if (!mpeg_status()) - exit = true; - restore = true; break; @@ -947,6 +949,10 @@ int wps_show(void) mpeg_stop(); status_set_playmode(STATUS_STOP); + /* Keys can be locked when exiting, so either unlock here + or implement key locking in tree.c too */ + keys_locked=false; + /* set dir browser to current playing song */ if (global_settings.browse_current && current_track_path[0] != '\0') diff --git a/firmware/powermgmt.c b/firmware/powermgmt.c index e4cdcde300..21ccddf301 100644 --- a/firmware/powermgmt.c +++ b/firmware/powermgmt.c @@ -306,25 +306,35 @@ static void handle_auto_poweroff(void) #endif !usb_inserted() && (mpeg_stat == 0 || - mpeg_stat == (MPEG_STATUS_PLAY | MPEG_STATUS_PAUSE))) + (mpeg_stat == (MPEG_STATUS_PLAY | MPEG_STATUS_PAUSE)) && + !sleeptimer_active)) { if(TIME_AFTER(current_tick, last_keypress + timeout) && - TIME_AFTER(current_tick, last_disk_activity + timeout) && - TIME_AFTER(current_tick, last_charge_time + timeout)) - power_off(); + TIME_AFTER(current_tick, last_disk_activity + timeout)) + { + if (mpeg_stat == (MPEG_STATUS_PLAY | MPEG_STATUS_PAUSE)) + { + mpeg_stop(); + } + + if (TIME_AFTER(current_tick, last_charge_time + timeout)) + { + power_off(); + } + } } else { /* Handle sleeptimer */ - if(sleeptimer_endtick && - !usb_inserted()) + if(sleeptimer_active && !usb_inserted()) { if(TIME_AFTER(current_tick, sleeptimer_endtick)) { + mpeg_stop(); if(charger_is_inserted) { DEBUGF("Sleep timer timeout. Stopping...\n"); - mpeg_stop(); + set_sleep_timer(0); } else { -- cgit v1.2.3