diff --git a/src/common/serialization/vst3/README.md b/src/common/serialization/vst3/README.md index d4a22cf9..12e801bf 100644 --- a/src/common/serialization/vst3/README.md +++ b/src/common/serialization/vst3/README.md @@ -70,6 +70,10 @@ instantiated and managed by the host. The basic model works as follows: native plugin in a `known_iids` set. In our query interface method we then only report support for the same interfaces that were supported by the original `IPtr component, size_t instance_id) : instance_id(instance_id) { + known_iids.insert(component->iid); // `IComponent::getControllerClassId` Steinberg::TUID cid; if (component->getControllerClassId(cid) == Steinberg::kResultOk) { edit_controller_cid = std::to_array(cid); } + + // TODO: Add support of IAudioProcessor } YaComponent::YaComponent(const ConstructArgs&& args) : arguments(std::move(args)) { @@ -48,10 +51,13 @@ IMPLEMENT_REFCOUNT(YaComponent) tresult PLUGIN_API YaComponent::queryInterface(Steinberg::FIDString _iid, void** obj) { QUERY_INTERFACE(_iid, obj, Steinberg::FUnknown::iid, Steinberg::IPluginBase) - QUERY_INTERFACE(_iid, obj, Steinberg::IPluginBase::iid, - Steinberg::IPluginBase) - QUERY_INTERFACE(_iid, obj, Steinberg::Vst::IComponent::iid, - Steinberg::Vst::IComponent) + if (arguments.known_iids.contains(Steinberg::Vst::IComponent::iid)) { + QUERY_INTERFACE(_iid, obj, Steinberg::IPluginBase::iid, + Steinberg::IPluginBase) + QUERY_INTERFACE(_iid, obj, Steinberg::Vst::IComponent::iid, + Steinberg::Vst::IComponent) + } + // TODO: Add IAudioProcessor *obj = nullptr; return Steinberg::kNoInterface; diff --git a/src/common/serialization/vst3/component.h b/src/common/serialization/vst3/component.h index 99789178..fe0216d2 100644 --- a/src/common/serialization/vst3/component.h +++ b/src/common/serialization/vst3/component.h @@ -17,14 +17,17 @@ #pragma once #include +#include #include #include #include +#include #include #include #include +#include "../../bitsery/ext/vst3.h" #include "../common.h" #include "base.h" #include "host-application.h" @@ -55,7 +58,9 @@ class YaComponent : public Steinberg::Vst::IComponent { ConstructArgs(); /** - * Read arguments from an existing implementation. + * Read arguments from an existing implementation. Depending on the + * supported interface function more or less of this struct will be left + * empty, and `known_iids` will be set accordingly. */ ConstructArgs(Steinberg::IPtr component, size_t instance_id); @@ -65,6 +70,11 @@ class YaComponent : public Steinberg::Vst::IComponent { */ native_size_t instance_id; + /** + * The IIDs that the interface we serialized supports. + */ + std::set known_iids; + /** * The class ID of this component's corresponding editor controller. You * can't use C-style array in `std::optional`s. @@ -74,6 +84,10 @@ class YaComponent : public Steinberg::Vst::IComponent { template void serialize(S& s) { s.value8b(instance_id); + s.ext(known_iids, bitsery::ext::StdSet{32}, + [](S& s, Steinberg::FUID& iid) { + s.ext(iid, bitsery::ext::FUID{}); + }); s.ext(edit_controller_cid, bitsery::ext::StdOptional{}, [](S& s, auto& cid) { s.container1b(cid); }); } diff --git a/src/common/serialization/vst3/plugin-factory.h b/src/common/serialization/vst3/plugin-factory.h index 532a9bb9..6d1dfa35 100644 --- a/src/common/serialization/vst3/plugin-factory.h +++ b/src/common/serialization/vst3/plugin-factory.h @@ -48,7 +48,7 @@ class YaPluginFactory : public Steinberg::IPluginFactory3 { /** * Create a copy of an existing plugin factory. Depending on the * supported interface function more or less of this struct will be left - * empty, and `iid` will be set accordingly. + * empty, and `known_iids` will be set accordingly. */ ConstructArgs(Steinberg::IPtr factory);