diff options
Diffstat (limited to 'firmware')
-rw-r--r-- | firmware/powermgmt.c | 24 |
1 files changed, 17 insertions, 7 deletions
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) | |||
306 | #endif | 306 | #endif |
307 | !usb_inserted() && | 307 | !usb_inserted() && |
308 | (mpeg_stat == 0 || | 308 | (mpeg_stat == 0 || |
309 | mpeg_stat == (MPEG_STATUS_PLAY | MPEG_STATUS_PAUSE))) | 309 | (mpeg_stat == (MPEG_STATUS_PLAY | MPEG_STATUS_PAUSE)) && |
310 | !sleeptimer_active)) | ||
310 | { | 311 | { |
311 | if(TIME_AFTER(current_tick, last_keypress + timeout) && | 312 | if(TIME_AFTER(current_tick, last_keypress + timeout) && |
312 | TIME_AFTER(current_tick, last_disk_activity + timeout) && | 313 | TIME_AFTER(current_tick, last_disk_activity + timeout)) |
313 | TIME_AFTER(current_tick, last_charge_time + timeout)) | 314 | { |
314 | power_off(); | 315 | if (mpeg_stat == (MPEG_STATUS_PLAY | MPEG_STATUS_PAUSE)) |
316 | { | ||
317 | mpeg_stop(); | ||
318 | } | ||
319 | |||
320 | if (TIME_AFTER(current_tick, last_charge_time + timeout)) | ||
321 | { | ||
322 | power_off(); | ||
323 | } | ||
324 | } | ||
315 | } | 325 | } |
316 | else | 326 | else |
317 | { | 327 | { |
318 | /* Handle sleeptimer */ | 328 | /* Handle sleeptimer */ |
319 | if(sleeptimer_endtick && | 329 | if(sleeptimer_active && !usb_inserted()) |
320 | !usb_inserted()) | ||
321 | { | 330 | { |
322 | if(TIME_AFTER(current_tick, sleeptimer_endtick)) | 331 | if(TIME_AFTER(current_tick, sleeptimer_endtick)) |
323 | { | 332 | { |
333 | mpeg_stop(); | ||
324 | if(charger_is_inserted) | 334 | if(charger_is_inserted) |
325 | { | 335 | { |
326 | DEBUGF("Sleep timer timeout. Stopping...\n"); | 336 | DEBUGF("Sleep timer timeout. Stopping...\n"); |
327 | mpeg_stop(); | 337 | set_sleep_timer(0); |
328 | } | 338 | } |
329 | else | 339 | else |
330 | { | 340 | { |