My AudioSource prototype is working, but I have a couple of questions for "edge" cases:
In MyAudioSource::getNextAudioBlock implementation...if the full number of samples requested (info.numSamples) are not availble (network latency), what should I do?
- Pad output buffer with 0? Yikes!
- Use info.buffer->clear (startSample, numSamples) to 'pad' the buffer?
- Use info.buffer->setSize to resize the buffer?
- Or should I just wait (block thread) until more data arrives?
Today I have just been filling the buffer with as many samples as I have and ignoring the rest of the samples. I don't notice any issues, but I have to think that isn't the ideal behavior.
If MyAudioSource is 'paused', or 'muted', MyAudioSource::getNextAudioBlock should invoke 'info.clearActiveBufferRegion', correct?
Minor Question
My audio source has a 8K sampling rate, so I have been using ResamplingAudioSource to handle the upsampling. When ResamplingAudioSource calls MyAudioSource::prepareToPlay, shouldn't the 'sampleRate' be 8K? Based on testing, it is always set to 44.1K. It seems like ResamplingAudioSouce should request source and destination sampling rate and not just a ratio, thoughts?