1
0
Fork 0
forked from len0rd/rockbox

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; 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) switch(button)
{ {
case BUTTON_ON: case BUTTON_ON:
@ -882,10 +888,6 @@ int wps_show(void)
if (menu()) if (menu())
return SYS_USB_CONNECTED; return SYS_USB_CONNECTED;
/* if user recorded, playback is stopped and we should exit */
if (!mpeg_status())
exit = true;
restore = true; restore = true;
break; break;
@ -947,6 +949,10 @@ int wps_show(void)
mpeg_stop(); mpeg_stop();
status_set_playmode(STATUS_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 */ /* set dir browser to current playing song */
if (global_settings.browse_current && if (global_settings.browse_current &&
current_track_path[0] != '\0') current_track_path[0] != '\0')

View file

@ -306,25 +306,35 @@ static void handle_auto_poweroff(void)
#endif #endif
!usb_inserted() && !usb_inserted() &&
(mpeg_stat == 0 || (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) && if(TIME_AFTER(current_tick, last_keypress + timeout) &&
TIME_AFTER(current_tick, last_disk_activity + timeout) && TIME_AFTER(current_tick, last_disk_activity + timeout))
TIME_AFTER(current_tick, last_charge_time + timeout)) {
power_off(); if (mpeg_stat == (MPEG_STATUS_PLAY | MPEG_STATUS_PAUSE))
{
mpeg_stop();
}
if (TIME_AFTER(current_tick, last_charge_time + timeout))
{
power_off();
}
}
} }
else else
{ {
/* Handle sleeptimer */ /* Handle sleeptimer */
if(sleeptimer_endtick && if(sleeptimer_active && !usb_inserted())
!usb_inserted())
{ {
if(TIME_AFTER(current_tick, sleeptimer_endtick)) if(TIME_AFTER(current_tick, sleeptimer_endtick))
{ {
mpeg_stop();
if(charger_is_inserted) if(charger_is_inserted)
{ {
DEBUGF("Sleep timer timeout. Stopping...\n"); DEBUGF("Sleep timer timeout. Stopping...\n");
mpeg_stop(); set_sleep_timer(0);
} }
else else
{ {