From 9d24d422d1a087582a00e6e48bd83f6d3f0b9e57 Mon Sep 17 00:00:00 2001 From: Robbert van der Helm Date: Thu, 31 Dec 2020 13:13:39 +0100 Subject: [PATCH] Log successful FUnknown::queryInterface calls --- src/common/logging/vst3.cpp | 19 ++++++++++++++----- src/common/logging/vst3.h | 12 +++++++----- .../bridges/vst3-impls/plug-view-proxy.cpp | 7 ++----- .../bridges/vst3-impls/plugin-factory.cpp | 4 ++-- .../bridges/vst3-impls/plugin-proxy.cpp | 7 ++----- .../vst3-impls/component-handler-proxy.cpp | 8 ++------ .../vst3-impls/connection-point-proxy.cpp | 8 ++------ .../bridges/vst3-impls/host-context-proxy.cpp | 12 +++++------- .../bridges/vst3-impls/plug-frame-proxy.cpp | 7 ++----- 9 files changed, 38 insertions(+), 46 deletions(-) diff --git a/src/common/logging/vst3.cpp b/src/common/logging/vst3.cpp index ce667512..7241e095 100644 --- a/src/common/logging/vst3.cpp +++ b/src/common/logging/vst3.cpp @@ -24,16 +24,25 @@ Vst3Logger::Vst3Logger(Logger& generic_logger) : logger(generic_logger) {} -void Vst3Logger::log_unknown_interface( +void Vst3Logger::log_query_interface( const std::string& where, + tresult result, const std::optional& uid) { if (BOOST_UNLIKELY(logger.verbosity >= Logger::Verbosity::most_events)) { + std::ostringstream message; std::string uid_string = uid ? format_uid(*uid) : ""; - std::ostringstream message; - message << "[unknown interface] " << where << ": " << uid_string; - - log(message.str()); + if (result == Steinberg::kResultOk) { + if (logger.verbosity >= Logger::Verbosity::most_events) { + message << "[query interface] " << where << ": " << uid_string; + log(message.str()); + } + } else { + // TODO: DIfferentiate between interfaces we don't implement and + // interfaces the object doesn't implement + message << "[unknown interface] " << where << ": " << uid_string; + log(message.str()); + } } } diff --git a/src/common/logging/vst3.h b/src/common/logging/vst3.h index 2eca806e..e1956aec 100644 --- a/src/common/logging/vst3.h +++ b/src/common/logging/vst3.h @@ -43,13 +43,15 @@ class Vst3Logger { } /** - * Log about encountering an unknown interface. The location and the UID - * will be printed when the verbosity level is set to `most_events` or - * higher. In case we could not get a FUID (because of null pointers, for + * Log calls to `FUnknown::queryInterface`. This will separately log about + * successful queries, queries for interfaces the object did not implement, + * and queries for interfaces we do not implement depending on the verbosity + * level. In case we could not get a FUID (because of null pointers, for * instance), `std::nullopt` should be passed. */ - void log_unknown_interface(const std::string& where, - const std::optional& uid); + void log_query_interface(const std::string& where, + tresult result, + const std::optional& uid); // For every object we send using `Vst3MessageHandler` we have overloads // that print information about the request and the response. The boolean diff --git a/src/plugin/bridges/vst3-impls/plug-view-proxy.cpp b/src/plugin/bridges/vst3-impls/plug-view-proxy.cpp index 1a5d0160..eea0848e 100644 --- a/src/plugin/bridges/vst3-impls/plug-view-proxy.cpp +++ b/src/plugin/bridges/vst3-impls/plug-view-proxy.cpp @@ -30,12 +30,9 @@ Vst3PlugViewProxyImpl::~Vst3PlugViewProxyImpl() { tresult PLUGIN_API Vst3PlugViewProxyImpl::queryInterface(const Steinberg::TUID _iid, void** obj) { - // TODO: Successful queries should also be logged const tresult result = Vst3PlugViewProxy::queryInterface(_iid, obj); - if (result != Steinberg::kResultOk) { - bridge.logger.log_unknown_interface("In IPlugView::queryInterface()", - Steinberg::FUID::fromTUID(_iid)); - } + bridge.logger.log_query_interface("In IPlugView::queryInterface()", result, + Steinberg::FUID::fromTUID(_iid)); return result; } diff --git a/src/plugin/bridges/vst3-impls/plugin-factory.cpp b/src/plugin/bridges/vst3-impls/plugin-factory.cpp index ac0b4ca9..505a74f3 100644 --- a/src/plugin/bridges/vst3-impls/plugin-factory.cpp +++ b/src/plugin/bridges/vst3-impls/plugin-factory.cpp @@ -59,8 +59,8 @@ YaPluginFactoryImpl::createInstance(Steinberg::FIDString cid, // to do. const Steinberg::FUID uid = Steinberg::FUID::fromTUID( *reinterpret_cast(&*_iid)); - bridge.logger.log_unknown_interface( - "In IPluginFactory::createInstance()", uid); + bridge.logger.log_query_interface("In IPluginFactory::createInstance()", + Steinberg::kNotImplemented, uid); *obj = nullptr; return Steinberg::kNotImplemented; diff --git a/src/plugin/bridges/vst3-impls/plugin-proxy.cpp b/src/plugin/bridges/vst3-impls/plugin-proxy.cpp index e5aca967..1e8aca11 100644 --- a/src/plugin/bridges/vst3-impls/plugin-proxy.cpp +++ b/src/plugin/bridges/vst3-impls/plugin-proxy.cpp @@ -32,12 +32,9 @@ Vst3PluginProxyImpl::~Vst3PluginProxyImpl() { tresult PLUGIN_API Vst3PluginProxyImpl::queryInterface(const Steinberg::TUID _iid, void** obj) { - // TODO: Successful queries should also be logged const tresult result = Vst3PluginProxy::queryInterface(_iid, obj); - if (result != Steinberg::kResultOk) { - bridge.logger.log_unknown_interface("In FUnknown::queryInterface()", - Steinberg::FUID::fromTUID(_iid)); - } + bridge.logger.log_query_interface("In FUnknown::queryInterface()", result, + Steinberg::FUID::fromTUID(_iid)); return result; } diff --git a/src/wine-host/bridges/vst3-impls/component-handler-proxy.cpp b/src/wine-host/bridges/vst3-impls/component-handler-proxy.cpp index ece96996..b9d0ba92 100644 --- a/src/wine-host/bridges/vst3-impls/component-handler-proxy.cpp +++ b/src/wine-host/bridges/vst3-impls/component-handler-proxy.cpp @@ -29,13 +29,9 @@ Vst3ComponentHandlerProxyImpl::Vst3ComponentHandlerProxyImpl( tresult PLUGIN_API Vst3ComponentHandlerProxyImpl::queryInterface(const Steinberg::TUID _iid, void** obj) { - // TODO: Successful queries should also be logged const tresult result = Vst3ComponentHandlerProxy::queryInterface(_iid, obj); - if (result != Steinberg::kResultOk) { - bridge.logger.log_unknown_interface( - "In IComponentHandler::queryInterface()", - Steinberg::FUID::fromTUID(_iid)); - } + bridge.logger.log_query_interface("In IComponentHandler::queryInterface()", + result, Steinberg::FUID::fromTUID(_iid)); return result; } diff --git a/src/wine-host/bridges/vst3-impls/connection-point-proxy.cpp b/src/wine-host/bridges/vst3-impls/connection-point-proxy.cpp index 4949a1f8..1e189a95 100644 --- a/src/wine-host/bridges/vst3-impls/connection-point-proxy.cpp +++ b/src/wine-host/bridges/vst3-impls/connection-point-proxy.cpp @@ -26,13 +26,9 @@ Vst3ConnectionPointProxyImpl::Vst3ConnectionPointProxyImpl( tresult PLUGIN_API Vst3ConnectionPointProxyImpl::queryInterface(const Steinberg::TUID _iid, void** obj) { - // TODO: Successful queries should also be logged const tresult result = Vst3ConnectionPointProxy::queryInterface(_iid, obj); - if (result != Steinberg::kResultOk) { - bridge.logger.log_unknown_interface( - "In IConnectionPoint::queryInterface()", - Steinberg::FUID::fromTUID(_iid)); - } + bridge.logger.log_query_interface("In IConnectionPoint::queryInterface()", + result, Steinberg::FUID::fromTUID(_iid)); return result; } diff --git a/src/wine-host/bridges/vst3-impls/host-context-proxy.cpp b/src/wine-host/bridges/vst3-impls/host-context-proxy.cpp index ae572e76..c7a0443d 100644 --- a/src/wine-host/bridges/vst3-impls/host-context-proxy.cpp +++ b/src/wine-host/bridges/vst3-impls/host-context-proxy.cpp @@ -34,12 +34,9 @@ Vst3HostContextProxyImpl::queryInterface(const Steinberg::TUID _iid, void** obj) { // I don't think it's expected of a host to implement multiple interfaces on // this object, so if we do get a call here it's important that it's logged - // TODO: Successful queries should also be logged const tresult result = Vst3HostContextProxy::queryInterface(_iid, obj); - if (result != Steinberg::kResultOk) { - bridge.logger.log_unknown_interface("In FUnknown::queryInterface()", - Steinberg::FUID::fromTUID(_iid)); - } + bridge.logger.log_query_interface("In FUnknown::queryInterface()", result, + Steinberg::FUID::fromTUID(_iid)); return result; } @@ -83,8 +80,9 @@ Vst3HostContextProxyImpl::createInstance(Steinberg::TUID /*cid*/, // When the host requests an interface we do not (yet) implement, // we'll print a recognizable log message const Steinberg::FUID uid = Steinberg::FUID::fromTUID(_iid); - bridge.logger.log_unknown_interface( - "In IHostApplication::createInstance()", uid); + bridge.logger.log_query_interface( + "In IHostApplication::createInstance()", Steinberg::kNotImplemented, + uid); return Steinberg::kNotImplemented; } diff --git a/src/wine-host/bridges/vst3-impls/plug-frame-proxy.cpp b/src/wine-host/bridges/vst3-impls/plug-frame-proxy.cpp index 74a68021..91cc413d 100644 --- a/src/wine-host/bridges/vst3-impls/plug-frame-proxy.cpp +++ b/src/wine-host/bridges/vst3-impls/plug-frame-proxy.cpp @@ -28,12 +28,9 @@ Vst3PlugFrameProxyImpl::Vst3PlugFrameProxyImpl( tresult PLUGIN_API Vst3PlugFrameProxyImpl::queryInterface(const Steinberg::TUID _iid, void** obj) { - // TODO: Successful queries should also be logged const tresult result = Vst3PlugFrameProxy::queryInterface(_iid, obj); - if (result != Steinberg::kResultOk) { - bridge.logger.log_unknown_interface("In IPlugFrame::queryInterface()", - Steinberg::FUID::fromTUID(_iid)); - } + bridge.logger.log_query_interface("In IPlugFrame::queryInterface()", result, + Steinberg::FUID::fromTUID(_iid)); return result; }