This is the bug/patch tracker for Rockbox. Click here for more information.
Quick links: Bugs · Patches · Rockbox frontpage
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+2
Last edited by Andree Buschmann (Buschel) - Wednesday, 06 April 2011, 21:22 GMT+2
Opened by Richard Sweeney (riksweeney) - Wednesday, 21 November 2007, 20:31 GMT+2
Last edited by Andree Buschmann (Buschel) - Wednesday, 06 April 2011, 21:22 GMT+2
|
DetailsResuming 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
Closed by Andree Buschmann (Buschel)
Wednesday, 06 April 2011, 21:22 GMT+2
Reason for closing: Fixed
Additional comments about closing: Fixed with r29682.
Wednesday, 06 April 2011, 21:22 GMT+2
Reason for closing: Fixed
Additional comments about closing: Fixed with r29682.
FS#2687... I think the problem is that you shut down the player in the middle of a track transition.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...
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)?
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
That sound you hear is a can of worms being opened. ;)
I'll have a look into making the variable global instead.
I haven't checked if it solves the actual issue described by this task, but I think it will.
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.
I was unable to reproduce the problem with r20205 and a resynched and slightly modified playlist_index.patch. However, I got a track to play twice, both for it and its successor, so I guess I shouldn't attach a patch.
If BUFFERING_DEFAULT_FILECHUNK in apps/buffering.c is increased, resuming near the end of a track causes a bigger problem. Audio output just loops one short bit, and playback continues past the end instead of switching tracks. The bit being looped changes once around when the track should end and then it stays the same. Time keeps incrementing, and time remaining goes negative and keeps decrementing (eg. -3:-46). I haven't seen a crash yet, and I can press next track to go to the next track. I am unable to reproduce this problem with the current value of BUFFERING_DEFAULT_FILECHUNK (32k), but if I set it to 256k it happens every time I resume within 10 s or so of the end. Yes, I know the fact I can't reproduce this with unmodified SVN code may make the problem seem unimportant, but I think it is a race condition which needs to be fixed. It still happens with playlist_index-r20205.patch.
This was on a 30GB 5G iPod.
FS#9795) to r20235 and tested on my 5G 30GB iPod. One chunk was rejected in apps/plugin.h.rej and minor changes were needed in apps/iap.c.I was easily able to pause with 0 seconds remaining and resume later on in the next track
With BUFFERING_DEFAULT_FILECHUNK set to (1024*256) and a shuffled playlist with 247 MP3 files, after a resume I was easily able to get looping audio and playback continuing past end of file.
RE:
FS#9795, it wasn't quite clear. Did you actually say: Yes, it appears to fix the problem?r20238 + long_buffering_filechunk_resume_errors.patch + playback_changes.8c.diff doesn't fix the resume with 0 seconds left issue
It's easy to reproduce the issue with the 5G iPod simulator. You just need two MP3 files. Put the one with smaller file size first in the playlist. Pause with 0 seconds left in the first file. When you resume, you'll end up with something like this on standard output:
Resume index 1 offset 5AE37E
Playback will start at that offset in the second file, instead of at the end of the first file or the beginning of the second file.
Steve already mentioned it: The codec is always a bit advanced. The codec changed already when the wps the audio output is still in the old song. This is due to buffering the pcm data.
FS#9795aims to add a proper event on track change (not the codec track change). It might be that we only need to listen to that event in the playlist and nvram.bin code too.PS: I haven't really looked into this issue yet, I'm just having random ideas. I'm pretty much only guessing.
With an unmodified r20238 5G iPod sim, there is a brief flash of the next track and time 0:00 on the whole WPS
With r20238 + playback_changes.8c.diff, "Next Track:" becomes the current track
In both cases, after that point, displayed track is 2 of 2 instead of 1 of 2.
If I stop after that happens, a resume will be into track 2, with the saved offset from track 1.
FS#9795shows the next track as current one too early? That would be a bug in that patch, then.>With an unmodified r20238 5G iPod sim, there is a brief flash of the next track and time 0:00 on the whole WPS
Near the end of track 1, I briefly see ID3 info (ie. track name, artist, etc.) for track 2. During that brief period, I also see a blank time bar and a track time of 0:00. After this, everything except the track number goes back to being correct. The track number is 2 when it should be 1 because track 1 is still playing.
This seems to imply that after curtrack_id3 has been updated to the next track, the WPS sees it. The WPS should instead see prevtrack_id3.
>With r20238 + playback_changes.8c.diff, "Next Track:" becomes the current track
On the WPS, text displayed after "Next Track:" becomes the current track. The ID3 info for the current track is always correct.
(There is no flash of track 2 info near the end of track 1.)
>In both cases, after that point, displayed track is 2 of 2 instead of 1 of 2.
Track 1 is near the end, but it is still playing. However, the WPS says that I am on track 2.
(This seems to come from playlist_get_display_index(), and
FS#9795doesn't seem to affect it.)FS#9795doesn't touch playlist code enough (yet)."On the WPS, text displayed after "Next Track:" becomes the current track. The ID3 info for the current track is always correct." This seems to be a remaining bug in
FS#9795.But anyway, it seems that
FS#9795doesn't help for this problem (yet, I still think it possibly could), so let's not pollute this task about it further, except you have some findings of course.Without the patch, if I skip to the next track within about 2 seconds of the end, I end up skipping two tracks. This is still wrong but it is better because the playlist is not corrupted.
I don't think use of events alone will fix this. I'd suggest that all variables which store a track position/offset are (at least) commented to mark which transition they are based on, so we know the scale of the work.
long_buffering_filechunk_resume_errors.patch ought to be commmitted.
Pressing next track within the last two seconds also skips two tracks (eg. track 1 to track 3).
Also, the track number increments about two seconds before the end of a track.