mirror of
https://github.com/robbert-vdh/yabridge.git
synced 2026-05-09 20:29:10 +02:00
Abstract away logging unknown interfaces
This commit is contained in:
@@ -18,10 +18,24 @@
|
|||||||
|
|
||||||
#include "src/common/serialization/vst3.h"
|
#include "src/common/serialization/vst3.h"
|
||||||
|
|
||||||
// TODO: Reconsider the output format
|
|
||||||
|
|
||||||
Vst3Logger::Vst3Logger(Logger& generic_logger) : logger(generic_logger) {}
|
Vst3Logger::Vst3Logger(Logger& generic_logger) : logger(generic_logger) {}
|
||||||
|
|
||||||
|
void Vst3Logger::log_unknown_interface(
|
||||||
|
const std::string& where,
|
||||||
|
const std::optional<Steinberg::FUID>& uid) {
|
||||||
|
if (BOOST_UNLIKELY(logger.verbosity >= Logger::Verbosity::most_events)) {
|
||||||
|
char uid_string[128] = "<invalid_pointer>";
|
||||||
|
if (uid) {
|
||||||
|
uid->print(uid_string, Steinberg::FUID::UIDPrintStyle::kCLASS_UID);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::ostringstream message;
|
||||||
|
message << "[unknown interface] " << where << ": " << uid_string;
|
||||||
|
|
||||||
|
log(message.str());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Vst3Logger::log_request(bool is_host_vst, const YaComponent::Construct&) {
|
void Vst3Logger::log_request(bool is_host_vst, const YaComponent::Construct&) {
|
||||||
log_request_base(is_host_vst, [](auto& message) {
|
log_request_base(is_host_vst, [](auto& message) {
|
||||||
// TODO: Log the cid in some readable way, if possible
|
// TODO: Log the cid in some readable way, if possible
|
||||||
|
|||||||
@@ -42,6 +42,15 @@ class Vst3Logger {
|
|||||||
logger.log_trace(message);
|
logger.log_trace(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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
|
||||||
|
* instance), `std::nullopt` should be passed.
|
||||||
|
*/
|
||||||
|
void log_unknown_interface(const std::string& where,
|
||||||
|
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
|
||||||
// that print information about the request and the response. The boolean
|
// that print information about the request and the response. The boolean
|
||||||
// flag here indicates whether the request was initiated on the host side
|
// flag here indicates whether the request was initiated on the host side
|
||||||
|
|||||||
@@ -29,8 +29,7 @@ YaComponentPluginImpl::~YaComponentPluginImpl() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
tresult PLUGIN_API
|
tresult PLUGIN_API
|
||||||
YaComponentPluginImpl::queryInterface(const ::Steinberg::TUID _iid,
|
YaComponentPluginImpl::queryInterface(const Steinberg::TUID _iid, void** obj) {
|
||||||
void** obj) {
|
|
||||||
// TODO: Log when this fails on debug level 1, and on debug level 2 also log
|
// TODO: Log when this fails on debug level 1, and on debug level 2 also log
|
||||||
// successful queries. This behaviour should be implemented for all
|
// successful queries. This behaviour should be implemented for all
|
||||||
// interfaces.
|
// interfaces.
|
||||||
@@ -46,16 +45,9 @@ tresult PLUGIN_API YaComponentPluginImpl::initialize(FUnknown* context) {
|
|||||||
if (host_application_context) {
|
if (host_application_context) {
|
||||||
// TODO: Init with `YaHostApplication`
|
// TODO: Init with `YaHostApplication`
|
||||||
} else {
|
} else {
|
||||||
context->iid;
|
bridge.logger.log_unknown_interface(
|
||||||
|
"In IPluginBase::initialize()",
|
||||||
char iid_string[128] = "<invalid_pointer>";
|
context ? std::optional(context->iid) : std::nullopt);
|
||||||
if (context) {
|
|
||||||
context->iid.print(iid_string,
|
|
||||||
Steinberg::FUID::UIDPrintStyle::kCLASS_UID);
|
|
||||||
}
|
|
||||||
|
|
||||||
bridge.logger.log("[Unknown interface] In IPluginBase::initialize(): " +
|
|
||||||
std::string(iid_string));
|
|
||||||
|
|
||||||
// TODO: Init with null pointer
|
// TODO: Init with null pointer
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ class YaComponentPluginImpl : public YaComponent {
|
|||||||
* We'll override the query interface to log queries for interfaces we do
|
* We'll override the query interface to log queries for interfaces we do
|
||||||
* not (yet) support.
|
* not (yet) support.
|
||||||
*/
|
*/
|
||||||
tresult PLUGIN_API queryInterface(const ::Steinberg::TUID _iid,
|
tresult PLUGIN_API queryInterface(const Steinberg::TUID _iid,
|
||||||
void** obj) override;
|
void** obj) override;
|
||||||
|
|
||||||
tresult PLUGIN_API initialize(FUnknown* context) override;
|
tresult PLUGIN_API initialize(FUnknown* context) override;
|
||||||
@@ -66,7 +66,9 @@ class YaComponentPluginImpl : public YaComponent {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* An `IHostApplication` instance if we get one through
|
* An `IHostApplication` instance if we get one through
|
||||||
* `IPluginBase::initialize()`.
|
* `IPluginBase::initialize()`. This should be the same for all plugin
|
||||||
|
* instances so we should not have to store it here separately, but for the
|
||||||
|
* sake of correctness we will.
|
||||||
*/
|
*/
|
||||||
Steinberg::FUnknownPtr<Steinberg::Vst::IHostApplication>
|
Steinberg::FUnknownPtr<Steinberg::Vst::IHostApplication>
|
||||||
host_application_context;
|
host_application_context;
|
||||||
|
|||||||
@@ -49,17 +49,15 @@ YaPluginFactoryPluginImpl::createInstance(Steinberg::FIDString cid,
|
|||||||
// print a recognizable log message. I don't think they include a safe
|
// 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
|
// way to convert a `FIDString/char*` into a `FUID`, so this will have
|
||||||
// to do.
|
// to do.
|
||||||
char iid_string[128] = "<invalid_pointer>";
|
std::optional<Steinberg::FUID> uid;
|
||||||
constexpr size_t uid_size = sizeof(Steinberg::TUID);
|
constexpr size_t uid_size = sizeof(Steinberg::TUID);
|
||||||
if (_iid && strnlen(_iid, uid_size + 1) == uid_size) {
|
if (_iid && strnlen(_iid, uid_size + 1) == uid_size) {
|
||||||
Steinberg::FUID iid = Steinberg::FUID::fromTUID(
|
uid = Steinberg::FUID::fromTUID(
|
||||||
*reinterpret_cast<const Steinberg::TUID*>(&_iid));
|
*reinterpret_cast<const Steinberg::TUID*>(&_iid));
|
||||||
iid.print(iid_string, Steinberg::FUID::UIDPrintStyle::kCLASS_UID);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bridge.logger.log(
|
bridge.logger.log_unknown_interface(
|
||||||
"[Unknown interface] In IPluginFactory::createInstance(): " +
|
"In IPluginFactory::createInstance()", uid);
|
||||||
std::string(iid_string));
|
|
||||||
|
|
||||||
return Steinberg::kNotImplemented;
|
return Steinberg::kNotImplemented;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user