Integer division by zero in ResamplingAudioSource::getNextAudioBlock


Hello everyone.

I’ve basically copied the example from AudioThumbnailTutorial into my app and trying to play a wave file when I get a division by zero in ResamplingAudioSource::getNextAudioBlock (buffer not valid).

I can get around this by manually calling transportSource.prepareToPlay() again, but how do I know what values I need to pass in?

File f(currentTrackInfo.filename);
AudioFormatReader* reader = formatManager.createReaderFor(f);

if (reader != nullptr)
	ScopedPointer<AudioFormatReaderSource> newSource = new AudioFormatReaderSource(reader, true);
	transportSource.setSource(newSource, 0, nullptr, reader->sampleRate);
	readerSource = newSource.release();
	//transportSource.prepareToPlay(448, 44100);

My component that does does inherits from AudioAppComponent.

I’ve probably just not quite understood how this works.


// E


Small update. If I move it to a subcomponent of the main GUI component, it works…


Try calling your AudioTransportSource’s prepareToPlay method in the AudioAppComponent’s prepareToPlay method.

See this tutorial for a step by step example of playing a file: