mirror of
https://github.com/robbert-vdh/yabridge.git
synced 2026-05-08 04:20:13 +02:00
Allocate shared memory audio buffers for CLAP
This commit is contained in:
@@ -110,7 +110,7 @@ bool CLAP_ABI clap_plugin_proxy::plugin_activate(
|
||||
uint32_t min_frames_count,
|
||||
uint32_t max_frames_count) {
|
||||
assert(plugin && plugin->plugin_data);
|
||||
auto self = static_cast<const clap_plugin_proxy*>(plugin->plugin_data);
|
||||
auto self = static_cast<clap_plugin_proxy*>(plugin->plugin_data);
|
||||
|
||||
const clap::plugin::ActivateResponse response =
|
||||
self->bridge_.send_main_thread_message(
|
||||
@@ -119,8 +119,16 @@ bool CLAP_ABI clap_plugin_proxy::plugin_activate(
|
||||
.min_frames_count = min_frames_count,
|
||||
.max_frames_count = max_frames_count});
|
||||
|
||||
// The shared memory audio buffers are allocated here so we can use them
|
||||
// during audio processing
|
||||
if (response.updated_audio_buffers_config) {
|
||||
// TODO: Set up the shared memory audio buffers
|
||||
if (!self->process_buffers_) {
|
||||
self->process_buffers_.emplace(
|
||||
*response.updated_audio_buffers_config);
|
||||
} else {
|
||||
self->process_buffers_->resize(
|
||||
*response.updated_audio_buffers_config);
|
||||
}
|
||||
}
|
||||
|
||||
return response.result;
|
||||
|
||||
@@ -184,6 +184,17 @@ class clap_plugin_proxy {
|
||||
size_t instance_id_;
|
||||
clap::plugin::Descriptor descriptor_;
|
||||
|
||||
/**
|
||||
* A shared memory object to share audio buffers between the native plugin
|
||||
* and the Wine plugin host. Copying audio is the most significant source of
|
||||
* bridging overhead during audio processing, and this way we can reduce the
|
||||
* amount of copies required to only once for the input audio, and one more
|
||||
* copy when copying the results back to the host.
|
||||
*
|
||||
* This will be set up during `clap_plugin::activate()`.
|
||||
*/
|
||||
std::optional<AudioShmBuffer> process_buffers_;
|
||||
|
||||
/**
|
||||
* The vtable for `clap_plugin`, requires that this object is never moved or
|
||||
* copied. We'll use the host data pointer instead of placing this vtable at
|
||||
|
||||
Reference in New Issue
Block a user