Rockbox Technical Forums

Support and General Use => Audio Playback, Database and Playlists => Topic started by: MatthewP on April 05, 2010, 05:31:22 AM

Title: Incorrect Resume
Post by: MatthewP on April 05, 2010, 05:31:22 AM
I paused a song, then connected the player to my computer and deleted a different song.  When Rockbox resumed playing, it was on another track.  Is this a known problem?
Title: Re: Incorrect Resume
Post by: AlexP on April 05, 2010, 07:04:09 AM
Yes, as the info stored for resume is an index - i.e. restart at this position in the third track.  If you delete e.g. track 2, then the third track is now track 4.
Title: Re: Incorrect Resume
Post by: MatthewP on April 05, 2010, 05:11:05 PM
Can this be changed so that it uses the filename instead of an index?
Title: Re: Incorrect Resume
Post by: AlexP on April 05, 2010, 05:32:57 PM
It could, and that would be nice I agree - I think the problem here is that the way resume info is stored would need to be rewritten (it isn't just a case of swapping them) and someone needs to do it.

Other things to think about - the filename referenced for resume is deleted, the same file appears multiple times in the playlist...

However, it is a valid bug even if it isn't quite as simple as it first seems to fix :)
Title: Re: Incorrect Resume
Post by: MatthewP on April 11, 2010, 02:53:45 AM
This problem happens even when the file is deleted in Rockbox, when it's not connected to a computer.
Title: Re: Incorrect Resume
Post by: AlexP on April 11, 2010, 05:38:17 AM
This problem happens even when the file is deleted in Rockbox, when it's not connected to a computer.

Yes, for the same reason.
Title: Re: Incorrect Resume
Post by: MatthewP on April 12, 2010, 02:41:10 PM
When a delete happens outside the player Rockbox doesn't know it needs to update the index.  But when it's done on the player Rockbox should update the index when the delete function is executed.
Title: Re: Incorrect Resume
Post by: GodEater on April 13, 2010, 03:13:08 AM
Yes, but the delete function does do this, as it has no way to know that the file you're deleting is currently being used in a playlist.
Title: Re: Incorrect Resume
Post by: MatthewP on April 15, 2010, 03:40:44 AM
If the original firmware can manage this, Rockbox should also.  When a delete is performed, just search the playlists for references to the deleted file.  If it's there, remove it.
Title: Re: Incorrect Resume
Post by: Llorean on April 15, 2010, 05:11:42 AM
You seem to have missed the point - the problem is that the file isn't referenced in the playlist.

Basically, the playlist says "the third file in the directory" rather than a specific filename - it's an index. Since playback is stopped at the time anyway, we don't know if the third file in the directory is still the same one it used to be (they could've had file added, or other files deleted) so when the user deletes the file, it can't know which index in the dynamic playlist is the right one to delete.

You'll notice static playlists (which have filenames in them) don't present this problem - a missing file will simply be skipped over.


If you think it's easy to identify reliably whether the file was removed and handle it in the case of such dynamic playlists, though, feel free to submit a patch. Maybe something's been overlooked.
Title: Re: Incorrect Resume
Post by: MatthewP on April 19, 2010, 06:13:25 PM
Is the dynamic playlist directory in .playlist_control?  And the index in nvram.bin?  I'm not a developer but wouldn't something like this work?:

// pseudocode
delete_dir =  directory of file being deleted
playlist_dir = dynamic playlist directory in .playlist_control
if delete_dir = playlist_dir // deleting a file in the dynamic playlist
{
    decrement playlist count // update # of playlist entries
    if delete file index < playlist index
    {
         decrement playlist index // deleted file is before current file so update current position to reflect deleted file
    }
}
Title: Re: Incorrect Resume
Post by: MatthewP on April 30, 2010, 02:46:32 AM
Does anyone have the time and know-how to implement this?
Title: Re: Incorrect Resume
Post by: Llorean on April 30, 2010, 03:03:32 AM
I don't see how that solves the problem in your first post - if you deleted the file from the computer, how does Rockbox know it's missing exactly? Your pseudocode doesn't cover that at all.

As well, this would require the filetree code to know things about playback status, and depend on them. Generally it's beneficial not to have too many dependencies between separate areas. It can lead to new and stranger bugs.

It also doesn't address the situation of added files, or renamed files, or any other way in which the contents of the folder could be changed. For example, if I add two files from my PC then delete one on Rockbox, your code would have it move the index making the resume point even more wrong.

The simplest solution would be to make it clear in the manual that when folder playback is started, if the folder contents change, resume could be inaccurate, and not try to add any special magic that can muck up the code any worse. Since there is no way for it to be reliably accurate, being up front about it is basically the best you can offer.

 If it's really a problem, figure out a way to get the speed of index based playlisting, but actually store the filenames for verification purposes.
Title: Re: Incorrect Resume
Post by: MatthewP on May 03, 2010, 01:37:30 AM
It doesn't solve the problem initially presented.  But the solution is still useful because I still need to delete many files through Rockbox.  This is not a issue with any other DAP's original firmware, so I'm surprised that Rockbox can't handle such a simple use case.
Title: Re: Incorrect Resume
Post by: Yotto on May 03, 2010, 06:13:57 AM
A simple, non-programming solution is to not use the resume function.

Turn on bookmarks, and when you stop your music and hook your player to the computer, the bookmark will still load the correct file no matter what you do to the files. Unless you delete the file you were listening to, of course. Bookmarks don't like that too much.

Personally, I wish that the user could define "resume" as "Load last bookmark" instead of what it is now, but as a non-programmer I have no clue how to do it myself. I also have no expectations that "what I want" be "what is put in Rockbox" :)
Title: Re: Incorrect Resume
Post by: Llorean on May 03, 2010, 11:47:28 AM
It doesn't solve the problem initially presented.  But the solution is still useful because I still need to delete many files through Rockbox.  This is not a issue with any other DAP's original firmware, so I'm surprised that Rockbox can't handle such a simple use case.

Many OFs don't allow you to delete files. Many others force the use of a database (look how long the e200 requires you to wait on bootup for it to scan and create its database before you can use it if it's in MSC mode). Many other take quite a while to recreate the playlist.

