mirror of
https://github.com/robbert-vdh/yabridge.git
synced 2026-05-07 12:10:09 +02:00
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:
@@ -58,6 +58,7 @@ PluginBridge::PluginBridge(audioMasterCallback host_callback)
|
||||
vst_host_callback(io_context),
|
||||
host_vst_parameters(io_context),
|
||||
host_vst_process_replacing(io_context),
|
||||
host_vst_control(io_context),
|
||||
host_callback_function(host_callback),
|
||||
logger(Logger::create_from_environment(
|
||||
create_logger_prefix(socket_endpoint.path()))),
|
||||
@@ -109,6 +110,7 @@ PluginBridge::PluginBridge(audioMasterCallback host_callback)
|
||||
socket_acceptor.accept(vst_host_callback);
|
||||
socket_acceptor.accept(host_vst_parameters);
|
||||
socket_acceptor.accept(host_vst_process_replacing);
|
||||
socket_acceptor.accept(host_vst_control);
|
||||
|
||||
#ifndef WITH_WINEDBG
|
||||
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
|
||||
// done after we started accepting host callbacks as the plugin will likely
|
||||
// call these during its initialization. We reuse the `dispatcher()` socket
|
||||
// for this since this has to be done only once.
|
||||
const auto initialization_data =
|
||||
read_object<EventResult>(host_vst_dispatch);
|
||||
// call these during its initialization. Any further updates will be sent
|
||||
// over the `dispatcher()` socket. This would happen whenever the plugin
|
||||
// calls `audioMasterIOChanged()` and after the host calls `effOpen()`.
|
||||
const auto initialization_data = read_object<EventResult>(host_vst_control);
|
||||
const auto initialized_plugin =
|
||||
std::get<AEffect>(initialization_data.payload);
|
||||
|
||||
|
||||
@@ -109,8 +109,7 @@ class PluginBridge {
|
||||
|
||||
/**
|
||||
* 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 `AEffect` object.
|
||||
* the plugin.
|
||||
*/
|
||||
boost::asio::local::stream_protocol::socket host_vst_dispatch;
|
||||
/**
|
||||
@@ -120,6 +119,10 @@ class PluginBridge {
|
||||
* this MIDI input would just stop working at times.
|
||||
*/
|
||||
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;
|
||||
/**
|
||||
* 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_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.
|
||||
*/
|
||||
|
||||
@@ -75,7 +75,8 @@ Vst2Bridge::Vst2Bridge(boost::asio::io_context& main_context,
|
||||
host_vst_dispatch_midi_events(io_context),
|
||||
vst_host_callback(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
|
||||
if (!plugin_handle) {
|
||||
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);
|
||||
host_vst_parameters.connect(socket_endpoint);
|
||||
host_vst_process_replacing.connect(socket_endpoint);
|
||||
host_vst_control.connect(socket_endpoint);
|
||||
|
||||
// Initialize after communication has been set up
|
||||
// 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;
|
||||
}
|
||||
|
||||
// Send the plugin's information to the Linux VST plugin. This is done over
|
||||
// the `dispatch()` socket since this has to be done only once during
|
||||
// initialization. Any updates during runtime are handled using the
|
||||
// `audioMasterIOChanged` host callback.
|
||||
write_object(host_vst_dispatch, EventResult{0, *plugin, std::nullopt});
|
||||
// Send the plugin's information to the Linux VST plugin. Any other updates
|
||||
// of this object will be sent over the `dispatcher()` socket. This would be
|
||||
// done after the host calls `effOpen()`, and when the plugin calls
|
||||
// `audioMasterIOChanged()`.
|
||||
write_object(host_vst_control, EventResult{0, *plugin, std::nullopt});
|
||||
|
||||
// This works functionally identically to the `handle_dispatch()` function,
|
||||
// but this socket will only handle MIDI events and it will handle them
|
||||
|
||||
@@ -193,8 +193,7 @@ class Vst2Bridge {
|
||||
|
||||
/**
|
||||
* 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 `AEffect` object.
|
||||
* the plugin.
|
||||
*/
|
||||
boost::asio::local::stream_protocol::socket host_vst_dispatch;
|
||||
/**
|
||||
@@ -204,6 +203,10 @@ class Vst2Bridge {
|
||||
* this MIDI input would just stop working at times.
|
||||
*/
|
||||
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;
|
||||
/**
|
||||
* 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_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
|
||||
* plugin can still receive MIDI during GUI interaction to work around Win32
|
||||
|
||||
Reference in New Issue
Block a user