For my application I keep one large sample buffer in memory.
In testing, I’ve been loading large files (2 hours) - If I try to resize my AudioSampleBuffer to handle it, I get a SEGV.
I’d like to report to the user that I can’t open the file, and not crash!
Now, it seems to me that, for my purposes anyway, this can be done with a tiny change AudioSampleBuffer::setDataToReferTo:
void setDataToReferTo (float** dataToReferTo,
bool freeExistingSamples = true) noexcept;
This lets me take the existing samples, realloc them, check for failure, and on success replace them in the AudioSampleBuffer, and it’s completely code-compatible with existing code.
EDIT: uh-uh, that quite doesn’t do it, because it still copies the data unnecessarily… but there are a lot of fairly simple ways to deal with this, I welcome comments!