Change argument order for event handling functions

This commit is contained in:
Robbert van der Helm
2020-03-17 00:53:09 +01:00
parent cdc2402bc8
commit 44a953c2d2
3 changed files with 20 additions and 19 deletions
+7 -7
View File
@@ -121,12 +121,12 @@ template <typename D>
intptr_t send_event(boost::asio::local::stream_protocol::socket& socket,
std::mutex& write_semaphore,
D& data_converter,
std::optional<std::pair<Logger&, bool>> logging,
int opcode,
int index,
intptr_t value,
void* data,
float option,
std::optional<std::pair<Logger&, bool>> 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 <typename F>
void passthrough_event(boost::asio::local::stream_protocol::socket& socket,
std::optional<std::pair<Logger&, bool>> logging,
AEffect* plugin,
F callback,
std::optional<std::pair<Logger&, bool>> logging) {
F callback) {
auto event = read_object<Event>(socket);
if (logging.has_value()) {
auto [logger, is_dispatch] = logging.value();
+8 -8
View File
@@ -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&, bool>(logger, false));
passthrough_event(vst_host_callback,
std::pair<Logger&, bool>(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&, bool>(logger, true));
std::pair<Logger&, bool>(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&, bool>(logger, true));
return send_event(host_vst_dispatch, dispatch_semaphore, converter,
std::pair<Logger&, bool>(logger, true), opcode, index,
value, data, option);
}
void HostBridge::process_replacing(AEffect* /*plugin*/,
+5 -4
View File
@@ -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,