FS#9703 - Better watermark handling

Attached to Project: Rockbox
Opened by Björn Stenberg (zagor) - Tuesday, 23 December 2008, 22:04 GMT
Last edited by Björn Stenberg (zagor) - Saturday, 10 January 2009, 21:12 GMT
Task Type Patches
Category Music playback
Status Closed
Assigned To No-one
Operating System All players
Severity Low
Priority Normal
Reported Version Release 3.0
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No


The current watermark handling is quite hardcoded at 512KB, which is a problem for targets with a small file buffer.

It is also of course not optimal for battery performance.

This patch instead calculates the watermark based on the bitrate of the last file in the buffer and the measured harddisk spinup time.

(This code is not ready for commit.)
This task depends upon

Closed by  Björn Stenberg (zagor)
Saturday, 10 January 2009, 21:12 GMT
Reason for closing:  Accepted
Additional comments about closing:  Committed in r19743
Comment by Björn Stenberg (zagor) - Monday, 29 December 2008, 00:30 GMT
Massaged pcmbuf.c a bit. The pause/unpause bug is now fixed and also the excess boost is fixed.

Still to do:
1) Understand pcmbuf.c better, in order to determine if I like how it works. :-) In any case it needs documentation.
2) See if I can find a clean way to export buffering information to playback.c, in order to include total and buffered file size for the last track in the watermark algorithm.

I have tested this on Iriver H140, Sansa C200 and Sansa Clip so far. I would appreciate some test reports for other targets.
Comment by Thomas Martitz (kugel.) - Wednesday, 31 December 2008, 01:40 GMT
Doesn't work at all here on my Fuze. I just hear a loud and constant hissing.
The debug screen shows that audio buffer decreased, but the pcm buffer apparently jumped back and forth between 2 values (the 2 values are constant it seems).

I tested with a Flac, other codecs (aac, vorbis, mp3) still don't give any sound at all.
Comment by Björn Stenberg (zagor) - Thursday, 01 January 2009, 00:22 GMT
Fixed an issue where codec thread would not cancel its' elevated priority.
Comment by Thomas Martitz (kugel.) - Thursday, 01 January 2009, 13:14 GMT
Definitely better now, but the issues are still there.
Playing FLAC and Mp3 seems fine now.

However: Ogg still causes slowness. It's much better than with watermark2, but the gui lags and backlight fade slowness are still very noticeable compared to SVN.

From the View OS stacks screen I can see, that with this patch codec is constantly *R. In SVN, it's changes between +R, *R and S freqeuently. The numbers are the same ("16 16 18%").
Comment by Björn Stenberg (zagor) - Thursday, 01 January 2009, 20:33 GMT
I need help repeating your problem. I cannot see any difference in backlight fade speed between mp3 and ogg on neither c200 or e200.

The codec thread runs more frequently since the PCM buffer is a third of the size in SVN. But it should not (and does not, afaik) boost more than SVN.