Log successful FUnknown::queryInterface calls

This commit is contained in:
Robbert van der Helm
2020-12-31 13:13:39 +01:00
parent 26bc97e273
commit 9d24d422d1
9 changed files with 38 additions and 46 deletions
+13 -4
View File
@@ -24,17 +24,26 @@
Vst3Logger::Vst3Logger(Logger& generic_logger) : logger(generic_logger) {} Vst3Logger::Vst3Logger(Logger& generic_logger) : logger(generic_logger) {}
void Vst3Logger::log_unknown_interface( void Vst3Logger::log_query_interface(
const std::string& where, const std::string& where,
tresult result,
const std::optional<Steinberg::FUID>& uid) { const std::optional<Steinberg::FUID>& uid) {
if (BOOST_UNLIKELY(logger.verbosity >= Logger::Verbosity::most_events)) { if (BOOST_UNLIKELY(logger.verbosity >= Logger::Verbosity::most_events)) {
std::ostringstream message;
std::string uid_string = uid ? format_uid(*uid) : "<unknown_pointer>"; std::string uid_string = uid ? format_uid(*uid) : "<unknown_pointer>";
std::ostringstream message; if (result == Steinberg::kResultOk) {
message << "[unknown interface] " << where << ": " << uid_string; if (logger.verbosity >= Logger::Verbosity::most_events) {
message << "[query interface] " << where << ": " << uid_string;
log(message.str()); 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());
}
}
} }
bool Vst3Logger::log_request(bool is_host_vst, bool Vst3Logger::log_request(bool is_host_vst,
+6 -4
View File
@@ -43,12 +43,14 @@ class Vst3Logger {
} }
/** /**
* Log about encountering an unknown interface. The location and the UID * Log calls to `FUnknown::queryInterface`. This will separately log about
* will be printed when the verbosity level is set to `most_events` or * successful queries, queries for interfaces the object did not implement,
* higher. In case we could not get a FUID (because of null pointers, for * 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. * instance), `std::nullopt` should be passed.
*/ */
void log_unknown_interface(const std::string& where, void log_query_interface(const std::string& where,
tresult result,
const std::optional<Steinberg::FUID>& uid); const std::optional<Steinberg::FUID>& uid);
// For every object we send using `Vst3MessageHandler` we have overloads // For every object we send using `Vst3MessageHandler` we have overloads
@@ -30,12 +30,9 @@ Vst3PlugViewProxyImpl::~Vst3PlugViewProxyImpl() {
tresult PLUGIN_API tresult PLUGIN_API
Vst3PlugViewProxyImpl::queryInterface(const Steinberg::TUID _iid, void** obj) { Vst3PlugViewProxyImpl::queryInterface(const Steinberg::TUID _iid, void** obj) {
// TODO: Successful queries should also be logged
const tresult result = Vst3PlugViewProxy::queryInterface(_iid, obj); const tresult result = Vst3PlugViewProxy::queryInterface(_iid, obj);
if (result != Steinberg::kResultOk) { bridge.logger.log_query_interface("In IPlugView::queryInterface()", result,
bridge.logger.log_unknown_interface("In IPlugView::queryInterface()",
Steinberg::FUID::fromTUID(_iid)); Steinberg::FUID::fromTUID(_iid));
}
return result; return result;
} }
@@ -59,8 +59,8 @@ YaPluginFactoryImpl::createInstance(Steinberg::FIDString cid,
// to do. // to do.
const Steinberg::FUID uid = Steinberg::FUID::fromTUID( const Steinberg::FUID uid = Steinberg::FUID::fromTUID(
*reinterpret_cast<const Steinberg::TUID*>(&*_iid)); *reinterpret_cast<const Steinberg::TUID*>(&*_iid));
bridge.logger.log_unknown_interface( bridge.logger.log_query_interface("In IPluginFactory::createInstance()",
"In IPluginFactory::createInstance()", uid); Steinberg::kNotImplemented, uid);
*obj = nullptr; *obj = nullptr;
return Steinberg::kNotImplemented; return Steinberg::kNotImplemented;
@@ -32,12 +32,9 @@ Vst3PluginProxyImpl::~Vst3PluginProxyImpl() {
tresult PLUGIN_API tresult PLUGIN_API
Vst3PluginProxyImpl::queryInterface(const Steinberg::TUID _iid, void** obj) { Vst3PluginProxyImpl::queryInterface(const Steinberg::TUID _iid, void** obj) {
// TODO: Successful queries should also be logged
const tresult result = Vst3PluginProxy::queryInterface(_iid, obj); const tresult result = Vst3PluginProxy::queryInterface(_iid, obj);
if (result != Steinberg::kResultOk) { bridge.logger.log_query_interface("In FUnknown::queryInterface()", result,
bridge.logger.log_unknown_interface("In FUnknown::queryInterface()",
Steinberg::FUID::fromTUID(_iid)); Steinberg::FUID::fromTUID(_iid));
}
return result; return result;
} }
@@ -29,13 +29,9 @@ Vst3ComponentHandlerProxyImpl::Vst3ComponentHandlerProxyImpl(
tresult PLUGIN_API tresult PLUGIN_API
Vst3ComponentHandlerProxyImpl::queryInterface(const Steinberg::TUID _iid, Vst3ComponentHandlerProxyImpl::queryInterface(const Steinberg::TUID _iid,
void** obj) { void** obj) {
// TODO: Successful queries should also be logged
const tresult result = Vst3ComponentHandlerProxy::queryInterface(_iid, obj); const tresult result = Vst3ComponentHandlerProxy::queryInterface(_iid, obj);
if (result != Steinberg::kResultOk) { bridge.logger.log_query_interface("In IComponentHandler::queryInterface()",
bridge.logger.log_unknown_interface( result, Steinberg::FUID::fromTUID(_iid));
"In IComponentHandler::queryInterface()",
Steinberg::FUID::fromTUID(_iid));
}
return result; return result;
} }
@@ -26,13 +26,9 @@ Vst3ConnectionPointProxyImpl::Vst3ConnectionPointProxyImpl(
tresult PLUGIN_API tresult PLUGIN_API
Vst3ConnectionPointProxyImpl::queryInterface(const Steinberg::TUID _iid, Vst3ConnectionPointProxyImpl::queryInterface(const Steinberg::TUID _iid,
void** obj) { void** obj) {
// TODO: Successful queries should also be logged
const tresult result = Vst3ConnectionPointProxy::queryInterface(_iid, obj); const tresult result = Vst3ConnectionPointProxy::queryInterface(_iid, obj);
if (result != Steinberg::kResultOk) { bridge.logger.log_query_interface("In IConnectionPoint::queryInterface()",
bridge.logger.log_unknown_interface( result, Steinberg::FUID::fromTUID(_iid));
"In IConnectionPoint::queryInterface()",
Steinberg::FUID::fromTUID(_iid));
}
return result; return result;
} }
@@ -34,12 +34,9 @@ Vst3HostContextProxyImpl::queryInterface(const Steinberg::TUID _iid,
void** obj) { void** obj) {
// I don't think it's expected of a host to implement multiple interfaces on // 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 // 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); const tresult result = Vst3HostContextProxy::queryInterface(_iid, obj);
if (result != Steinberg::kResultOk) { bridge.logger.log_query_interface("In FUnknown::queryInterface()", result,
bridge.logger.log_unknown_interface("In FUnknown::queryInterface()",
Steinberg::FUID::fromTUID(_iid)); Steinberg::FUID::fromTUID(_iid));
}
return result; return result;
} }
@@ -83,8 +80,9 @@ Vst3HostContextProxyImpl::createInstance(Steinberg::TUID /*cid*/,
// When the host requests an interface we do not (yet) implement, // When the host requests an interface we do not (yet) implement,
// we'll print a recognizable log message // we'll print a recognizable log message
const Steinberg::FUID uid = Steinberg::FUID::fromTUID(_iid); const Steinberg::FUID uid = Steinberg::FUID::fromTUID(_iid);
bridge.logger.log_unknown_interface( bridge.logger.log_query_interface(
"In IHostApplication::createInstance()", uid); "In IHostApplication::createInstance()", Steinberg::kNotImplemented,
uid);
return Steinberg::kNotImplemented; return Steinberg::kNotImplemented;
} }
@@ -28,12 +28,9 @@ Vst3PlugFrameProxyImpl::Vst3PlugFrameProxyImpl(
tresult PLUGIN_API tresult PLUGIN_API
Vst3PlugFrameProxyImpl::queryInterface(const Steinberg::TUID _iid, void** obj) { Vst3PlugFrameProxyImpl::queryInterface(const Steinberg::TUID _iid, void** obj) {
// TODO: Successful queries should also be logged
const tresult result = Vst3PlugFrameProxy::queryInterface(_iid, obj); const tresult result = Vst3PlugFrameProxy::queryInterface(_iid, obj);
if (result != Steinberg::kResultOk) { bridge.logger.log_query_interface("In IPlugFrame::queryInterface()", result,
bridge.logger.log_unknown_interface("In IPlugFrame::queryInterface()",
Steinberg::FUID::fromTUID(_iid)); Steinberg::FUID::fromTUID(_iid));
}
return result; return result;
} }