Simply put, yes, some other OFs may avoid this issue, but at other various costs of their own. Meanwhile, it's trivial for you to avoid this issue by either bookmarking or re-selecting the file to resume from, while the advantages of the way things are done exist for people who don't delete these files.

Honestly, if you need to delete many files through Rockbox while still listening to files in their folder, maybe you should examine your use habits. Perhaps try putting songs you know you like in a separate folder from the songs you're considering deleting in the first place.

Or the most obvious and simple solution - instead of simply playing a file in the folder, quickly create a playlist of it through the context menu and play that. This takes a few seconds more, but will not suffer the problem you're describing.

Or use the database.

Basically, there's a list of solutions to your problem, so I don't see why you're focusing on the one solution that requires additional work be done, and takes certain existing advantages away from people who don't for whatever reason apparently frequently find themselves deleting files.
Title: Re: Incorrect Resume
Post by: torne on May 03, 2010, 12:52:05 PM
Personally, I wish that the user could define "resume" as "Load last bookmark" instead of what it is now, but as a non-programmer I have no clue how to do it myself.
This wouldn't be that difficult, as long as you had "Maintain a list of recent bookmarks" enabled; it could just load the most recent one from that list. Of course, you can already do this manually by just picking Recent Bookmarks from the menu and then hitting select again, since the most recent one is selected by default :)
Title: Re: Incorrect Resume
Post by: Yotto on May 03, 2010, 05:44:06 PM
Personally, I wish that the user could define "resume" as "Load last bookmark" instead of what it is now, but as a non-programmer I have no clue how to do it myself.
This wouldn't be that difficult, as long as you had "Maintain a list of recent bookmarks" enabled; it could just load the most recent one from that list. Of course, you can already do this manually by just picking Recent Bookmarks from the menu and then hitting select again, since the most recent one is selected by default :)
Yeah, I know. It'd just give me a reason to hit Play (on iPod) on startup sometimes. It's the lazy man in me who wants to avoid hitting "Select" twice :)

But by now I've put more effort into explaining it than I'd ever save with its implementation :) so I'm officially dropping it.
Title: Re: Incorrect Resume
Post by: MatthewP on May 07, 2010, 10:21:50 PM
I tried using Bookmarks but it didn't work quite right.  I had Bookmark on Stop set to Yes, Load Last Bookmark set to Yes, but it didn't start in the right place.  After some experimenting with the different combinations of Unique, Recent Only, and Maintain a list of Recently Used Bookmarks settings I've finally got it close to what many people here are trying to do--use bookmarks to replace the broken resume feature.  If only Rockbox could load the bookmark and start playing the song without requiring me to select the bookmark first.  This shouldn't be necessary as there is only one.  An option to automatically play the last bookmark would be nice.  Maybe a kind soul will add this some day.