I’m using ResamplingAudioSource and getting a mod by zero on the initial call to getNextAudioBlock(). What is happening is bufferSize is initially zero and then we’re modding the bufferPos by that:
void ResamplingAudioSource::getNextAudioBlock (const AudioSourceChannelInfo& info)
{
//....
int bufferSize = buffer.getNumSamples();
if (bufferSize < sampsNeeded + 8)
{
bufferPos %= bufferSize; // mod by zero here
bufferSize = sampsNeeded + 32;
Swapping the order of assignment of bufferPos and bufferSize seems to fix it:
Sounds like you’re calling getNextAudioBlock() before you’ve initialised it with prepareToPlay()…?[/quote]
I wish that were the case but its not. Look at how bufferSize gets set:
int bufferSize = buffer.getNumSamples();
There are no samples in the buffer yet. “buffer” has physical storage available, because I call prepareToPlay with a good samplesPerBlockExpected, but there are no actual samples in it yet because audio is just starting.