Add a basic CLAP plugin factory implementation

Which can only list plugins without creating them.
This commit is contained in:
Robbert van der Helm
2022-09-05 17:37:12 +02:00
parent 1339c20fc1
commit c36590abf5
5 changed files with 142 additions and 4 deletions
+6 -3
View File
@@ -43,7 +43,7 @@ descriptor::descriptor(const clap_plugin_descriptor_t& original)
}
}
clap_plugin_descriptor_t descriptor::get() const {
const clap_plugin_descriptor_t* descriptor::get() const {
// This should be the minimum of yabridge's supported CLAP version and
// the plugin's supported CLAP version
clap_version_t supported_clap_version = clap_version;
@@ -55,14 +55,15 @@ clap_plugin_descriptor_t descriptor::get() const {
supported_clap_version = CLAP_VERSION;
}
// `features_ptrs` needs to be populated as envp-style null terminated array
// `features_ptrs` needs to be populated as an envp-style null terminated
// array
features_ptrs.resize(features.size() + 1);
for (size_t i = 0; i < features.size(); i++) {
features_ptrs[i] = features[i].c_str();
}
features_ptrs[features.size()] = nullptr;
return clap_plugin_descriptor_t{
clap_descriptor = clap_plugin_descriptor_t{
.clap_version = supported_clap_version,
.id = id.c_str(),
.name = name.c_str(),
@@ -74,6 +75,8 @@ clap_plugin_descriptor_t descriptor::get() const {
.description = description ? description->c_str() : nullptr,
.features = features_ptrs.data(),
};
return &clap_descriptor;
}
} // namespace plugin