Clean up interface checks in VST3 plugin factory

Even though the interface ID is passed as an FIDString and there is a
function to compare FIDStrings obviously doesn't mean that you're
supposed to use them! Duh.
This commit is contained in:
Robbert van der Helm
2021-02-09 23:24:05 +01:00
parent 10b01b5140
commit a91fad2217
@@ -38,30 +38,23 @@ YaPluginFactoryImpl::createInstance(Steinberg::FIDString cid,
Steinberg::TUID cid_array; Steinberg::TUID cid_array;
std::copy(cid, cid + std::extent_v<Steinberg::TUID>, cid_array); std::copy(cid, cid + std::extent_v<Steinberg::TUID>, cid_array);
// FIXME: `_iid` in Bitwig Studio 3.3.1 is not null terminated, and the // I don't think they include a safe way to convert a `FIDString/char*` into
// comparison below will thus fail since the strings have different // a `FUID`, so this will have to do
// lengths. Since it looks like the module implementation that comes const Steinberg::FUID requested_iid = Steinberg::FUID::fromTUID(
// with the SDK has this same issue I think it might just be a case *reinterpret_cast<const Steinberg::TUID*>(&*_iid));
// of Steinberg not following its own specifications.
std::string iid_string(_iid, uid_size);
Vst3PluginProxy::Construct::Interface requested_interface; Vst3PluginProxy::Construct::Interface requested_interface;
if (Steinberg::FIDStringsEqual(iid_string.c_str(), if (requested_iid == Steinberg::Vst::IComponent::iid) {
Steinberg::Vst::IComponent::iid)) {
requested_interface = Vst3PluginProxy::Construct::Interface::IComponent; requested_interface = Vst3PluginProxy::Construct::Interface::IComponent;
} else if (Steinberg::FIDStringsEqual( } else if (requested_iid == Steinberg::Vst::IEditController::iid) {
iid_string.c_str(), Steinberg::Vst::IEditController::iid)) {
requested_interface = requested_interface =
Vst3PluginProxy::Construct::Interface::IEditController; Vst3PluginProxy::Construct::Interface::IEditController;
} else { } else {
// When the host requests an interface we do not (yet) implement, we'll // When the host requests an interface we do not (yet) implement, we'll
// print a recognizable log message. I don't think they include a safe // print a recognizable log message
// way to convert a `FIDString/char*` into a `FUID`, so this will have
// to do.
const Steinberg::FUID uid = Steinberg::FUID::fromTUID(
*reinterpret_cast<const Steinberg::TUID*>(&*_iid));
bridge.logger.log_query_interface("In IPluginFactory::createInstance()", bridge.logger.log_query_interface("In IPluginFactory::createInstance()",
Steinberg::kNotImplemented, uid); Steinberg::kNotImplemented,
requested_iid);
*obj = nullptr; *obj = nullptr;
return Steinberg::kNotImplemented; return Steinberg::kNotImplemented;