dev builds
themes manual
device status forums
mailing lists
IRC bugs
dev guide

Rockbox mail archive

Subject: Re: Buffering two files

Re: Buffering two files

From: Boris Gjenero <>
Date: Wed, 08 Apr 2009 12:29:04 -0400

Bryan Jacobs wrote:
> I am a prospective Summer of Code 2009 student potentially working on
> implementing Wavpack Hybrid Compression support in Rockbox. To do
> this, I'll probably need to buffer two different files.
> There's been some debate as to how best do this. What do the devs out
> there think?

Both files need to be in the main buffer. The plugin buffer is small,
and neither file has an extremely low bitrate. If one file is in the
plugin buffer, the hard drive will have to spin up much more often.
It's okay to use the plugin buffer during development however.

When the files are being loaded, the length of time loaded has to be
similar for both files. If file A runs out before file B runs out, you
could have loaded more of file A and less of file B. Maybe the format
has a seek table which can help when estimating how much to load.

If you try to buffer two files with differing bitrates at the same time
into one circular buffer, they can run into each other. Then, you
either have to interleave them or move data around.

One way of dealing with this is interleaving the files while they are
read so they become a single file in the buffer. This can be done via
new code in buffer_handle or another function which is used instead of
buffer_handle. Few changes would be needed in the rest of buffering
code. The codec can then deal with the interleaving.

The most interesting case here is what happens when you run low on data
and need to fill the buffer again. You'll have something like
"fffffffAAffffBB" at the end, where f is free (already played), A is
file A and B is file B. You can either make the interleaving chunks
small so that the space between AA and BB is insignificant, or you can
have a function which shrinks the handle and moves AA to just before BB.
  Larger interleaving chunks lead to more efficient disk access.

Received on 2009-04-08

Page template was last modified "Tue Sep 7 00:00:02 2021" The Rockbox Crew -- Privacy Policy