Rockbox

This is the bug/patch tracker for Rockbox. Click here for more information.

Quick links: Bugs · Patches · Rockbox frontpage

Tasklist

FS#8206 - Resuming playback from end of song after power on confuses playback

Attached to Project: Rockbox
Opened by Richard Sweeney (riksweeney) - Wednesday, 21 November 2007, 20:31 GMT+1
Last edited by Nils Wallménius (nls) - Wednesday, 12 November 2008, 15:56 GMT+1
Task Type Bugs
Category Music playback
Status Assigned   Reopened
Assigned To Nicolas Pennequin (nicolas_p)
Player type All players
Severity Low
Priority Normal
Reported Version current build
Due in Version Version 3.1
Due Date Undecided
Percent Complete 0%
Private No

Details

Resuming playback of a song that is a few seconds from ending after the player has been powered on confuses the playback.

The simplest way to reproduce this behaviour is to do the following (this works in the simulator too).

Select a song to play and let it play almost to the very end, make sure that another song is in the playlist to be played afterwards.

A few seconds before the end of the song, stop the playback and then shutdown Rockbox.

Start up Rockbox and resume playback. The playback will continue from half to three quarters of the way through the following song on the playlist.

This appears to be buffer related as fast forwarding to the end of the song, shutting down and resuming will not produce this behaviour.
This task depends upon

Comment by Nicolas Pennequin (nicolas_p) - Tuesday, 27 November 2007, 17:35 GMT+1
This seems to be another manifestation of the issue causing  FS#2687 ... I think the problem is that you shut down the player in the middle of a track transition.
Comment by Richard Sweeney (riksweeney) - Tuesday, 27 November 2007, 19:26 GMT+1
I think it is too, a fairly old build that I use at the moment doesn't exhibit this behaviour so I might download that revision and examine it. It's revision 15812 if you're interested...
Comment by Richard Sweeney (riksweeney) - Tuesday, 27 November 2007, 19:44 GMT+1
Oops, tell a lie, it's 13742
Comment by Steve Bavin (pondlife) - Wednesday, 28 November 2007, 13:02 GMT+1
Does it still happen with 15841 or later?
Comment by Richard Sweeney (riksweeney) - Wednesday, 28 November 2007, 22:57 GMT+1
Unfortunately yes, the resuming problem still exists. I have noticed however that simply stopping at the end of the song and resuming playback will also cause this problem.

What I did notice though, is that in apps/playback.c, changing

return &prevtrack_id3;

to

return &curtrack_id3;

on line 525 fix this problem, but the WPS information changes prematurely. I only noticed this because I'd been tinkering with the source code...
Comment by Steve Bavin (pondlife) - Thursday, 29 November 2007, 10:11 GMT+1
The external interfaces to playback.c generally use the "WPS track" rather than the "codec track" transition point and resulting track name and offset (which is a good thing for keeping the UI correct).

audio_current_track() does this, as do the calls to playlist_update_resume_info(). However, when resuming we have an offset passed in to audio_play which is assumed to be based on the "codec track". I can't think of a way for audio_play() to convert a "WPS offset" into a "codec offset", which would be more correct.

Perhaps instead we should base the resume point on the "codec track/offset"?

One other point - shouldn't codec_get_file_pos() should use the "codec track" (i.e not rely on audio_current_track(), maybe just curtrack_id3 would do)?
Comment by Richard Sweeney (riksweeney) - Wednesday, 02 January 2008, 16:57 GMT+1
OK, I've been having a root through the code and have more or less found the problem (IMHO). When the playback enters the transition phase, the playlist index is incremented which means that if you press stop during this period then the resume index will be off by 1. This basically means it'll play the following track using the current track's offset which on the simulator can cause segfaults.

I did code a solution by passing in the transition state into playlist_update_resume_info, but it was messy and hacky. I guess I could add another variable to the mp3entry structure and then tell playlist_update_resume_info in playlist.c to use the previous, rather than the current index of the playlist when saving the resume info.

Something like:

int playlist_update_resume_info(const struct mp3entry* id3)
...
global_status.resume_index = id3->transition == 1 ? playlist->index - 1 : playlist->index;
global_status.resume_offset = id3->offset;
status_save();
...

Bit of a mess though
Comment by Richard Sweeney (riksweeney) - Thursday, 03 January 2008, 20:57 GMT+1
OK, here's a patch based upon the pseudo code I wrote. It appears to work OK but I really need to test it more.

Comment by Alexander Levin (fml2) - Friday, 04 January 2008, 09:09 GMT+1
Why did you introduce a new field in the mp3 struct? IMHO the transition status is something that is 'global' and doesn't belong to a particular track. I.e. it should be a global state var. I don't know where it's placed best though.
Comment by Steve Bavin (pondlife) - Friday, 04 January 2008, 09:25 GMT+1
I'd prefer the transition to be entirely hidden. The playlist->index shouldn't be incremented until the transition is completed (i.e. the WPS has moved on rather than when the codec has moved on). Similar should be true for all variables accessible outside of playback.c.

