[SOLVED] Windows error CRITICAL_SECTION and question

Got this error asking me to report it, so here I am.

CriticalSection::CriticalSection() noexcept
// (just to check the MS haven’t changed this structure and broken things…)
static_assert (sizeof (CRITICAL_SECTION) <= sizeof (lock),
“win32 lock array too small to hold CRITICAL_SECTION: please report this JUCE bug!”);

InitializeCriticalSection ((CRITICAL_SECTION*) &lock);


As a plus, can someone tell me if I’m doing something wrong?
I just want to send Midi messages whenever I click a button.
Later, I want to send MPE messages, but for now even a simple noteOn is crashing my app.
This particular error started after I added the StartBackgroundTrhead line.

audioDeviceManager.initialise(0, 2, nullptr, true, {}, nullptr);
audioDeviceManager.addMidiInputDeviceCallback({}, this); // [6]
auto devices = MidiOutput::getAvailableDevices();
auto defaultDevice = devices[MidiOutput::getDefaultDeviceIndex()];
auto defaultDeviceID = defaultDevice.identifier;

The idea was

juce::MidiMessage midiMsg;
midiMsg = juce::MidiMessage();
double timeStamp = Time::getMillisecondCounter();
midiMsg = MidiMessage::noteOff(1, 37, DEFAULT_VELOCITY);

OK, midiOut was declared as pointer, not as unique_prt.
After I changed that, the CRITICAL_SECTION error ceased to appear, as well as the notes played.
(with and without the startbackgroundThread)