mirror of
https://github.com/robbert-vdh/yabridge.git
synced 2026-05-15 21:15:51 +02:00
Prevent data races in host callbacks
This commit is contained in:
@@ -268,8 +268,8 @@ intptr_t PluginBridge::host_callback(AEffect* /*plugin*/,
|
||||
void* data,
|
||||
float option) {
|
||||
HostCallbackDataConverter converter(plugin, time_info);
|
||||
return send_event(vst_host_callback, converter, opcode, index, value, data,
|
||||
option, std::nullopt);
|
||||
return send_event(vst_host_callback, host_callback_semaphore, converter,
|
||||
opcode, index, value, data, option, std::nullopt);
|
||||
}
|
||||
|
||||
intptr_t VST_CALL_CONV host_callback_proxy(AEffect* effect,
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
#include <windows.h>
|
||||
|
||||
#include <boost/asio/local/stream_protocol.hpp>
|
||||
#include <mutex>
|
||||
#include <thread>
|
||||
|
||||
#include "../common/logging.h"
|
||||
@@ -115,6 +116,13 @@ class PluginBridge {
|
||||
*/
|
||||
std::thread process_replacing_handler;
|
||||
|
||||
/**
|
||||
* A binary semaphore to prevent race conditions from the host callback
|
||||
* function being called by two threads at once. See `send_event()` for more
|
||||
* information.
|
||||
*/
|
||||
std::mutex host_callback_semaphore;
|
||||
|
||||
/**
|
||||
* A scratch buffer for sending and receiving data during `process` and
|
||||
* `processReplacing` calls.
|
||||
|
||||
Reference in New Issue
Block a user