FS#8104 - playback.c consistency and track count

Attached to Project: Rockbox
Opened by Bertrik Sikken (bertrik) - Tuesday, 06 November 2007, 20:59 GMT
Last edited by Nicolas Pennequin (nicolas_p) - Monday, 19 November 2007, 16:38 GMT
Task Type Patches
Category Music playback
Status Closed
Assigned To Nicolas Pennequin (nicolas_p)
Operating System All players
Severity Low
Priority Normal
Reported Version Daily build (which?)
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No


I noticed that track_widx and track_ridx in playback.c are not always updated in the same way (with the wrap-around). Patch playback1.txt corrects this and should have no functional impact.

Patch playback2.txt goes a bit further. It simplifies functions audio_have_tracks, audio_have_free_tracks and audio_track_count by using just the track_widx and track_ridx pointers to determine how much of the track buffer is used/free. This clears up a few 'ifs' for corner cases and replaces it by a simpler unconditional calculation.
This new implementation is not 100% identical to the original implementation as the exact intention of the original functions was not completely clear to me.
This task depends upon

Closed by  Nicolas Pennequin (nicolas_p)
Monday, 19 November 2007, 16:38 GMT
Reason for closing:  Accepted
Additional comments about closing:  Thanks!
Comment by Nicolas Pennequin (nicolas_p) - Wednesday, 07 November 2007, 01:01 GMT
Thanks! I'll look into those ASAP.
Reading "the exact intention of the original functions was not completely clear to me" made me smile, because I had the exact same problem and it's why I didn't touch these parts of the code ;)
Comment by Steve Bavin (pondlife) - Wednesday, 07 November 2007, 07:26 GMT
If anyone claims to know what those functions do, can we have lots of comments added please ;).
Comment by Bertrik Sikken (bertrik) - Monday, 12 November 2007, 22:14 GMT
FWIW, re-diffed against 15597.