From 7f0a8c8efd5fc840351f02b655cf2f36742a6663 Mon Sep 17 00:00:00 2001 From: Robbert van der Helm Date: Mon, 27 Apr 2020 16:53:44 +0200 Subject: [PATCH] Extend the midi event lock This should not make any difference, but if this event ever gets called at the same time as the processing then this at least won't cause any issues with plugins that are not thread safe themselves. --- src/wine-host/plugin-bridge.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/wine-host/plugin-bridge.cpp b/src/wine-host/plugin-bridge.cpp index e45b5c92..708d8ee8 100644 --- a/src/wine-host/plugin-bridge.cpp +++ b/src/wine-host/plugin-bridge.cpp @@ -178,15 +178,13 @@ void PluginBridge::handle_dispatch() { // `DynamicVstEvents` object first. // HACK: Is there a cleaner way to do this, or a way to // avoid having to store temporary copies of this? - DynamicVstEvents* events; - { - std::lock_guard lock(next_buffer_midi_events_mutex); - events = &next_audio_buffer_midi_events.emplace_back( + std::lock_guard lock(next_buffer_midi_events_mutex); + DynamicVstEvents& events = + next_audio_buffer_midi_events.emplace_back( *static_cast(data)); - } return plugin->dispatcher(plugin, opcode, index, value, - &events->as_c_events(), option); + &events.as_c_events(), option); } else { std::cerr << "[Warning] Received non-MIDI " "event on MIDI processing thread"