mirror of
https://github.com/robbert-vdh/yabridge.git
synced 2026-05-06 19:40:10 +02:00
Add CLAP plugin activation and deactivation
Shared memory audio buffers are not yet set up.
This commit is contained in:
@@ -43,7 +43,9 @@ using ClapMainThreadControlRequest = std::variant<WantsConfiguration,
|
||||
clap::plugin_factory::List,
|
||||
clap::plugin_factory::Create,
|
||||
clap::plugin::Init,
|
||||
clap::plugin::Destroy>;
|
||||
clap::plugin::Destroy,
|
||||
clap::plugin::Activate,
|
||||
clap::plugin::Deactivate>;
|
||||
|
||||
template <typename S>
|
||||
void serialize(S& s, ClapMainThreadControlRequest& payload) {
|
||||
|
||||
@@ -80,8 +80,18 @@ bool CLAP_ABI clap_plugin_proxy::plugin_activate(
|
||||
assert(plugin && plugin->plugin_data);
|
||||
auto self = static_cast<const clap_plugin_proxy*>(plugin->plugin_data);
|
||||
|
||||
// TODO: Implement
|
||||
return false;
|
||||
const clap::plugin::ActivateResponse response =
|
||||
self->bridge_.send_main_thread_message(
|
||||
clap::plugin::Activate{.instance_id = self->instance_id(),
|
||||
.sample_rate = sample_rate,
|
||||
.min_frames_count = min_frames_count,
|
||||
.max_frames_count = max_frames_count});
|
||||
|
||||
if (response.updated_audio_buffers_config) {
|
||||
// TODO: Set up the shared memory audio buffers
|
||||
}
|
||||
|
||||
return response.result;
|
||||
}
|
||||
|
||||
void CLAP_ABI
|
||||
@@ -89,7 +99,8 @@ clap_plugin_proxy::plugin_deactivate(const struct clap_plugin* plugin) {
|
||||
assert(plugin && plugin->plugin_data);
|
||||
auto self = static_cast<const clap_plugin_proxy*>(plugin->plugin_data);
|
||||
|
||||
// TODO: Implement
|
||||
self->bridge_.send_main_thread_message(
|
||||
clap::plugin::Deactivate{.instance_id = self->instance_id()});
|
||||
}
|
||||
|
||||
bool CLAP_ABI
|
||||
|
||||
@@ -238,7 +238,6 @@ void ClapBridge::run() {
|
||||
})
|
||||
.get();
|
||||
},
|
||||
|
||||
[&](clap::plugin::Destroy& request)
|
||||
-> clap::plugin::Destroy::Response {
|
||||
return main_context_
|
||||
@@ -252,6 +251,41 @@ void ClapBridge::run() {
|
||||
})
|
||||
.get();
|
||||
},
|
||||
[&](clap::plugin::Activate& request)
|
||||
-> clap::plugin::Activate::Response {
|
||||
return main_context_
|
||||
.run_in_context([&]() {
|
||||
const auto& [instance, _] =
|
||||
get_instance(request.instance_id);
|
||||
|
||||
const bool result = instance.plugin->activate(
|
||||
instance.plugin.get(), request.sample_rate,
|
||||
request.min_frames_count, request.max_frames_count);
|
||||
|
||||
// TODO: Audio buffer setup
|
||||
const std::optional<AudioShmBuffer::Config>
|
||||
updated_audio_buffers_config;
|
||||
|
||||
return clap::plugin::ActivateResponse{
|
||||
.result = result,
|
||||
.updated_audio_buffers_config =
|
||||
std::move(updated_audio_buffers_config)};
|
||||
})
|
||||
.get();
|
||||
},
|
||||
[&](clap::plugin::Deactivate& request)
|
||||
-> clap::plugin::Deactivate::Response {
|
||||
return main_context_
|
||||
.run_in_context([&]() {
|
||||
const auto& [instance, _] =
|
||||
get_instance(request.instance_id);
|
||||
|
||||
instance.plugin->deactivate(instance.plugin.get());
|
||||
|
||||
return Ack{};
|
||||
})
|
||||
.get();
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user