I found the error. I was cleaning audioProcessors
before audioProcessorPlayers
. Since one AudioProcessorPlayer had a pure pointer to HelloAudioProcessor
, by the time I went to clear audioProcessorPlayers
, its AudioProcessorPlayer
had no processor to point to, so it tried to destruct the base class
This fixed the problem:
void shutdown() override
{
ALOGV(TAG, "shutting down");
ALOGV(TAG, "audioProcessorPlayers.clear()");
audioProcessorPlayers.clear();
ALOGV(TAG, "audioProcessors.clear()");
audioProcessors.clear();
ALOGV(TAG, "gonna closeAudioDevice");
deviceManager.closeAudioDevice();
ALOGV(TAG, "shutdown success");
}
Anyway, that code is being called from a Flutter call at an arbitrary time:
class MyApp : public juce::JUCEApplication
{
void initialise (const juce::String& commandLine) override
{
deviceManager.initialiseWithDefaultDevices (2, 2);
}
//Flutter calls this piece here at an arbitrary time
static void createSampler(int index) {
auto samplerProcessorPlayer = std::make_shared<juce::AudioProcessorPlayer>();
audioProcessorPlayers[index] = samplerProcessorPlayer;
auto samplerProcessor = std::make_shared<HelloSamplerAudioProcessor>();
samplerProcessorPlayer->setProcessor (samplerProcessor.get());
deviceManager.addAudioCallback (samplerProcessorPlayer.get());
audioProcessors[index] = samplerProcessor;
}
static juce::AudioDeviceManager deviceManager;
}
proper mutexing will be done, but currently it works as I do nothing but call createSampler
after the juce app starts