mirror of
https://github.com/robbert-vdh/yabridge.git
synced 2026-05-08 04:20:13 +02:00
Use a thread for dispatch events
This commit is contained in:
@@ -95,10 +95,15 @@ HostBridge::HostBridge(audioMasterCallback host_callback)
|
||||
plugin.getParameter = getParameter_proxy;
|
||||
plugin.processReplacing = process_replacing_proxy;
|
||||
|
||||
// TODO: Replace manual thread creation with an async_read loop
|
||||
// Start accepting host callbacks after we've set up our sockets and basic
|
||||
// `AEffect` struct.
|
||||
removeme = std::thread([&]() { return host_callback_loop(); });
|
||||
// For our communication we use simple threads and blocking operations
|
||||
// instead of asynchronous IO since communication has to be handled in
|
||||
// lockstep anyway
|
||||
host_callback_handler = std::thread([&]() {
|
||||
while (true) {
|
||||
passthrough_event(vst_host_callback, &plugin,
|
||||
host_callback_function);
|
||||
}
|
||||
});
|
||||
|
||||
// Read the plugin's information from the Wine process. This can only be
|
||||
// done after we started accepting host callbacks as the plugin might do
|
||||
@@ -261,15 +266,6 @@ fs::path generate_endpoint_name() {
|
||||
return candidate_endpoint;
|
||||
}
|
||||
|
||||
// TODO: Replace blocking loop with async readers or threads for all of the
|
||||
// sockets. Also extract this functionality somewhere since the host event
|
||||
// callback needs to do exactly the same thing.
|
||||
void HostBridge::host_callback_loop() {
|
||||
while (true) {
|
||||
passthrough_event(vst_host_callback, &plugin, host_callback_function);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Locate the wineprefix and set the `WINEPREFIX` environment variable if found.
|
||||
* This way it's also possible to run .dll files outside of a wineprefix using
|
||||
|
||||
@@ -21,7 +21,6 @@
|
||||
#include <boost/asio/io_context.hpp>
|
||||
#include <boost/asio/local/stream_protocol.hpp>
|
||||
#include <boost/process/child.hpp>
|
||||
// TODO: Remove
|
||||
#include <thread>
|
||||
|
||||
/**
|
||||
@@ -67,9 +66,6 @@ class HostBridge {
|
||||
void set_parameter(AEffect* plugin, int32_t index, float value);
|
||||
float get_parameter(AEffect* plugin, int32_t index);
|
||||
|
||||
// TODO: Remove debug loop
|
||||
void host_callback_loop();
|
||||
|
||||
/**
|
||||
* This AEffect struct will be populated using the data passed by the Wine
|
||||
* VST host during initialization and then passed as a pointer to the Linux
|
||||
@@ -96,12 +92,15 @@ class HostBridge {
|
||||
*/
|
||||
boost::asio::local::stream_protocol::socket vst_host_aeffect;
|
||||
|
||||
/**
|
||||
* The thread that handles host callbacks.
|
||||
*/
|
||||
std::thread host_callback_handler;
|
||||
|
||||
/**
|
||||
* The callback function passed by the host to the VST plugin instance.
|
||||
*/
|
||||
audioMasterCallback host_callback_function;
|
||||
// TODO: Remove
|
||||
std::thread removeme;
|
||||
/**
|
||||
* The Wine process hosting the Windows VST plugin.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user