That sound you hear is a can of worms being opened. ;)
Comment by Richard Sweeney (riksweeney) - Friday, 04 January 2008, 10:51 GMT+1
True, it should probably be a global variable instead, I'm still trying to get my head around the code at the moment. Steve's suggestion of making the playlist increment would probably solve the related problem of "rewinding at the end of a song will rewind the following song rather than the current" as well.

I'll have a look into making the variable global instead.
Comment by Steve Bavin (pondlife) - Friday, 04 January 2008, 11:20 GMT+1
"transition" should NOT be global, it should be only available within playback.c. Where it's used elsewhere, there's probably playback API that could be used instead (e.g. to get the current track).
Comment by Nicolas Pennequin (nicolas_p) - Friday, 04 January 2008, 13:03 GMT+1
I once tried moving the playlist index incrementation to after the track transition (it's in the SVN history), but it broke auto folder advance. I guess we could go back to what I had done and then fix the folder advance.
Comment by Steve Bavin (pondlife) - Friday, 04 January 2008, 13:19 GMT+1
Go for it! ;)
Comment by Nicolas Pennequin (nicolas_p) - Friday, 04 January 2008, 16:57 GMT+1
This patch is an attempt to handle the playlist updating at the right time, i.e. after the track transition for most skips, but before it for manual skips or automatic dir change skips.
I haven't checked if it solves the actual issue described by this task, but I think it will.
Comment by Richard Sweeney (riksweeney) - Friday, 04 January 2008, 18:21 GMT+1
Thanks for the patch, I'll have a look at it when I get in after the pub^H^H^H^H^Hwork
Comment by Nicolas Pennequin (nicolas_p) - Friday, 04 January 2008, 18:49 GMT+1
I just tested and the original issue looks fixed. Please confirm and I'll commit :)
Comment by Richard Sweeney (riksweeney) - Saturday, 05 January 2008, 10:23 GMT+1
Cool, this appears to have solved the problem, I've only tried it on the simulator but I will put this on my iRiver H120 shortly and see how I get on.
Comment by Richard Sweeney (riksweeney) - Saturday, 05 January 2008, 12:55 GMT+1
Actually, it looks like there is a problem with the playback. While I was playing an album it played the same song twice after a short hesitation. It only did it once but I'll test it on the simulator and see if I can make it do it again.
Comment by Nicolas Pennequin (nicolas_p) - Sunday, 06 January 2008, 20:46 GMT+1
Anything new here?
Comment by Richard Sweeney (riksweeney) - Sunday, 06 January 2008, 22:33 GMT+1
I haven't managed to make it play the same track again so I'm not sure what the problem was. The only other issue I noticed was that stopping during the transition and restarting will resume playback from before where the transition started, or maybe a couple of seconds before that, but it doesn't happen on the simulator (I'm using an iRiver H120). Apart from these two issues I haven't seen anything where the playback corrupts or crashes.
Comment by Nicolas Pennequin (nicolas_p) - Monday, 07 January 2008, 00:03 GMT+1
Well I guess I'll commit and wait for the bug reports :)
Comment by Nicolas Pennequin (nicolas_p) - Monday, 07 January 2008, 10:13 GMT+1
Changing playlist_check() had undesirable side-effects. This new version takes a slightly different approach.
Comment by Brian Hall (brihall) - Monday, 07 January 2008, 16:44 GMT+1
I've seen a problem similar to this, I added my comment (copied below) to  FS#6215 .

The reason I think I might be seeing this problem is because after listening to a podcast, I will typically stop playback while the host is making his closing remarks, a few seconds before the end of the file. Then I delete the podcast via rockbox and power off. On power on, rockbox tries to resume the podcast and hangs.


-------------------from  FS#6215 :

I see this frequently with podcasts- I will listen to one, delete it via rockbox, and on the next power-up it hangs when trying to resume the file. It looks like it is selecting the next file, but resuming at the position of the last (deleted) file. In the case of podcasts, the new file might be significantly shorter than the previous, maybe trying to resume far enough after the end of a file causes a hang?

The only way I've found to fix this once it occurs is to delete the playlist control file from a PC connection (reset doesn't help).

Player is a H320. I've seen this problem on multiple builds over the last 3-4 months. Currently running r15989-080103.
Comment by Marc Guay (Marc_Guay) - Friday, 18 April 2008, 01:52 GMT+1
e200 + r17153 = The first time it displayed a lovely cabbiev2 smear across the screen and required a hard shutdown (something I saw randomly earlier today). The second time it did as described in the original report (playing next track 2/3 the way through).
Comment by Marc Guay (Marc_Guay) - Sunday, 13 July 2008, 03:14 GMT+1
e200 + r18013 = Still happening.

Loading...