diff --git a/src/common/logging/vst3.cpp b/src/common/logging/vst3.cpp index d75c4e8a..9a73988a 100644 --- a/src/common/logging/vst3.cpp +++ b/src/common/logging/vst3.cpp @@ -342,13 +342,7 @@ bool Vst3Logger::log_request(bool is_host_vst, bool Vst3Logger::log_request(bool is_host_vst, const YaPluginFactory::SetHostContext& request) { return log_request_base(is_host_vst, [&](auto& message) { - message << "IPluginFactory3::setHostContext("; - if (request.host_context_args) { - message << ""; - } else { - message << ""; - } - message << ")"; + message << "IPluginFactory3::setHostContext()"; }); } diff --git a/src/common/serialization/vst3/plugin-factory.h b/src/common/serialization/vst3/plugin-factory.h index ac78342e..fdc572c7 100644 --- a/src/common/serialization/vst3/plugin-factory.h +++ b/src/common/serialization/vst3/plugin-factory.h @@ -162,15 +162,11 @@ class YaPluginFactory : public Steinberg::IPluginFactory3 { struct SetHostContext { using Response = UniversalTResult; - /** - * Arguments for creating a proxy host context object. If we got passed - * an null pointer we'll reflect that. - */ - std::optional host_context_args; + Vst3HostContextProxy::ConstructArgs host_context_args; template void serialize(S& s) { - s.ext(host_context_args, bitsery::ext::StdOptional{}); + s.object(host_context_args); } }; diff --git a/src/plugin/bridges/vst3-impls/plugin-factory.cpp b/src/plugin/bridges/vst3-impls/plugin-factory.cpp index 988bf06a..a795a5fe 100644 --- a/src/plugin/bridges/vst3-impls/plugin-factory.cpp +++ b/src/plugin/bridges/vst3-impls/plugin-factory.cpp @@ -100,25 +100,24 @@ YaPluginFactoryImpl::createInstance(Steinberg::FIDString cid, tresult PLUGIN_API YaPluginFactoryImpl::setHostContext(Steinberg::FUnknown* context) { - // We will create a proxy object that that supports all the same interfaces - // as `context`, and then we'll store `context` in this object. We can then - // use it to handle callbacks made by the Windows VST3 plugin to this - // context. - host_context = context; + if (context) { + // We will create a proxy object that that supports all the same + // interfaces as `context`, and then we'll store `context` in this + // object. We can then use it to handle callbacks made by the Windows + // VST3 plugin to this context. + host_context = context; - // Automatically converted smart pointers for when the plugin performs a - // callback later - host_application = host_context; + // Automatically converted smart pointers for when the plugin performs a + // callback later + host_application = host_context; - std::optional host_context_args{}; - if (host_context) { - host_context_args = - Vst3HostContextProxy::ConstructArgs(host_context, std::nullopt); + return bridge.send_message(YaPluginFactory::SetHostContext{ + .host_context_args = Vst3HostContextProxy::ConstructArgs( + host_context, std::nullopt)}); } else { bridge.logger.log( - "Null pointer passed to 'IPluginFactory3::setHostContext()'"); + "WARNING: Null pointer passed to " + "'IPluginFactory3::setHostContext()'"); + return Steinberg::kInvalidArgument; } - - return bridge.send_message(YaPluginFactory::SetHostContext{ - .host_context_args = std::move(host_context_args)}); } diff --git a/src/plugin/bridges/vst3-impls/plugin-proxy.cpp b/src/plugin/bridges/vst3-impls/plugin-proxy.cpp index 6f2c2ed6..2b196590 100644 --- a/src/plugin/bridges/vst3-impls/plugin-proxy.cpp +++ b/src/plugin/bridges/vst3-impls/plugin-proxy.cpp @@ -406,7 +406,8 @@ tresult PLUGIN_API Vst3PluginProxyImpl::initialize(FUnknown* context) { .host_context_args = Vst3HostContextProxy::ConstructArgs( host_context, instance_id())}); } else { - bridge.logger.log("Null pointer passed to 'IPluginBase::initialize()'"); + bridge.logger.log( + "WARNING: Null pointer passed to 'IPluginBase::initialize()'"); return Steinberg::kInvalidArgument; } } diff --git a/src/wine-host/bridges/vst3.cpp b/src/wine-host/bridges/vst3.cpp index 8a289086..261e274e 100644 --- a/src/wine-host/bridges/vst3.cpp +++ b/src/wine-host/bridges/vst3.cpp @@ -443,18 +443,14 @@ void Vst3Bridge::run() { }, [&](YaPluginFactory::SetHostContext& request) -> YaPluginFactory::SetHostContext::Response { - if (request.host_context_args) { - plugin_factory_host_context = - Steinberg::owned(new Vst3HostContextProxyImpl( - *this, std::move(*request.host_context_args))); - } else { - plugin_factory_host_context = nullptr; - } + plugin_factory_host_context = + Steinberg::owned(new Vst3HostContextProxyImpl( + *this, std::move(request.host_context_args))); Steinberg::FUnknownPtr factory_3( module->getFactory().get()); - assert(factory_3); + return factory_3->setHostContext(plugin_factory_host_context); }}); }