mirror of
https://github.com/robbert-vdh/yabridge.git
synced 2026-06-16 16:33:55 +02:00
Change argument order for event handling functions
This commit is contained in:
+7
-7
@@ -121,12 +121,12 @@ template <typename D>
|
|||||||
intptr_t send_event(boost::asio::local::stream_protocol::socket& socket,
|
intptr_t send_event(boost::asio::local::stream_protocol::socket& socket,
|
||||||
std::mutex& write_semaphore,
|
std::mutex& write_semaphore,
|
||||||
D& data_converter,
|
D& data_converter,
|
||||||
|
std::optional<std::pair<Logger&, bool>> logging,
|
||||||
int opcode,
|
int opcode,
|
||||||
int index,
|
int index,
|
||||||
intptr_t value,
|
intptr_t value,
|
||||||
void* data,
|
void* data,
|
||||||
float option,
|
float option) {
|
||||||
std::optional<std::pair<Logger&, bool>> logging) {
|
|
||||||
// Encode the right payload type for this event. Check the documentation for
|
// Encode the right payload type for this event. Check the documentation for
|
||||||
// `EventPayload` for more information. We have to skip some opcodes because
|
// `EventPayload` for more information. We have to skip some opcodes because
|
||||||
// some VST hsots will outright crash if they receive them, please let me
|
// 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.
|
* those functions.
|
||||||
*
|
*
|
||||||
* @param socket The socket to receive on and to send the response back to.
|
* @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
|
* @param plugin The `AEffect` instance that should be passed to the callback
|
||||||
* function.
|
* function.
|
||||||
* @param callback The function to call with the arguments received from the
|
* @param callback The function to call with the arguments received from the
|
||||||
* socket.
|
* 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
|
* @relates send_event
|
||||||
*/
|
*/
|
||||||
template <typename F>
|
template <typename F>
|
||||||
void passthrough_event(boost::asio::local::stream_protocol::socket& socket,
|
void passthrough_event(boost::asio::local::stream_protocol::socket& socket,
|
||||||
|
std::optional<std::pair<Logger&, bool>> logging,
|
||||||
AEffect* plugin,
|
AEffect* plugin,
|
||||||
F callback,
|
F callback) {
|
||||||
std::optional<std::pair<Logger&, bool>> logging) {
|
|
||||||
auto event = read_object<Event>(socket);
|
auto event = read_object<Event>(socket);
|
||||||
if (logging.has_value()) {
|
if (logging.has_value()) {
|
||||||
auto [logger, is_dispatch] = logging.value();
|
auto [logger, is_dispatch] = logging.value();
|
||||||
|
|||||||
@@ -147,9 +147,9 @@ HostBridge::HostBridge(audioMasterCallback host_callback)
|
|||||||
host_callback_handler = std::thread([&]() {
|
host_callback_handler = std::thread([&]() {
|
||||||
try {
|
try {
|
||||||
while (true) {
|
while (true) {
|
||||||
passthrough_event(vst_host_callback, &plugin,
|
passthrough_event(vst_host_callback,
|
||||||
host_callback_function,
|
std::pair<Logger&, bool>(logger, false),
|
||||||
std::pair<Logger&, bool>(logger, false));
|
&plugin, host_callback_function);
|
||||||
}
|
}
|
||||||
} catch (const boost::system::system_error&) {
|
} catch (const boost::system::system_error&) {
|
||||||
// This happens when the sockets got closed because the plugin
|
// This happens when the sockets got closed because the plugin
|
||||||
@@ -270,8 +270,8 @@ intptr_t HostBridge::dispatch(AEffect* /*plugin*/,
|
|||||||
try {
|
try {
|
||||||
return_value =
|
return_value =
|
||||||
send_event(host_vst_dispatch, dispatch_semaphore, converter,
|
send_event(host_vst_dispatch, dispatch_semaphore, converter,
|
||||||
opcode, index, value, data, option,
|
std::pair<Logger&, bool>(logger, true), opcode,
|
||||||
std::pair<Logger&, bool>(logger, true));
|
index, value, data, option);
|
||||||
} catch (const boost::system::system_error& a) {
|
} catch (const boost::system::system_error& a) {
|
||||||
// Thrown when the socket gets closed because the VST plugin
|
// Thrown when the socket gets closed because the VST plugin
|
||||||
// loaded into the Wine process crashed during shutdown
|
// 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
|
// TODO: Maybe reuse buffers here when dealing with chunk data
|
||||||
return send_event(host_vst_dispatch, dispatch_semaphore, converter, opcode,
|
return send_event(host_vst_dispatch, dispatch_semaphore, converter,
|
||||||
index, value, data, option,
|
std::pair<Logger&, bool>(logger, true), opcode, index,
|
||||||
std::pair<Logger&, bool>(logger, true));
|
value, data, option);
|
||||||
}
|
}
|
||||||
|
|
||||||
void HostBridge::process_replacing(AEffect* /*plugin*/,
|
void HostBridge::process_replacing(AEffect* /*plugin*/,
|
||||||
|
|||||||
@@ -65,7 +65,8 @@ PluginBridge::PluginBridge(std::string plugin_dll_path,
|
|||||||
vst_host_callback(io_context),
|
vst_host_callback(io_context),
|
||||||
host_vst_parameters(io_context),
|
host_vst_parameters(io_context),
|
||||||
host_vst_process_replacing(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
|
// Got to love these C APIs
|
||||||
if (plugin_handle == nullptr) {
|
if (plugin_handle == nullptr) {
|
||||||
throw std::runtime_error("Could not load a shared library at '" +
|
throw std::runtime_error("Could not load a shared library at '" +
|
||||||
@@ -122,8 +123,8 @@ PluginBridge::PluginBridge(std::string plugin_dll_path,
|
|||||||
// lockstep anyway
|
// lockstep anyway
|
||||||
dispatch_handler = std::thread([&]() {
|
dispatch_handler = std::thread([&]() {
|
||||||
while (true) {
|
while (true) {
|
||||||
passthrough_event(host_vst_dispatch, plugin, plugin->dispatcher,
|
passthrough_event(host_vst_dispatch, std::nullopt, plugin,
|
||||||
std::nullopt);
|
plugin->dispatcher);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -269,7 +270,7 @@ intptr_t PluginBridge::host_callback(AEffect* /*plugin*/,
|
|||||||
float option) {
|
float option) {
|
||||||
HostCallbackDataConverter converter(plugin, time_info);
|
HostCallbackDataConverter converter(plugin, time_info);
|
||||||
return send_event(vst_host_callback, host_callback_semaphore, converter,
|
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,
|
intptr_t VST_CALL_CONV host_callback_proxy(AEffect* effect,
|
||||||
|
|||||||
Reference in New Issue
Block a user