How to play an audio processor without a plugin editor?

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

OK, now the object creation code makes more sense, since you are storing the shared pointers in some container. (You didn’t show that stuff in your previous post.)

Thank you for all the help. I made a minimal example. I ported the AudioProcessorGraph tutorial for Android (and possibly iOS, did not test because I don’t have macOS + iPhone) but it should compile.

It’s working perfectly on my phone.

Hope it helps people in the future.

This is how it does the audio processor playing:

    deviceManager.initialiseWithDefaultDevices (2, 2);                          // [1]
    deviceManager.addAudioCallback (&player);                                   // [2]
    //midi disabled for Android
    //deviceManager.setMidiInputDeviceEnabled (inputDevice.identifier, true);
    //deviceManager.addMidiInputDeviceCallback (inputDevice.identifier, &player); // [3]
    //deviceManager.setDefaultMidiOutputDevice (outputDevice.identifier);
    player.setProcessor (mainProcessor.get());                  

This proved to work on Android.

For the input error on my plugin, I suspect it has to do with me passing the player which plays my processor, to a device manager with 2 inputs: deviceManager.initialiseWithDefaultDevices (2, 2);. So it naturally expects the processor to have an input channel. I did not test adding another device manager with no inputs but I think it would work. For now having only one with input but muting the input on my processor should work.

Thanks @xenakios @HowardAntares and @anoesisaudio