mirror of
https://github.com/robbert-vdh/yabridge.git
synced 2026-05-16 13:40:05 +02:00
Abstract away logging unknown interfaces
This commit is contained in:
@@ -29,8 +29,7 @@ YaComponentPluginImpl::~YaComponentPluginImpl() {
|
||||
}
|
||||
|
||||
tresult PLUGIN_API
|
||||
YaComponentPluginImpl::queryInterface(const ::Steinberg::TUID _iid,
|
||||
void** obj) {
|
||||
YaComponentPluginImpl::queryInterface(const Steinberg::TUID _iid, void** obj) {
|
||||
// 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
|
||||
// interfaces.
|
||||
@@ -46,16 +45,9 @@ tresult PLUGIN_API YaComponentPluginImpl::initialize(FUnknown* context) {
|
||||
if (host_application_context) {
|
||||
// TODO: Init with `YaHostApplication`
|
||||
} else {
|
||||
context->iid;
|
||||
|
||||
char iid_string[128] = "<invalid_pointer>";
|
||||
if (context) {
|
||||
context->iid.print(iid_string,
|
||||
Steinberg::FUID::UIDPrintStyle::kCLASS_UID);
|
||||
}
|
||||
|
||||
bridge.logger.log("[Unknown interface] In IPluginBase::initialize(): " +
|
||||
std::string(iid_string));
|
||||
bridge.logger.log_unknown_interface(
|
||||
"In IPluginBase::initialize()",
|
||||
context ? std::optional(context->iid) : std::nullopt);
|
||||
|
||||
// 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
|
||||
* not (yet) support.
|
||||
*/
|
||||
tresult PLUGIN_API queryInterface(const ::Steinberg::TUID _iid,
|
||||
tresult PLUGIN_API queryInterface(const Steinberg::TUID _iid,
|
||||
void** obj) override;
|
||||
|
||||
tresult PLUGIN_API initialize(FUnknown* context) override;
|
||||
@@ -66,7 +66,9 @@ class YaComponentPluginImpl : public YaComponent {
|
||||
|
||||
/**
|
||||
* 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>
|
||||
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
|
||||
// way to convert a `FIDString/char*` into a `FUID`, so this will have
|
||||
// to do.
|
||||
char iid_string[128] = "<invalid_pointer>";
|
||||
std::optional<Steinberg::FUID> uid;
|
||||
constexpr size_t uid_size = sizeof(Steinberg::TUID);
|
||||
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));
|
||||
iid.print(iid_string, Steinberg::FUID::UIDPrintStyle::kCLASS_UID);
|
||||
}
|
||||
|
||||
bridge.logger.log(
|
||||
"[Unknown interface] In IPluginFactory::createInstance(): " +
|
||||
std::string(iid_string));
|
||||
bridge.logger.log_unknown_interface(
|
||||
"In IPluginFactory::createInstance()", uid);
|
||||
|
||||
return Steinberg::kNotImplemented;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user