This is the bug/patch tracker for Rockbox. Click here for more information.
Quick links: Bugs · Patches · Rockbox frontpage
FS#9822 - RB sometimes forgets where it is in a playlist and that shuffle is on
|
DetailsSometimes when I shut my unit off and then turn it on again and resume playback, RB resumes from a different place than where it left off, and even though when I resume shuffle is on (as indicated by its icon), it isn't. It'll play the current track, then the next track in the playlist (which in my case is in order by track number, so it'll play the next track on the album), and so on.
If I turn shuffle off and then on again, shuffle works correctly again. I'm using a build from January 19 (19800-090119) on an Archos Recorder. I noticed this bug occurring in the 3.1 build as well. It seems to happen randomly -- I can't figure out anything specifically that I can do to always make it happen. |
This task depends upon
Some discussion about it here:
http://forums.rockbox.org/index.php?topic=20016.0
If you can get yourself a working compiler, you should be able to work out exactly which change broke this. Given that you can reliably repro the problem that would seem a good way forward.
Read http://www.rockbox.org/twiki/bin/view/Main/SimpleGuideToCompiling for Windows, or http://www.rockbox.org/twiki/bin/view/Main/LinuxSimpleGuideToCompiling for Linux if you need help.
According to info in that, this commit was the start of the problem:
http://svn.rockbox.org/viewvc.cgi?view=rev;revision=18561
And it was supposed to be fixed here:
http://svn.rockbox.org/viewvc.cgi?view=rev;revision=19723
But perhaps it didn't?
FS#9408in http://svn.rockbox.org/viewvc.cgi?view=rev;revision=18555 and then the first index was removed in http://svn.rockbox.org/viewvc.cgi?view=rev;revision=18561 (as stated above by zipr).Targets with dircache have playlist_flush_callback(). It is registered as a storage idle function, and so the playlist control file is flushed when the disk spins down or when the idle functions are explicitly called. Targets without dircache only flush the playlist control file when other changes are made to the playlist, or when playlist_shutdown() is called at shutdown or USB connect time. I have verified that the shuffle line is added to the playlist control file at shutdown on my V2 Recorder. However, resume is still wrong after that.
To make Archos targets remember shuffle mode, I see two options:
1) Ensure that .playlist_control is flushed, maybe via playlist_flush_callback
2) Store the information in NVRAM like before. This means reverting
FS#9408and related commits. Preprocessor directives could be added, so the code is only used on some targets.http://download.rockbox.org/manual/rockbox-recorder/rockbox-buildch3.html#x5-240003.1.2
In the sim, a single press of OFF causes "Press OFF to shut down" to be displayed. This message might mislead some people into holding OFF. It should say something like "Press OFF again to shut down". Holding off forces a shutdown or a reboot; only do that if the device is locked up.
When Rockbox shuts down cleanly, the playlist control file should be written to disk. After powering up, resume should work properly even now. The only exception is if the battery is so low that disk writes are considered unsafe. That would be when the battery icon is blinking.
With option 1, any new .playlist_control data would be written to disk before the next disk spindown. For example, if you enable shuffle, that's not saved immediately; the next buffer filling saves it. I think this is good enough. It will only fail if the Recorder is shut down before that happens, and the shutdown is forced or battery level is unsafe.
I like option 1 because it seems I could then remove all explicit .playlist_control flushing and let the storage idle function take care of it. This would simplify code and reduce code size. That would be a separate patch, after this bug has been fixed via option 1.
Here's how flushing of playlist control lines which don't have to be flushed immediately and syncing of the playlist control file happens:
- If storage idle callbacks exist, then playlist_flush_callback() is registered when lines are added and it runs the next time those callbacks run.
- If the callbacks don't exist, but dircache exists, playlist_thread() periodically calls playlist_flush_callback(). (Dircache does not need to be enabled for this.)
- If there are no callbacks and no dircache, each line is flushed and synced immediately. This leads to correct resuming but it is not good. It results in multiple flash writes for every line, and it makes other code redundant. This case only happens on iFP7xx and sims without dircache. I put a TODO in the patch. Maybe the best solution is to have a minimal playlist_thread() periodically flush and sync.
If flushes can be delayed, a flush is performed when resuming. This ensures that the resumed playlist is up to date.