Any way to lower the size of FLAC AudioFormatReader's reservoir buffer?


#1

Hi JUCErs,

In my case I have 3520 sample files and for each and every one of them I have an AudioFormatReader in memory, at all time.

I noticed they take quite a lot of space (just the readers) - I think there is a reservoir buffer of 8096 (*2 channels) in each reader. Having that for all 3520 files, it totals in ~217MB just for the readers.

Reading from disk doesn’t happen on the audio thread (worker threads use the audioFormatReaders and write in a lock-free fifo) and I guess I could use a pool of readers and reset them with the current file location (is this doable?), but I guess the reservoir is delivering samples without querying the disk when it’s full, so I’m afraid this may not be optimal for this specific format?

Any help is much appreciated.


Should FlacReader::readSamples() allocate memory which isn't cleaned up after completion?
#2

If you have that many files, then just using the simple approach of keeping a permanent reader per file isn’t going to scale!

Don’t know what’s best for your app, but you’ll need to build some kind of smarter system that works on that scale.