Allow midi events to be handled during interaction

This commit is contained in:
Robbert van der Helm
2020-03-28 17:00:12 +01:00
parent 629fa72e0c
commit d52989acc5
5 changed files with 52 additions and 16 deletions
+13
View File
@@ -62,6 +62,7 @@ PluginBridge::PluginBridge(std::string plugin_dll_path,
io_context(),
socket_endpoint(socket_endpoint_path),
host_vst_dispatch(io_context),
host_vst_dispatch_midi_events(io_context),
vst_host_callback(io_context),
host_vst_parameters(io_context),
host_vst_process_replacing(io_context),
@@ -94,6 +95,7 @@ PluginBridge::PluginBridge(std::string plugin_dll_path,
// It's very important that these sockets are accepted to in the same order
// in the Linus plugin
host_vst_dispatch.connect(socket_endpoint);
host_vst_dispatch_midi_events.connect(socket_endpoint);
vst_host_callback.connect(socket_endpoint);
host_vst_parameters.connect(socket_endpoint);
host_vst_process_replacing.connect(socket_endpoint);
@@ -118,6 +120,16 @@ PluginBridge::PluginBridge(std::string plugin_dll_path,
current_bridge_isntance = nullptr;
plugin->ptr1 = this;
// This works functionally identically to the `handle_dispatch()` function
// below, but this socket will only handle midi events. This is needed
// because of Win32 API limitations.
dispatch_midi_events_handler = std::thread([&]() {
while (true) {
passthrough_event(host_vst_dispatch_midi_events, std::nullopt,
plugin, plugin->dispatcher);
}
});
parameters_handler = std::thread([&]() {
while (true) {
// Both `getParameter` and `setParameter` functions are passed
@@ -191,6 +203,7 @@ void PluginBridge::handle_dispatch() {
} catch (const boost::system::system_error&) {
// This happens when the sockets got closed because the plugin is being
// shut down. In that case we can just let the whole host terminate.
dispatch_midi_events_handler.detach();
parameters_handler.detach();
process_replacing_handler.detach();
}
+13
View File
@@ -104,6 +104,13 @@ class PluginBridge {
// `AEffect.dispatch()` calls from the native VST host to the Windows VST
// plugin (through the Wine VST host).
boost::asio::local::stream_protocol::socket host_vst_dispatch;
/**
* Used specifically for the `effProcessEvents` opcode. This is needed
* because the Win32 API is designed to block during certain GUI
* interactions such as resizing a window or opening a dropdown. Without
* this midi input would just stop working at times.
*/
boost::asio::local::stream_protocol::socket host_vst_dispatch_midi_events;
boost::asio::local::stream_protocol::socket vst_host_callback;
/**
* Used for both `getParameter` and `setParameter` since they mostly
@@ -119,6 +126,12 @@ class PluginBridge {
*/
boost::asio::local::stream_protocol::socket vst_host_aeffect;
/**
* The thread that specifically handles `effProcessEvents` opcodes so the
* plugin can still receive midi during GUI interaction to work around Win32
* API limitations.
*/
std::thread dispatch_midi_events_handler;
/**
* The thread that responds to `getParameter` and `setParameter` requests.
*/