This is the bug/patch tracker for Rockbox. Click here for more information.
Quick links: Bugs · Patches · Rockbox frontpage
FS#6317 - Lockup if stopping while still seeking to resume point
Attached to Project:
Rockbox
Opened by Peter D'Hoye (petur) - Sunday, 12 November 2006, 00:27 GMT+1
Last edited by Michael Sevakis (MikeS) - Tuesday, 31 July 2007, 13:13 GMT+1
Opened by Peter D'Hoye (petur) - Sunday, 12 November 2006, 00:27 GMT+1
Last edited by Michael Sevakis (MikeS) - Tuesday, 31 July 2007, 13:13 GMT+1
|
DetailsHitting stop while still reading the file to reach the resume point causes a lockup.
1) Play a fairly large WAV and seek quite far into it 2) stop layback 3) start playback using 'play' to resume where left off 4) press stop again before playback resumes (= while reading the file to rewach the resume point) backlight thread still running but paperclip required to get a usable player again. Observed on h340 but probably an issue on al SWCODEC |
This task depends upon
Closed by Michael Sevakis (MikeS)
Tuesday, 31 July 2007, 13:13 GMT+1
Reason for closing: Fixed
Additional comments about closing: Fixed is as fixed does. I thought I closed this one.
Tuesday, 31 July 2007, 13:13 GMT+1
Reason for closing: Fixed
Additional comments about closing: Fixed is as fixed does. I thought I closed this one.
FS#6129I am able to reproduce this, maybe will have time to look into it this week...
The audio thread is getting stuck in an infinite loop in audio_stop_codec_flush(), specifically the loop
while (audio_codec_loaded)
yield();
It's easy to see on the remote if you put a logf with a counter in there.
So, I guess the audio thread is waiting for the codec thread to stop, but the codec thread is still waiting for the audio thread to finish buffering. It looks like the audio thread has buffered some data, however, I'm not sure why control is not returned to the codec thread, but instead the audio thread continues to process the stop request.
The sequence of events are as follows:
1. Start up
2. Play track (150MB flac)
3. Seek far enough to cause a rebuffer & seek
4. Stop (return to file tree)
5. Press play to resume playback
6a. For locked up case: Press stop while buffering (don't know if the timing is important here...I waited until I saw the wps and then pressed stop a couple of times).
6b. For ok resume case: wait for hdd activity to stop, then logfdump.
Note: there are a couple of extra logf's added here and there.
EDIT: ...though I have an idea of using a counter instead of a bool so every time an audio codec loads it increments the counter by 1 and you'd be able to detect this state. Simply adding yields somewhere is still a race condition.
EDIT2: Having the counter start at zero and increment when loading a codec and increment a again when unloading would make it even when no codec is loaded and odd when a codec is loaded and other checks can simply be if (encoder_version & 0x1) instead of if (audio_codec_loaded) but the aliasing problem would be nonexistent too.
I think there may be some confusion in the buffering process for flac files. When a flac files resumes at a long offset, it must be buffered from the beginning in order to get the stream info & seek tables and then immediately rebuffered to the proper seek point. I think maybe the stop is coming between the initial fill buffer request and secondary seek & rebuffer. That seems to be what the logf dump is indicating for the lockup case (look at when Q_AUDIO_REBUFFER_SEEK is queued).
If that's the case, maybe a solution is to make codec_seek_buffer_callback return "busy" while the audio thread is filling and make the codec do a yield loop until it's ready.
Just thinking out loud...shouldn't rebuffer_seek be able to abort the current fill processes? It's very inefficient in these cases to fill the buffer twice. Or maybe we need a function like audio_fill_buffer_exact(Nbytes) that reads at most Nbytes onto the buffer. Flac (and wav?) could use that function for the initial buffering of the stream info & seek table.
One thing I've wondered about but haven't tested (off topic):
What happens if you have a codec on the buffer followed by several files that use that codec and the first file is invalid and causes a codec failure? Do the remaining files play or die?