From 44a953c2d2753f52bcf2c81600643c1d0dfd6192 Mon Sep 17 00:00:00 2001 From: Robbert van der Helm Date: Tue, 17 Mar 2020 00:53:09 +0100 Subject: [PATCH] Change argument order for event handling functions --- src/common/events.h | 14 +++++++------- src/plugin/host-bridge.cpp | 16 ++++++++-------- src/wine-host/plugin-bridge.cpp | 9 +++++---- 3 files changed, 20 insertions(+), 19 deletions(-) diff --git a/src/common/events.h b/src/common/events.h index e36ac232..c03707ed 100644 --- a/src/common/events.h +++ b/src/common/events.h @@ -121,12 +121,12 @@ template intptr_t send_event(boost::asio::local::stream_protocol::socket& socket, std::mutex& write_semaphore, D& data_converter, + std::optional> logging, int opcode, int index, intptr_t value, void* data, - float option, - std::optional> logging) { + float option) { // Encode the right payload type for this event. Check the documentation for // `EventPayload` for more information. We have to skip some opcodes because // some VST hsots will outright crash if they receive them, please let me @@ -173,21 +173,21 @@ intptr_t send_event(boost::asio::local::stream_protocol::socket& socket, * those functions. * * @param socket The socket to receive on and to send the response back to. + * @param logging A pair containing a logger instance and whether or not this is + * for sending `dispatch()` events or host callbacks. Optional since it + * doesn't have to be done on both sides. * @param plugin The `AEffect` instance that should be passed to the callback * function. * @param callback The function to call with the arguments received from the * socket. - * @param logging A pair containing a logger instance and whether or not this is - * for sending `dispatch()` events or host callbacks. Optional since it - * doesn't have to be done on both sides. * * @relates send_event */ template void passthrough_event(boost::asio::local::stream_protocol::socket& socket, + std::optional> logging, AEffect* plugin, - F callback, - std::optional> logging) { + F callback) { auto event = read_object(socket); if (logging.has_value()) { auto [logger, is_dispatch] = logging.value(); diff --git a/src/plugin/host-bridge.cpp b/src/plugin/host-bridge.cpp index 7ecf2418..965e82c5 100644 --- a/src/plugin/host-bridge.cpp +++ b/src/plugin/host-bridge.cpp @@ -147,9 +147,9 @@ HostBridge::HostBridge(audioMasterCallback host_callback) host_callback_handler = std::thread([&]() { try { while (true) { - passthrough_event(vst_host_callback, &plugin, - host_callback_function, - std::pair(logger, false)); + passthrough_event(vst_host_callback, + std::pair(logger, false), + &plugin, host_callback_function); } } catch (const boost::system::system_error&) { // This happens when the sockets got closed because the plugin @@ -270,8 +270,8 @@ intptr_t HostBridge::dispatch(AEffect* /*plugin*/, try { return_value = send_event(host_vst_dispatch, dispatch_semaphore, converter, - opcode, index, value, data, option, - std::pair(logger, true)); + std::pair(logger, true), opcode, + index, value, data, option); } catch (const boost::system::system_error& a) { // Thrown when the socket gets closed because the VST plugin // loaded into the Wine process crashed during shutdown @@ -306,9 +306,9 @@ intptr_t HostBridge::dispatch(AEffect* /*plugin*/, } // TODO: Maybe reuse buffers here when dealing with chunk data - return send_event(host_vst_dispatch, dispatch_semaphore, converter, opcode, - index, value, data, option, - std::pair(logger, true)); + return send_event(host_vst_dispatch, dispatch_semaphore, converter, + std::pair(logger, true), opcode, index, + value, data, option); } void HostBridge::process_replacing(AEffect* /*plugin*/, diff --git a/src/wine-host/plugin-bridge.cpp b/src/wine-host/plugin-bridge.cpp index 7d35a0b8..44c44bd8 100644 --- a/src/wine-host/plugin-bridge.cpp +++ b/src/wine-host/plugin-bridge.cpp @@ -65,7 +65,8 @@ PluginBridge::PluginBridge(std::string plugin_dll_path, vst_host_callback(io_context), host_vst_parameters(io_context), host_vst_process_replacing(io_context), - vst_host_aeffect(io_context) { + vst_host_aeffect(io_context), + editor("yabridge plugin") { // Got to love these C APIs if (plugin_handle == nullptr) { throw std::runtime_error("Could not load a shared library at '" + @@ -122,8 +123,8 @@ PluginBridge::PluginBridge(std::string plugin_dll_path, // lockstep anyway dispatch_handler = std::thread([&]() { while (true) { - passthrough_event(host_vst_dispatch, plugin, plugin->dispatcher, - std::nullopt); + passthrough_event(host_vst_dispatch, std::nullopt, plugin, + plugin->dispatcher); } }); @@ -269,7 +270,7 @@ intptr_t PluginBridge::host_callback(AEffect* /*plugin*/, float option) { HostCallbackDataConverter converter(plugin, time_info); return send_event(vst_host_callback, host_callback_semaphore, converter, - opcode, index, value, data, option, std::nullopt); + std::nullopt, opcode, index, value, data, option); } intptr_t VST_CALL_CONV host_callback_proxy(AEffect* effect,