FS#8187 - Charging from USB breaks sleep timer

Attached to Project: Rockbox
Opened by PaulJam (PaulJam) - Monday, 19 November 2007, 14:03 GMT
Last edited by Jonathan Gordon (jdgordon) - Sunday, 29 June 2008, 09:44 GMT
Task Type Bugs
Category Battery/Charging
Status Closed
Assigned To No-one
Operating System All players
Severity Low
Priority Normal
Reported Version Daily build (which?)
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No


When the sleep timer is set and the device is charging via USB then nothing happens when the countdown reaches 0:00. Playback continues and the timer continues to count down (the %bs WPS tag returns negative values like -12:-34).
As soon as the USB calble gets disconnected the device shuts down.

While charging from the normal A/C adapter everything works (more or less*) as expected:
When the countdown is over playback stops and the backlight/screen turns off.

The problem was reported on IRC for an Ipod (no exact model mentioned) and was reproduceable on an H300 with r15682.

* - There is a delay between the timer reaching 0:00 and the device actually shutting down (i experienced ~30 seconds delay with a 2 hour sleep timer) but this is not a big issue.
This task depends upon

Closed by  Jonathan Gordon (jdgordon)
Sunday, 29 June 2008, 09:44 GMT
Reason for closing:  Fixed
Additional comments about closing:  patch worked... commited
Comment by Bryan Stine (Battousai) - Thursday, 14 February 2008, 08:01 GMT
I can confirm this behavior on e200 as well.

The issue seems to be at line 545 of current SVN's (r16309) firmware/powermgmt.c:
if(sleeptimer_active && !usb_inserted())

Removing the usb_inserted() condition allows the sleep timer to trigger and stop the audio (I believe pp502x devices should stay powered on while the charger is inserted).

I'm definitely not very familiar with rockbox code or all the platforms it supports, so I don't know (and rather doubt) that removing that usb_inserted() condition is the correct solution, or whether the logic within the function itself leads to the endless countdown.
Comment by carl (locketine) - Saturday, 16 February 2008, 20:08 GMT
they obviously had a reason to put that there so maybe that check needs to be expanded to include a device check for those players that can't be shut off while charging. I also noticed that I can't turn off my e200 while it's plugged into usb; is this caused by that same line of code as well?
Comment by Nathan Hartley (TreeStryder) - Monday, 25 February 2008, 03:15 GMT
If it matters, the wife of this e200 owner would like the sleep timer to at least stop playback.

Me, I'm more worried about the battery over charging.
Comment by Jonathan Gordon (jdgordon) - Sunday, 29 June 2008, 08:26 GMT
this should fix it... please test it out