Hi,
I have written a simple audio player plugin, mostly following the 404 - Missing Page - JUCE tutorial. Everything is fine, except when I close the JUCE Plug-in host I get an
Exception thrown: read access violation.
this->input.object.object-> was 0xDDDDDDDD.
every time.
The stack trace looks like this:
NewProject.dll!juce::ResamplingAudioSource::releaseResources() Line 77 C++
NewProject.dll!juce::AudioTransportSource::setSource(juce::PositionableAudioSource * newSource, int readAheadSize, juce::TimeSliceThread * readAheadThread, double sourceSampleRateToCorrectFor, int maxNumChannels) Line 121 C++
NewProject.dll!juce::AudioTransportSource::~AudioTransportSource() Line 47 C++
NewProject.dll!NewProjectAudioProcessor::~NewProjectAudioProcessor() Line 24 C++
The relevant code boils down to this:
void NewProjectAudioProcessor::prepareToPlay (double sampleRate, int samplesPerBlock)
{
// Use this method as the place to do any pre-playback
// initialisation that you need…
formatManager.registerBasicFormats();
transportSource.prepareToPlay(samplesPerBlock, sampleRate);
var filePath = “path to some .wav file”;
auto file = File(filePath);
AudioFormatReader* reader = formatManager.createReaderFor(file);
if (reader != nullptr)
{
ScopedPointer newSource = new AudioFormatReaderSource(reader, true);
transportSource.setSource(newSource, 0, nullptr, reader->sampleRate);
readerSource = newSource.release();
}
}
void NewProjectAudioProcessor::releaseResources()
{
// When playback stops, you can use this as an opportunity to free up any
// spare memory, etc.
transportSource.releaseResources();
}
Which is pretty much copy paste from the tutorial. I am a C++ noob and I just don’t see, what the problem is here. I am sure that I have missed something trivial, so I am sorry for a stupid question
Thanks for reading