diff --git a/README.md b/README.md index 0580ff21..b3c4cf78 100644 --- a/README.md +++ b/README.md @@ -419,7 +419,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 - `WineBridge::dispatch_wrapper`. On the receiving end of the function calls, + `Vst2Bridge::dispatch_wrapper`. On the receiving end of the function calls, the `passthrough_event()` function which 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 diff --git a/meson.build b/meson.build index fa04a7a2..ed88f111 100644 --- a/meson.build +++ b/meson.build @@ -86,10 +86,10 @@ shared_library( host_sources = [ 'src/common/logging.cpp', 'src/common/serialization.cpp', + 'src/wine-host/bridges/vst2.cpp', 'src/wine-host/editor.cpp', 'src/wine-host/editor.cpp', 'src/wine-host/utils.cpp', - 'src/wine-host/wine-bridge.cpp', version_header, ] diff --git a/src/plugin/plugin-bridge.cpp b/src/plugin/plugin-bridge.cpp index d9e08ac3..5f463605 100644 --- a/src/plugin/plugin-bridge.cpp +++ b/src/plugin/plugin-bridge.cpp @@ -165,7 +165,7 @@ PluginBridge::PluginBridge(audioMasterCallback host_callback) try { while (true) { // TODO: Think of a nicer way to structure this and the similar - // handler in `WineBridge::handle_dispatch_midi_events` + // handler in `Vst2Bridge::handle_dispatch_midi_events` receive_event( vst_host_callback, std::pair(logger, false), [&](Event& event) { diff --git a/src/plugin/plugin-bridge.h b/src/plugin/plugin-bridge.h index 8b7672fb..d26aff36 100644 --- a/src/plugin/plugin-bridge.h +++ b/src/plugin/plugin-bridge.h @@ -65,7 +65,7 @@ class PluginBridge { * 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 - * `WineBridge::handle_process_replacing()`. + * `Vst2Bridge::handle_process_replacing()`. */ void process_replacing(AEffect* plugin, float** inputs, diff --git a/src/wine-host/wine-bridge.cpp b/src/wine-host/bridges/vst2.cpp similarity index 94% rename from src/wine-host/wine-bridge.cpp rename to src/wine-host/bridges/vst2.cpp index 2adc9f39..22a6c861 100644 --- a/src/wine-host/wine-bridge.cpp +++ b/src/wine-host/bridges/vst2.cpp @@ -14,12 +14,12 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . -#include "wine-bridge.h" +#include "vst2.h" #include -#include "../common/communication.h" -#include "../common/events.h" +#include "../../common/communication.h" +#include "../../common/events.h" /** * A function pointer to what should be the entry point of a VST plugin. @@ -30,7 +30,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. */ -WineBridge* current_bridge_instance = nullptr; +Vst2Bridge* current_bridge_instance = nullptr; intptr_t VST_CALL_CONV host_callback_proxy(AEffect*, int, int, intptr_t, void*, float); @@ -43,12 +43,12 @@ uint32_t WINAPI handle_parameters_proxy(void*); uint32_t WINAPI handle_process_replacing_proxy(void*); /** - * Fetch the WineBridge instance stored in one of the two pointers reserved + * Fetch the Vst2Bridge 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. */ -WineBridge& get_bridge_instance(const AEffect* plugin) { +Vst2Bridge& 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) { @@ -57,10 +57,10 @@ WineBridge& get_bridge_instance(const AEffect* plugin) { return *current_bridge_instance; } - return *static_cast(plugin->ptr1); + return *static_cast(plugin->ptr1); } -WineBridge::WineBridge(std::string plugin_dll_path, +Vst2Bridge::Vst2Bridge(std::string plugin_dll_path, std::string socket_endpoint_path) : plugin_handle(LoadLibrary(plugin_dll_path.c_str()), FreeLibrary), io_context(), @@ -135,7 +135,7 @@ WineBridge::WineBridge(std::string plugin_dll_path, Win32Thread(handle_process_replacing_proxy, this); } -void WineBridge::handle_dispatch() { +void Vst2Bridge::handle_dispatch() { using namespace std::placeholders; // For our communication we use simple threads and blocking operations @@ -145,7 +145,7 @@ void WineBridge::handle_dispatch() { while (true) { receive_event(host_vst_dispatch, std::nullopt, passthrough_event( - plugin, std::bind(&WineBridge::dispatch_wrapper, + plugin, std::bind(&Vst2Bridge::dispatch_wrapper, this, _1, _2, _3, _4, _5, _6))); // Because of the way the Win32 API works we have to process events @@ -156,7 +156,7 @@ void WineBridge::handle_dispatch() { // run this loop. The only exception is a in specific situation that // can cause a race condition in some plugins because of incorrect // assumptions made by the plugin. See the dostring for - // `WineBridge::editor` for more information. + // `Vst2Bridge::editor` for more information. std::visit(overload{[](Editor& editor) { editor.handle_events(); }, [](std::monostate&) { MSG msg; @@ -170,7 +170,7 @@ void WineBridge::handle_dispatch() { [](EditorOpening&) { // Don't handle any events in this // particular case as explained in - // `WineBridge::editor` + // `Vst2Bridge::editor` }}, editor); } @@ -180,7 +180,7 @@ void WineBridge::handle_dispatch() { } } -[[noreturn]] void WineBridge::handle_dispatch_midi_events() { +[[noreturn]] void Vst2Bridge::handle_dispatch_midi_events() { while (true) { receive_event( host_vst_dispatch_midi_events, std::nullopt, [&](Event& event) { @@ -221,14 +221,14 @@ void WineBridge::handle_dispatch() { // Maybe this should just be a hard error instead, since it // should never happen return passthrough_event( - plugin, std::bind(&WineBridge::dispatch_wrapper, this, + plugin, std::bind(&Vst2Bridge::dispatch_wrapper, this, _1, _2, _3, _4, _5, _6))(event); } }); } } -[[noreturn]] void WineBridge::handle_parameters() { +[[noreturn]] void Vst2Bridge::handle_parameters() { while (true) { // Both `getParameter` and `setParameter` functions are passed // through on this socket since they have a lot of overlap. The @@ -251,7 +251,7 @@ void WineBridge::handle_dispatch() { } } -[[noreturn]] void WineBridge::handle_process_replacing() { +[[noreturn]] void Vst2Bridge::handle_process_replacing() { std::vector> output_buffers(plugin->numOutputs); while (true) { @@ -307,7 +307,7 @@ void WineBridge::handle_dispatch() { } } -intptr_t WineBridge::dispatch_wrapper(AEffect* plugin, +intptr_t Vst2Bridge::dispatch_wrapper(AEffect* plugin, int opcode, int index, intptr_t value, @@ -448,7 +448,7 @@ class HostCallbackDataConverter : DefaultDataConverter { std::optional& time_info; }; -intptr_t WineBridge::host_callback(AEffect* effect, +intptr_t Vst2Bridge::host_callback(AEffect* effect, int opcode, int index, intptr_t value, @@ -470,13 +470,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/wine-bridge.h b/src/wine-host/bridges/vst2.h similarity index 95% rename from src/wine-host/wine-bridge.h rename to src/wine-host/bridges/vst2.h index b48c2546..fb52af1a 100644 --- a/src/wine-host/wine-bridge.h +++ b/src/wine-host/bridges/vst2.h @@ -16,7 +16,7 @@ #pragma once -#include "boost-fix.h" +#include "../boost-fix.h" #define NOMINMAX #define NOSERVICE @@ -29,23 +29,23 @@ #include #include -#include "../common/logging.h" -#include "editor.h" -#include "utils.h" +#include "../../common/logging.h" +#include "../editor.h" +#include "../utils.h" /** * A marker struct to indicate that the editor is about to be opened. * - * @see WineBridge::editor + * @see Vst2Bridge::editor */ struct EditorOpening {}; /** * This handles the communication between the Linux native VST plugin and the - * Wine VST host. The functions below should be used as callback functions in an - * `AEffect` object. + * Wine VST host when hosting VST2 plugins. The functions below should be used + * as callback functions in an `AEffect` object. */ -class WineBridge { +class Vst2Bridge { public: /** * Initializes the Windows VST plugin and set up communication with the @@ -59,7 +59,7 @@ class WineBridge { * @throw std::runtime_error Thrown when the VST plugin could not be loaded, * or if communication could not be set up. */ - WineBridge(std::string plugin_dll_path, std::string socket_endpoint_path); + Vst2Bridge(std::string plugin_dll_path, std::string socket_endpoint_path); /** * Handle events on the main thread until the plugin quits. This can't be diff --git a/src/wine-host/group-host.cpp b/src/wine-host/group-host.cpp index 76a7450d..be2b8b41 100644 --- a/src/wine-host/group-host.cpp +++ b/src/wine-host/group-host.cpp @@ -29,7 +29,7 @@ #include #include -#include "wine-bridge.h" +#include "bridges/vst2.h" // FIXME: `std::filesystem` is broken in wineg++, at least under Wine 5.8. Any // path operation will thrown an encoding related error. diff --git a/src/wine-host/individual-host.cpp b/src/wine-host/individual-host.cpp index 1d8149a3..5aa8a314 100644 --- a/src/wine-host/individual-host.cpp +++ b/src/wine-host/individual-host.cpp @@ -20,7 +20,7 @@ #include #include -#include "wine-bridge.h" +#include "bridges/vst2.h" /** * This is the default VST host application. It will load the specified VST2 @@ -55,7 +55,7 @@ int __cdecl main(int argc, char* argv[]) { #endif << std::endl; try { - WineBridge bridge(plugin_dll_path, socket_endpoint_path); + Vst2Bridge bridge(plugin_dll_path, socket_endpoint_path); std::cerr << "Finished initializing '" << plugin_dll_path << "'" << std::endl;