Send the AEffect object over a new control socket

We'll use the same socket to send the configuration data back to the
plugin.
This commit is contained in:
Robbert van der Helm
2020-07-22 13:36:29 +02:00
parent c83680a21a
commit 6f772ca899
4 changed files with 40 additions and 14 deletions
+6 -4
View File
@@ -58,6 +58,7 @@ PluginBridge::PluginBridge(audioMasterCallback host_callback)
vst_host_callback(io_context), vst_host_callback(io_context),
host_vst_parameters(io_context), host_vst_parameters(io_context),
host_vst_process_replacing(io_context), host_vst_process_replacing(io_context),
host_vst_control(io_context),
host_callback_function(host_callback), host_callback_function(host_callback),
logger(Logger::create_from_environment( logger(Logger::create_from_environment(
create_logger_prefix(socket_endpoint.path()))), create_logger_prefix(socket_endpoint.path()))),
@@ -109,6 +110,7 @@ PluginBridge::PluginBridge(audioMasterCallback host_callback)
socket_acceptor.accept(vst_host_callback); socket_acceptor.accept(vst_host_callback);
socket_acceptor.accept(host_vst_parameters); socket_acceptor.accept(host_vst_parameters);
socket_acceptor.accept(host_vst_process_replacing); socket_acceptor.accept(host_vst_process_replacing);
socket_acceptor.accept(host_vst_control);
#ifndef WITH_WINEDBG #ifndef WITH_WINEDBG
host_guard_handler.request_stop(); host_guard_handler.request_stop();
@@ -170,10 +172,10 @@ PluginBridge::PluginBridge(audioMasterCallback host_callback)
// Read the plugin's information from the Wine process. This can only be // Read the plugin's information from the Wine process. This can only be
// done after we started accepting host callbacks as the plugin will likely // done after we started accepting host callbacks as the plugin will likely
// call these during its initialization. We reuse the `dispatcher()` socket // call these during its initialization. Any further updates will be sent
// for this since this has to be done only once. // over the `dispatcher()` socket. This would happen whenever the plugin
const auto initialization_data = // calls `audioMasterIOChanged()` and after the host calls `effOpen()`.
read_object<EventResult>(host_vst_dispatch); const auto initialization_data = read_object<EventResult>(host_vst_control);
const auto initialized_plugin = const auto initialized_plugin =
std::get<AEffect>(initialization_data.payload); std::get<AEffect>(initialization_data.payload);
+13 -2
View File
@@ -109,8 +109,7 @@ class PluginBridge {
/** /**
* The socket that forwards all `dispatcher()` calls from the VST host to * The socket that forwards all `dispatcher()` calls from the VST host to
* the plugin. This is also used once at startup to populate the values of * the plugin.
* the `AEffect` object.
*/ */
boost::asio::local::stream_protocol::socket host_vst_dispatch; boost::asio::local::stream_protocol::socket host_vst_dispatch;
/** /**
@@ -120,6 +119,10 @@ class PluginBridge {
* this MIDI input would just stop working at times. * 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 host_vst_dispatch_midi_events;
/**
* The socket that forwards all `audioMaster()` calls from the Windows VST
* plugin to the host.
*/
boost::asio::local::stream_protocol::socket vst_host_callback; boost::asio::local::stream_protocol::socket vst_host_callback;
/** /**
* Used for both `getParameter` and `setParameter` since they mostly * Used for both `getParameter` and `setParameter` since they mostly
@@ -128,6 +131,14 @@ class PluginBridge {
boost::asio::local::stream_protocol::socket host_vst_parameters; boost::asio::local::stream_protocol::socket host_vst_parameters;
boost::asio::local::stream_protocol::socket host_vst_process_replacing; boost::asio::local::stream_protocol::socket host_vst_process_replacing;
/**
* A control socket that sends data that is not suitable for the other
* sockets. At the moment this is only used to, on startup, send the Windows
* VST plugin's `AEffect` object to the native VST plugin, and to then send
* the configuration (from `config`) back to the Wine host.
*/
boost::asio::local::stream_protocol::socket host_vst_control;
/** /**
* The thread that handles host callbacks. * The thread that handles host callbacks.
*/ */
+8 -6
View File
@@ -75,7 +75,8 @@ Vst2Bridge::Vst2Bridge(boost::asio::io_context& main_context,
host_vst_dispatch_midi_events(io_context), host_vst_dispatch_midi_events(io_context),
vst_host_callback(io_context), vst_host_callback(io_context),
host_vst_parameters(io_context), host_vst_parameters(io_context),
host_vst_process_replacing(io_context) { host_vst_process_replacing(io_context),
host_vst_control(io_context) {
// Got to love these C APIs // Got to love these C APIs
if (!plugin_handle) { if (!plugin_handle) {
throw std::runtime_error("Could not load the Windows .dll file at '" + throw std::runtime_error("Could not load the Windows .dll file at '" +
@@ -107,6 +108,7 @@ Vst2Bridge::Vst2Bridge(boost::asio::io_context& main_context,
vst_host_callback.connect(socket_endpoint); vst_host_callback.connect(socket_endpoint);
host_vst_parameters.connect(socket_endpoint); host_vst_parameters.connect(socket_endpoint);
host_vst_process_replacing.connect(socket_endpoint); host_vst_process_replacing.connect(socket_endpoint);
host_vst_control.connect(socket_endpoint);
// Initialize after communication has been set up // Initialize after communication has been set up
// We'll try to do the same `get_bridge_isntance` trick as in // We'll try to do the same `get_bridge_isntance` trick as in
@@ -126,11 +128,11 @@ Vst2Bridge::Vst2Bridge(boost::asio::io_context& main_context,
plugin->ptr1 = this; plugin->ptr1 = this;
} }
// Send the plugin's information to the Linux VST plugin. This is done over // Send the plugin's information to the Linux VST plugin. Any other updates
// the `dispatch()` socket since this has to be done only once during // of this object will be sent over the `dispatcher()` socket. This would be
// initialization. Any updates during runtime are handled using the // done after the host calls `effOpen()`, and when the plugin calls
// `audioMasterIOChanged` host callback. // `audioMasterIOChanged()`.
write_object(host_vst_dispatch, EventResult{0, *plugin, std::nullopt}); write_object(host_vst_control, EventResult{0, *plugin, std::nullopt});
// This works functionally identically to the `handle_dispatch()` function, // This works functionally identically to the `handle_dispatch()` function,
// but this socket will only handle MIDI events and it will handle them // but this socket will only handle MIDI events and it will handle them
+13 -2
View File
@@ -193,8 +193,7 @@ class Vst2Bridge {
/** /**
* The socket that forwards all `dispatcher()` calls from the VST host to * The socket that forwards all `dispatcher()` calls from the VST host to
* the plugin. This is also used once at startup to populate the values of * the plugin.
* the `AEffect` object.
*/ */
boost::asio::local::stream_protocol::socket host_vst_dispatch; boost::asio::local::stream_protocol::socket host_vst_dispatch;
/** /**
@@ -204,6 +203,10 @@ class Vst2Bridge {
* this MIDI input would just stop working at times. * 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 host_vst_dispatch_midi_events;
/**
* The socket that forwards all `audioMaster()` calls from the Windows VST
* plugin to the host.
*/
boost::asio::local::stream_protocol::socket vst_host_callback; boost::asio::local::stream_protocol::socket vst_host_callback;
/** /**
* Used for both `getParameter` and `setParameter` since they mostly * Used for both `getParameter` and `setParameter` since they mostly
@@ -212,6 +215,14 @@ class Vst2Bridge {
boost::asio::local::stream_protocol::socket host_vst_parameters; boost::asio::local::stream_protocol::socket host_vst_parameters;
boost::asio::local::stream_protocol::socket host_vst_process_replacing; boost::asio::local::stream_protocol::socket host_vst_process_replacing;
/**
* A control socket that sends data that is not suitable for the other
* sockets. At the moment this is only used to, on startup, send the Windows
* VST plugin's `AEffect` object to the native VST plugin, and to then send
* the configuration (from `config`) back to the Wine host.
*/
boost::asio::local::stream_protocol::socket host_vst_control;
/** /**
* The thread that specifically handles `effProcessEvents` opcodes so the * The thread that specifically handles `effProcessEvents` opcodes so the
* plugin can still receive MIDI during GUI interaction to work around Win32 * plugin can still receive MIDI during GUI interaction to work around Win32