FS#5582 - Buffer desync and wrong recalculation of filebufused

Attached to Project: Rockbox
Opened by Tomasz Malesinski (tmal) - Wednesday, 21 June 2006, 23:49 GMT
Task Type Bugs
Category Music playback
Status Closed
Assigned To No-one
Operating System All players
Severity High
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No


Recalculation of filebufused in codec_discard_codec_callback() is clearly wrong. It should be based on buf_ridx and buf_widx not track_ridx and track_widx.

I am not yet familiar with the code enough, but I suppose that a buffer desync should not happen in first place. Anyway, here is a way to produce a desync (tested in simulator only):
Put two files, shorter than the codec buffer, in different formats (eg. mp3 and ogg) to one directory. Start playing one of them, skip to the next one, skip back to the first one and once again skip to the second one. Buffer desync should happen because discard_codec assumes there is no codec in the buffer (cur_ti->has_codec is false). Incorrectly recalculated filebufused will cause problems when all the data from the codec buffer will be played. End of buffered data will not be noticed because of incorrect value of filebufused.
This task depends upon

Closed by  Jonas Häggqvist (rasher)
Thursday, 12 October 2006, 21:38 GMT
Reason for closing:  Fixed
Additional comments about closing:  Submitter reports that this issue has been fixed.
Comment by Steve Bavin (pondlife) - Monday, 02 October 2006, 13:15 GMT
Hi Tomasz,

This report seems to be out of date; codec_discard_codec_callback() is now only using buf_ridx. Please could you recheck.
Comment by Tomasz Malesinski (tmal) - Thursday, 12 October 2006, 20:10 GMT
Yes, it has been fixed.