mirror of
https://github.com/robbert-vdh/yabridge.git
synced 2026-05-15 13:00:02 +02:00
Generate a unique ID and store the new component
This commit is contained in:
@@ -56,20 +56,14 @@ void Vst3Bridge::run() {
|
||||
Steinberg::IPtr<Steinberg::Vst::IComponent> component =
|
||||
module->getFactory()
|
||||
.createInstance<Steinberg::Vst::IComponent>(args.cid);
|
||||
|
||||
// TODO: Next steps are:
|
||||
// - Generate a new unique ID using an atomic size_t and
|
||||
// fetch-and-add.
|
||||
// - Add an `std::map<size_t,
|
||||
// Steinberg::IPtr<Steinberg::Vst::IComponent>`
|
||||
// to this class and add `component` with the generated
|
||||
// ID to that.
|
||||
// - Add that ID to `YaComponent` and set it in the object
|
||||
// we create here.
|
||||
if (component) {
|
||||
// TODO: Generate a unique instance ID
|
||||
std::lock_guard lock(component_instances_mutex);
|
||||
|
||||
const size_t instance_id = generate_instance_id();
|
||||
component_instances[instance_id] = std::move(component);
|
||||
|
||||
return std::make_optional<YaComponent::Arguments>(
|
||||
component, 420691337);
|
||||
component, instance_id);
|
||||
} else {
|
||||
return std::nullopt;
|
||||
}
|
||||
@@ -78,3 +72,7 @@ void Vst3Bridge::run() {
|
||||
return *plugin_factory;
|
||||
}});
|
||||
}
|
||||
|
||||
size_t Vst3Bridge::generate_instance_id() {
|
||||
return current_instance_id.fetch_add(1);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user