diff --git a/src/common/communication/common.h b/src/common/communication/common.h index cabddd4f..4439d72b 100644 --- a/src/common/communication/common.h +++ b/src/common/communication/common.h @@ -195,7 +195,11 @@ class Sockets { /** * Depending on the value of the `listen` argument passed to the * constructor, either accept connections made to the sockets on the Linux - * side or connect to the sockets on the Wine side + * side or connect to the sockets on the Wine side. + * + * @remark On the plugin side `PluginBridge::connect_sockets_guarded()` + * should be used instead so we can terminate everything in the event that + * Wine fails to start. */ virtual void connect() = 0; diff --git a/src/plugin/bridges/vst3.cpp b/src/plugin/bridges/vst3.cpp index 5039126c..d1c7b02b 100644 --- a/src/plugin/bridges/vst3.cpp +++ b/src/plugin/bridges/vst3.cpp @@ -38,8 +38,20 @@ Vst3PluginBridge::Vst3PluginBridge() // host connect_sockets_guarded(); + // Now that communication is set up the Wine host can send callbacks to this + // bridge class, and we can send control messages to the Wine host. This + // messaging mechanism is how we relay the VST3 communication protocol. As a + // first thing, the Wine VST host will ask us for a copy of the + // configuration. host_callback_handler = std::jthread([&]() { - // TODO: Handle callbacks - // sockets.vst_host_callback.receive_multi(); + sockets.vst_host_callback.receive_messages( + std::pair(logger, false), + [&](CallbackRequest request) -> CallbackResponse { + return std::visit(overload{[&](const WantsConfiguration&) + -> WantsConfiguration::Response { + return config; + }}, + request); + }); }); } diff --git a/src/wine-host/bridges/common.h b/src/wine-host/bridges/common.h index eee60936..efefd9ee 100644 --- a/src/wine-host/bridges/common.h +++ b/src/wine-host/bridges/common.h @@ -78,7 +78,10 @@ class HostBridge { * Wine window, and embedding that Wine window into a window provided by the * host. Should be empty when the editor is not open. * - * @see should_postpone_message_loop + * TODO: This should be moved back to `Vst2Bridge`, `handle_x11_events()`` + * and `handle_win32_events()` should be made pure virtual. A single + * `Vst3Bridge` instance will handle multiple plugin instances because + * of the way VST3 works. */ std::optional editor; }; diff --git a/src/wine-host/bridges/vst2.h b/src/wine-host/bridges/vst2.h index 5f80c029..9062870f 100644 --- a/src/wine-host/bridges/vst2.h +++ b/src/wine-host/bridges/vst2.h @@ -63,6 +63,10 @@ class Vst2Bridge : public HostBridge { std::string plugin_dll_path, std::string endpoint_base_dir); + /** + * Here we'll handle incoming `dispatch()` messages until the sockets get + * closed during `effClose()`. + */ void run() override; /** diff --git a/src/wine-host/bridges/vst3.cpp b/src/wine-host/bridges/vst3.cpp index 71ad6bce..6830a090 100644 --- a/src/wine-host/bridges/vst3.cpp +++ b/src/wine-host/bridges/vst3.cpp @@ -45,16 +45,17 @@ Vst3Bridge::Vst3Bridge(MainContext& main_context, sockets.connect(); - // TODO: We should send a copy of the configuration from the plugin at this - // point config = sockets.host_vst_control.receive_single(); - - control_handler = Win32Thread([&]() { - // TODO: Handle control messages - // sockets.host_vst_control.receive_multi(); - }); + // Fetch this instance's configuration from the plugin to finish the setup + // process + config = sockets.vst_host_callback.send_message(WantsConfiguration{}, + std::nullopt); } void Vst3Bridge::run() { - // TODO: Do something + // TODO: Handle events + // sockets.host_vst_control.receive_messages( + // std::nullopt, [&](ControlRequest request) -> ControlResponse { + // }); + std::cerr << "TODO: Not yet implemented" << std::endl; } diff --git a/src/wine-host/bridges/vst3.h b/src/wine-host/bridges/vst3.h index 9dbb4be0..bb9e4804 100644 --- a/src/wine-host/bridges/vst3.h +++ b/src/wine-host/bridges/vst3.h @@ -52,6 +52,10 @@ class Vst3Bridge : public HostBridge { std::string plugin_dll_path, std::string endpoint_base_dir); + /** + * Here we'll listen for and handle incoming control messages until the + * sockets get closed. + */ void run() override; private: @@ -79,9 +83,4 @@ class Vst3Bridge : public HostBridge { * threads to exit. */ Vst3Sockets sockets; - - /** - * Handles control messages host over the `hsot_vst_control` sockets. - */ - Win32Thread control_handler; };