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
This commit is contained in:
Björn Stenberg 2003-10-17 14:05:32 +00:00
parent fb067481a8
commit 3953211531
2 changed files with 27 additions and 11 deletions

View File

@ -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')

View File

@ -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
{