mirror of
https://github.com/robbert-vdh/yabridge.git
synced 2026-05-09 20:29:10 +02:00
Skip main thread requirement in array lookups
This should be fine, right? We'll do it everywhere else, but especially for parameters this is going to be very costly and may thus increase plugin startup time by a noticeable amount if we spool every individual call to the main thread.
This commit is contained in:
@@ -313,65 +313,53 @@ void ClapBridge::run() {
|
|||||||
-> clap::ext::audio_ports::plugin::Count::Response {
|
-> clap::ext::audio_ports::plugin::Count::Response {
|
||||||
const auto& [instance, _] = get_instance(request.instance_id);
|
const auto& [instance, _] = get_instance(request.instance_id);
|
||||||
|
|
||||||
return main_context_
|
// We'll ignore the main thread requirement for simple array
|
||||||
.run_in_context(
|
// lookups to avoid the synchronisation costs in code code paths
|
||||||
[&, plugin = instance.plugin.get(),
|
return instance.extensions.audio_ports->count(
|
||||||
audio_ports = instance.extensions.audio_ports]() {
|
instance.plugin.get(), request.is_input);
|
||||||
return audio_ports->count(plugin, request.is_input);
|
|
||||||
})
|
|
||||||
.get();
|
|
||||||
},
|
},
|
||||||
[&](const clap::ext::audio_ports::plugin::Get& request)
|
[&](const clap::ext::audio_ports::plugin::Get& request)
|
||||||
-> clap::ext::audio_ports::plugin::Get::Response {
|
-> clap::ext::audio_ports::plugin::Get::Response {
|
||||||
const auto& [instance, _] = get_instance(request.instance_id);
|
const auto& [instance, _] = get_instance(request.instance_id);
|
||||||
|
|
||||||
return main_context_
|
// We'll ignore the main thread requirement for simple array
|
||||||
.run_in_context([&, plugin = instance.plugin.get(),
|
// lookups to avoid the synchronisation costs in code code paths
|
||||||
audio_ports =
|
clap_audio_port_info_t info{};
|
||||||
instance.extensions.audio_ports]() {
|
if (instance.extensions.audio_ports->get(
|
||||||
clap_audio_port_info_t info{};
|
instance.plugin.get(), request.index, request.is_input,
|
||||||
if (audio_ports->get(plugin, request.index,
|
&info)) {
|
||||||
request.is_input, &info)) {
|
return clap::ext::audio_ports::plugin::GetResponse{
|
||||||
return clap::ext::audio_ports::plugin::GetResponse{
|
.result = info};
|
||||||
.result = info};
|
} else {
|
||||||
} else {
|
return clap::ext::audio_ports::plugin::GetResponse{
|
||||||
return clap::ext::audio_ports::plugin::GetResponse{
|
.result = std::nullopt};
|
||||||
.result = std::nullopt};
|
}
|
||||||
}
|
|
||||||
})
|
|
||||||
.get();
|
|
||||||
},
|
},
|
||||||
[&](const clap::ext::note_ports::plugin::Count& request)
|
[&](const clap::ext::note_ports::plugin::Count& request)
|
||||||
-> clap::ext::note_ports::plugin::Count::Response {
|
-> clap::ext::note_ports::plugin::Count::Response {
|
||||||
const auto& [instance, _] = get_instance(request.instance_id);
|
const auto& [instance, _] = get_instance(request.instance_id);
|
||||||
|
|
||||||
return main_context_
|
// We'll ignore the main thread requirement for simple array
|
||||||
.run_in_context(
|
// lookups to avoid the synchronisation costs in code code paths
|
||||||
[&, plugin = instance.plugin.get(),
|
return instance.extensions.note_ports->count(
|
||||||
note_ports = instance.extensions.note_ports]() {
|
instance.plugin.get(), request.is_input);
|
||||||
return note_ports->count(plugin, request.is_input);
|
|
||||||
})
|
|
||||||
.get();
|
|
||||||
},
|
},
|
||||||
[&](const clap::ext::note_ports::plugin::Get& request)
|
[&](const clap::ext::note_ports::plugin::Get& request)
|
||||||
-> clap::ext::note_ports::plugin::Get::Response {
|
-> clap::ext::note_ports::plugin::Get::Response {
|
||||||
const auto& [instance, _] = get_instance(request.instance_id);
|
const auto& [instance, _] = get_instance(request.instance_id);
|
||||||
|
|
||||||
return main_context_
|
// We'll ignore the main thread requirement for simple array
|
||||||
.run_in_context([&, plugin = instance.plugin.get(),
|
// lookups to avoid the synchronisation costs in code code paths
|
||||||
note_ports =
|
clap_note_port_info_t info{};
|
||||||
instance.extensions.note_ports]() {
|
if (instance.extensions.note_ports->get(
|
||||||
clap_note_port_info_t info{};
|
instance.plugin.get(), request.index, request.is_input,
|
||||||
if (note_ports->get(plugin, request.index,
|
&info)) {
|
||||||
request.is_input, &info)) {
|
return clap::ext::note_ports::plugin::GetResponse{.result =
|
||||||
return clap::ext::note_ports::plugin::GetResponse{
|
info};
|
||||||
.result = info};
|
} else {
|
||||||
} else {
|
return clap::ext::note_ports::plugin::GetResponse{
|
||||||
return clap::ext::note_ports::plugin::GetResponse{
|
.result = std::nullopt};
|
||||||
.result = std::nullopt};
|
}
|
||||||
}
|
|
||||||
})
|
|
||||||
.get();
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user