Rockbox

This is the bug/patch tracker for Rockbox. Click here for more information.

Quick links: Bugs · Patches · Rockbox frontpage

Tasklist

FS#9703 - Better watermark handling

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

Details

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.)
   watermark.patch (15.2 KiB)
 apps/pcmbuf.c         |    8 ------
 apps/dsp.h            |    3 --
 apps/playback.c       |   66 ++++++++++++++++++++++++++++++++------------------
 apps/buffering.c      |   15 ++---------
 apps/debug_menu.c     |    8 +++---
 apps/codecs/flac.c    |    2 -
 apps/codecs/ape.c     |    2 -
 apps/codecs/aiff.c    |    1 
 apps/codecs/aac.c     |    2 -
 apps/codecs/spc.c     |    2 -
 apps/codecs/alac.c    |    2 -
 apps/codecs/mod.c     |    3 --
 apps/codecs/sid.c     |    3 --
 apps/codecs/shorten.c |    2 -
 apps/codecs/asap.c    |    3 --
 apps/codecs/wma.c     |    2 -
 apps/codecs/wavpack.c |    2 -
 apps/codecs/wav.c     |    1 
 18 files changed, 52 insertions(+), 75 deletions(-)

This task depends upon

Closed by  Björn Stenberg (zagor)
Saturday, 10 January 2009, 22:12 GMT+2
Reason for closing:  Accepted
Additional comments about closing:  Committed in r19743
Comment by Björn Stenberg (zagor) - Monday, 29 December 2008, 01:30 GMT+2
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.
   watermark2.patch (21.2 KiB)
 apps/pcmbuf.c         |   61 ++++++++++++++++++++++-------------------
 apps/pcmbuf.h         |    6 ----
 apps/dsp.h            |    3 --
 apps/playback.c       |   74 +++++++++++++++++++++++++++++---------------------
 apps/buffering.c      |   19 ++----------
 apps/debug_menu.c     |   10 +++---
 apps/codecs/flac.c    |    2 -
 apps/codecs/ape.c     |    2 -
 apps/codecs/aiff.c    |    1 
 apps/codecs/aac.c     |    2 -
 apps/codecs/spc.c     |    2 -
 apps/codecs/alac.c    |    2 -
 apps/codecs/mod.c     |    3 --
 apps/codecs/sid.c     |    3 --
 apps/codecs/shorten.c |    2 -
 apps/codecs/asap.c    |    3 --
 apps/codecs/wma.c     |    2 -
 apps/codecs/wavpack.c |    2 -
 apps/codecs/wav.c     |    1 
 19 files changed, 86 insertions(+), 114 deletions(-)

Comment by Thomas Martitz (kugel.) - Wednesday, 31 December 2008, 02:40 GMT+2
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, 01:22 GMT+2
Fixed an issue where codec thread would not cancel its' elevated priority.
   watermark3.patch (22.9 KiB)
 apps/pcmbuf.c         |   83 +++++++++++++++++++++++++++++---------------------
 apps/pcmbuf.h         |    6 ---
 apps/dsp.h            |    3 -
 apps/playback.c       |   78 +++++++++++++++++++++++++++-------------------
 apps/buffering.c      |   19 +----------
 apps/debug_menu.c     |   10 +++---
 apps/codecs/flac.c    |    2 -
 apps/codecs/ape.c     |    2 -
 apps/codecs/aiff.c    |    1 
 apps/codecs/aac.c     |    2 -
 apps/codecs/spc.c     |    2 -
 apps/codecs/alac.c    |    2 -
 apps/codecs/sid.c     |    3 -
 apps/codecs/mod.c     |    3 -
 apps/codecs/shorten.c |    2 -
 apps/codecs/asap.c    |    3 -
 apps/codecs/wma.c     |    2 -
 apps/codecs/wavpack.c |    2 -
 apps/codecs/wav.c     |    1 
 19 files changed, 103 insertions(+), 123 deletions(-)

Comment by Thomas Martitz (kugel.) - Thursday, 01 January 2009, 14:14 GMT+2
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, 21:33 GMT+2
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.

Loading...