From 2d0998047cabf5ec07dc9cd1a97b7ae7cef85cb9 Mon Sep 17 00:00:00 2001 From: Robbert van der Helm Date: Thu, 7 May 2020 13:04:00 +0200 Subject: [PATCH] :boom: Rename PluginBridge to WineBridge I had swapped these names around once before but I think going with PluginBridge for the plugin and WineBridge for the Wine VST host is the least ambiguous it can get. --- README.md | 2 +- meson.build | 2 +- src/plugin/host-bridge.cpp | 2 +- src/plugin/host-bridge.h | 2 +- src/wine-host/vst-host.cpp | 4 +- .../{plugin-bridge.cpp => wine-bridge.cpp} | 56 +++++++++---------- .../{plugin-bridge.h => wine-bridge.h} | 4 +- 7 files changed, 36 insertions(+), 36 deletions(-) rename src/wine-host/{plugin-bridge.cpp => wine-bridge.cpp} (91%) rename src/wine-host/{plugin-bridge.h => wine-bridge.h} (98%) diff --git a/README.md b/README.md index c9a07e58..08838056 100644 --- a/README.md +++ b/README.md @@ -369,7 +369,7 @@ as the _Windows VST plugin_. The whole process works as follows: in the `DispatchDataConverter` and `HostCallbackDataCovnerter` classes for the `dispatcher()` and `audioMaster()` functions respectively. For operations involving the plugin editor there is also some extra glue in - `PluginBridge::dispatch_wrapper`. On the receiving end of the function calls, + `WineBridge::dispatch_wrapper`. On the receiving end of the function calls, the `passthrough_event()` function calls the callback functions and handles the marshalling between our data types created by the `*DataConverter` classes and the VST API's different pointer types. This behaviour is diff --git a/meson.build b/meson.build index 9c76f11f..04b5bcfe 100644 --- a/meson.build +++ b/meson.build @@ -76,8 +76,8 @@ host_sources = [ 'src/common/serialization.cpp', 'src/wine-host/editor.cpp', 'src/wine-host/editor.cpp', - 'src/wine-host/plugin-bridge.cpp', 'src/wine-host/vst-host.cpp', + 'src/wine-host/wine-bridge.cpp', 'src/wine-host/utils.cpp', version_header, ] diff --git a/src/plugin/host-bridge.cpp b/src/plugin/host-bridge.cpp index 47564901..325d11d3 100644 --- a/src/plugin/host-bridge.cpp +++ b/src/plugin/host-bridge.cpp @@ -260,7 +260,7 @@ HostBridge::HostBridge(audioMasterCallback host_callback) try { while (true) { // TODO: Think of a nicer way to structure this and the similar - // handler in `PluginBridge::handle_dispatch_midi_events` + // handler in `WineBridge::handle_dispatch_midi_events` receive_event( vst_host_callback, std::pair(logger, false), [&](Event& event) { diff --git a/src/plugin/host-bridge.h b/src/plugin/host-bridge.h index 3b04ba35..83195113 100644 --- a/src/plugin/host-bridge.h +++ b/src/plugin/host-bridge.h @@ -87,7 +87,7 @@ class HostBridge { * Ask the VST plugin to process audio for us. If the plugin somehow does * not support `processReplacing()` and only supports the old `process()` * function, then this will be handled implicitely in - * `PluginBridge::handle_process_replacing()`. + * `WineBridge::handle_process_replacing()`. */ void process_replacing(AEffect* plugin, float** inputs, diff --git a/src/wine-host/vst-host.cpp b/src/wine-host/vst-host.cpp index 274ac272..44c947bd 100644 --- a/src/wine-host/vst-host.cpp +++ b/src/wine-host/vst-host.cpp @@ -20,7 +20,7 @@ #include #include -#include "plugin-bridge.h" +#include "wine-bridge.h" int main(int argc, char* argv[]) { // We pass the name of the VST plugin .dll file to load and the Unix domain @@ -47,7 +47,7 @@ int main(int argc, char* argv[]) { #endif << std::endl; try { - PluginBridge bridge(plugin_dll_path, socket_endpoint_path); + WineBridge bridge(plugin_dll_path, socket_endpoint_path); std::cerr << "Finished initializing '" << plugin_dll_path << "'" << std::endl; diff --git a/src/wine-host/plugin-bridge.cpp b/src/wine-host/wine-bridge.cpp similarity index 91% rename from src/wine-host/plugin-bridge.cpp rename to src/wine-host/wine-bridge.cpp index 0a76adef..943a3190 100644 --- a/src/wine-host/plugin-bridge.cpp +++ b/src/wine-host/wine-bridge.cpp @@ -14,7 +14,7 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . -#include "plugin-bridge.h" +#include "wine-bridge.h" #include @@ -34,7 +34,7 @@ using VstEntryPoint = AEffect*(VST_CALL_CONV*)(audioMasterCallback); * This ugly global is needed so we can get the instance of a `Brdige` class * from an `AEffect` when it performs a host callback during its initialization. */ -PluginBridge* current_bridge_instance = nullptr; +WineBridge* current_bridge_instance = nullptr; intptr_t VST_CALL_CONV host_callback_proxy(AEffect*, int, int, intptr_t, void*, float); @@ -47,12 +47,12 @@ uint32_t WINAPI handle_parameters_proxy(void*); uint32_t WINAPI handle_process_replacing_proxy(void*); /** - * Fetch the Pluginbridge instance stored in one of the two pointers reserved + * Fetch the WineBridge instance stored in one of the two pointers reserved * for the host of the hosted VST plugin. This is sadly needed as a workaround * to avoid using globals since we need free function pointers to interface with * the VST C API. */ -PluginBridge& get_bridge_instance(const AEffect* plugin) { +WineBridge& get_bridge_instance(const AEffect* plugin) { // This is needed during the initialization of the plugin since we can only // add our own pointer after it's done initializing if (current_bridge_instance != nullptr) { @@ -61,11 +61,11 @@ PluginBridge& get_bridge_instance(const AEffect* plugin) { return *current_bridge_instance; } - return *static_cast(plugin->ptr1); + return *static_cast(plugin->ptr1); } -PluginBridge::PluginBridge(std::string plugin_dll_path, - std::string socket_endpoint_path) +WineBridge::WineBridge(std::string plugin_dll_path, + std::string socket_endpoint_path) : plugin_handle(LoadLibrary(plugin_dll_path.c_str()), FreeLibrary), io_context(), socket_endpoint(socket_endpoint_path), @@ -139,7 +139,7 @@ PluginBridge::PluginBridge(std::string plugin_dll_path, Win32Thread(handle_process_replacing_proxy, this); } -void PluginBridge::handle_dispatch() { +void WineBridge::handle_dispatch() { using namespace std::placeholders; // For our communication we use simple threads and blocking operations @@ -149,7 +149,7 @@ void PluginBridge::handle_dispatch() { while (true) { receive_event(host_vst_dispatch, std::nullopt, passthrough_event( - plugin, std::bind(&PluginBridge::dispatch_wrapper, + plugin, std::bind(&WineBridge::dispatch_wrapper, this, _1, _2, _3, _4, _5, _6))); // Because of the way the Win32 API works we have to process events @@ -178,7 +178,7 @@ void PluginBridge::handle_dispatch() { } } -[[noreturn]] void PluginBridge::handle_dispatch_midi_events() { +[[noreturn]] void WineBridge::handle_dispatch_midi_events() { while (true) { receive_event( host_vst_dispatch_midi_events, std::nullopt, [&](Event& event) { @@ -219,14 +219,14 @@ void PluginBridge::handle_dispatch() { // Maybe this should just be a hard error instead, since it // should never happen return passthrough_event( - plugin, std::bind(&PluginBridge::dispatch_wrapper, this, + plugin, std::bind(&WineBridge::dispatch_wrapper, this, _1, _2, _3, _4, _5, _6))(event); } }); } } -[[noreturn]] void PluginBridge::handle_parameters() { +[[noreturn]] void WineBridge::handle_parameters() { while (true) { // Both `getParameter` and `setParameter` functions are passed // through on this socket since they have a lot of overlap. The @@ -249,7 +249,7 @@ void PluginBridge::handle_dispatch() { } } -[[noreturn]] void PluginBridge::handle_process_replacing() { +[[noreturn]] void WineBridge::handle_process_replacing() { std::vector> output_buffers(plugin->numOutputs); while (true) { @@ -306,12 +306,12 @@ void PluginBridge::handle_dispatch() { } } -intptr_t PluginBridge::dispatch_wrapper(AEffect* plugin, - int opcode, - int index, - intptr_t value, - void* data, - float option) { +intptr_t WineBridge::dispatch_wrapper(AEffect* plugin, + int opcode, + int index, + intptr_t value, + void* data, + float option) { // We have to intercept GUI open calls since we can't use // the X11 window handle passed by the host switch (opcode) { @@ -420,12 +420,12 @@ class HostCallbackDataConverter : DefaultDataConverter { std::optional& time_info; }; -intptr_t PluginBridge::host_callback(AEffect* effect, - int opcode, - int index, - intptr_t value, - void* data, - float option) { +intptr_t WineBridge::host_callback(AEffect* effect, + int opcode, + int index, + intptr_t value, + void* data, + float option) { HostCallbackDataConverter converter(effect, time_info); return send_event(vst_host_callback, host_callback_mutex, converter, std::nullopt, opcode, index, value, data, option); @@ -442,13 +442,13 @@ intptr_t VST_CALL_CONV host_callback_proxy(AEffect* effect, } uint32_t WINAPI handle_dispatch_midi_events_proxy(void* instance) { - static_cast(instance)->handle_dispatch_midi_events(); + static_cast(instance)->handle_dispatch_midi_events(); } uint32_t WINAPI handle_parameters_proxy(void* instance) { - static_cast(instance)->handle_parameters(); + static_cast(instance)->handle_parameters(); } uint32_t WINAPI handle_process_replacing_proxy(void* instance) { - static_cast(instance)->handle_process_replacing(); + static_cast(instance)->handle_process_replacing(); } diff --git a/src/wine-host/plugin-bridge.h b/src/wine-host/wine-bridge.h similarity index 98% rename from src/wine-host/plugin-bridge.h rename to src/wine-host/wine-bridge.h index 27186067..060eec21 100644 --- a/src/wine-host/plugin-bridge.h +++ b/src/wine-host/wine-bridge.h @@ -38,7 +38,7 @@ * Wine VST host. The functions below should be used as callback functions in an * `AEffect` object. */ -class PluginBridge { +class WineBridge { public: /** * Initializes the Windows VST plugin and set up communication with the @@ -52,7 +52,7 @@ class PluginBridge { * @throw std::runtime_error Thrown when the VST plugin could not be loaded, * or if communication could not be set up. */ - PluginBridge(std::string plugin_dll_path, std::string socket_endpoint_path); + WineBridge(std::string plugin_dll_path, std::string socket_endpoint_path); /** * Handle events on the main thread until the plugin quits. This can't be