Postpone clearing old MIDI events until next event

This fixes Native Instrument's FM7 crashing on MIDI input. The plugin
expects the last received MIDI event to always be alive during audio
processing, even if there have not been any new events in this
processing cycle.
This commit is contained in:
Robbert van der Helm
2021-04-23 01:03:57 +02:00
parent 3f427cfa5a
commit afefb725b5
3 changed files with 27 additions and 1 deletions
+11 -1
View File
@@ -278,7 +278,9 @@ Vst2Bridge::Vst2Bridge(MainContext& main_context,
}},
request.buffers);
next_audio_buffer_midi_events.clear();
// See the docstrong on `should_clear_midi_events` for why we
// don't just clear `next_buffer_midi_events` here
should_clear_midi_events = true;
});
});
}
@@ -303,6 +305,14 @@ void Vst2Bridge::run() {
// plugin.
std::lock_guard lock(next_buffer_midi_events_mutex);
// See the docstring on `should_clear_midi_events` for why we
// only deallocate old MIDI events here instead of a at the end
// of every processing cycle
if (should_clear_midi_events) {
next_audio_buffer_midi_events.clear();
should_clear_midi_events = false;
}
next_audio_buffer_midi_events.push_back(
std::get<DynamicVstEvents>(event.payload));
DynamicVstEvents& events = next_audio_buffer_midi_events.back();