Do you really need to interact with MIDI devices in during initialisation? It seems like a pretty dangerous thing to do as hosts instantiate plug-ins in loads of different contexts and threads.
Thank you for your answer! It simplifies stuff a lot if we initialize MIDI devices during initialization, but we could also initialize it later. But if it’s unsafe to do during initialization, how can I be sure doing it later is safe?
I don’t know what exactly Steinberg is doing in their vstscanner tool, which prints the segmentation faults, but I’d guess they have only one thread running, that initializes the plugin.
I’ve just built JUCE’s audio plugin demo on JUCE’s current master and tested it with OS X 10.11.
JUCE’s plugin demo gets blacklisted in Cubase 9 if I call MidiOutput::getDevices (or MidiInput…) at the end of the constructor of JuceDemoPluginAudioProcessor. And Steinberg’s vst2xscanner gives this error: Segmentation fault: 11
If I call MidiOutput::getDevices in prepareToPlay instead, then JUCE’s plugin demo is not blacklisted, and the scan works fine.
Still - I wonder if the reported Segmentation fault: 11 means there’s something bad going on in MidiOutput::getDevices that might needs to be addressed. It would be great if the JUCE team can have a look at it.
Of course we don’t know why Steinberg’s vst2xscanner prints a “Segmentation fault” after calling MidiOutput::getDevices_, still I think it’d be valuable if the JUCE team could have a look at this.
JUCE team, is this something you will look into, or will you ignore it?
No stack trace - the code is getting executed all fine. It’s just Steinberg’s scanner that afterwards prints the “Segmentation fault” message (instead of printing the details of the plugin and channel configuration).
OK, I’ve just verified this again - it’s not the JUCE code that’s crashing. But still, it requires the call to MidiOutput::getDevices_ and then Steinberg’s vst2xscanner is crashing.
OK, well I’m really not sure what we could possibly do to stop that - if you look inside that function call you’ll see that it does pretty much nothing except call the OS MIDI enumerator…