From f1fe0fa8a44dbd2d5349b8ad1bea01dc947feea0 Mon Sep 17 00:00:00 2001 From: Robbert van der Helm Date: Mon, 7 Dec 2020 22:16:34 +0100 Subject: [PATCH] Log a warning when encountering unknown interfaces --- src/common/communication/vst3.h | 3 --- src/plugin/bridges/vst3-impls.cpp | 23 ++++++++++++++++++++++- src/plugin/bridges/vst3.h | 12 ++++++------ 3 files changed, 28 insertions(+), 10 deletions(-) diff --git a/src/common/communication/vst3.h b/src/common/communication/vst3.h index 0f97478b..4bc3d13b 100644 --- a/src/common/communication/vst3.h +++ b/src/common/communication/vst3.h @@ -208,9 +208,6 @@ class Vst3MessageHandler : public AdHocSocketHandler { * sockets, and the call to `connect()` will then accept any incoming * connections. * - * TODO: I have no idea what the best approach here is yet, so this is very much - * subject to change - * * @tparam Thread The thread implementation to use. On the Linux side this * should be `std::jthread` and on the Wine side this should be `Win32Thread`. */ diff --git a/src/plugin/bridges/vst3-impls.cpp b/src/plugin/bridges/vst3-impls.cpp index 72686852..971264c5 100644 --- a/src/plugin/bridges/vst3-impls.cpp +++ b/src/plugin/bridges/vst3-impls.cpp @@ -16,6 +16,8 @@ #include "vst3-impls.h" +#include + YaPluginFactoryPluginImpl::YaPluginFactoryPluginImpl(Vst3PluginBridge& bridge) : bridge(bridge) {} @@ -49,7 +51,26 @@ YaPluginFactoryPluginImpl::createInstance(Steinberg::FIDString cid, // `createInstance()` will have a reference to `Vst3PluginBridge`, // they can also send control messages themselves. - return Steinberg::kNotImplemented; + if (Steinberg::FIDStringsEqual(_iid, Steinberg::Vst::IComponent::iid)) { + // TODO: Instantiate an IComponent as described above + return Steinberg::kNotImplemented; + } else { + // 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 + // way to convert a `FIDString/char*` into a `FUID`, so this will have + // to do. + char iid_string[128] = ""; + constexpr size_t uid_size = sizeof(Steinberg::TUID); + if (_iid && strnlen(_iid, uid_size + 1) == uid_size) { + Steinberg::FUID iid = Steinberg::FUID::fromTUID( + *reinterpret_cast(&_iid)); + iid.print(iid_string, Steinberg::FUID::UIDPrintStyle::kCLASS_UID); + } + + bridge.logger.log("[Unknown interface] " + std::string(iid_string)); + + return Steinberg::kNotImplemented; + } } tresult PLUGIN_API diff --git a/src/plugin/bridges/vst3.h b/src/plugin/bridges/vst3.h index 0b383f4e..1d6d6d69 100644 --- a/src/plugin/bridges/vst3.h +++ b/src/plugin/bridges/vst3.h @@ -63,6 +63,12 @@ class Vst3PluginBridge : PluginBridge> { */ Steinberg::IPluginFactory* get_plugin_factory(); + /** + * The logging facility used for this instance of yabridge. Wraps around + * `PluginBridge::generic_logger`. + */ + Vst3Logger logger; + private: /** * Handles callbacks from the plugin to the host over the @@ -70,12 +76,6 @@ class Vst3PluginBridge : PluginBridge> { */ std::jthread host_callback_handler; - /** - * The logging facility used for this instance of yabridge. Wraps around - * `PluginBridge::generic_logger`. - */ - Vst3Logger logger; - /** * Our plugin factory. All information about the plugin and its supported * classes are copied directly from the Windows VST3 plugin's factory on the