mirror of
https://github.com/robbert-vdh/yabridge.git
synced 2026-05-07 03:50:11 +02:00
Add audio thread callbacks
This commit is contained in:
@@ -328,6 +328,28 @@ class ClapSockets final : public Sockets {
|
||||
request_ref, response_ref, request_ref.get().instance_id, logging);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a message from the Wine plugin host to the native plugin to handle
|
||||
* an audio thread callback. Since those functions are called from a hot
|
||||
* loop we want every instance to have a dedicated socket and thread for
|
||||
* handling those. These calls also always reuse buffers to minimize
|
||||
* allocations.
|
||||
*
|
||||
* @tparam T Some object in the `ClapAudioThreadCallbackRequest` variant.
|
||||
* All of these objects need to have an `owner_instance_id` field.
|
||||
*/
|
||||
template <typename T>
|
||||
typename T::Response send_audio_thread_callback_message(
|
||||
const T& object,
|
||||
std::optional<std::pair<ClapLogger&, bool>> logging) {
|
||||
typename T::Response response_object;
|
||||
thread_local SerializationBuffer<256> audio_thread_buffer{};
|
||||
|
||||
return audio_thread_sockets_.at(object.owner_instance_id)
|
||||
.callback_.receive_into(object, response_object, logging,
|
||||
audio_thread_buffer);
|
||||
}
|
||||
|
||||
/**
|
||||
* For sending messages from the host to the plugin. After we have a better
|
||||
* idea of what our communication model looks like we'll probably want to
|
||||
|
||||
Reference in New Issue
Block a user