diff --git a/src/common/logging/vst3.cpp b/src/common/logging/vst3.cpp index b259da24..d75c4e8a 100644 --- a/src/common/logging/vst3.cpp +++ b/src/common/logging/vst3.cpp @@ -322,13 +322,7 @@ bool Vst3Logger::log_request(bool is_host_vst, const YaPluginBase::Initialize& request) { return log_request_base(is_host_vst, [&](auto& message) { message << request.instance_id - << ": IPluginBase::initialize(context = "; - if (request.host_context_args) { - message << ""; - } else { - message << ""; - } - message << ")"; + << ": IPluginBase::initialize(context = )"; }); } diff --git a/src/common/serialization/vst3/plugin/plugin-base.h b/src/common/serialization/vst3/plugin/plugin-base.h index ad89d37f..5958ac9b 100644 --- a/src/common/serialization/vst3/plugin/plugin-base.h +++ b/src/common/serialization/vst3/plugin/plugin-base.h @@ -16,7 +16,6 @@ #pragma once -#include #include #include "../../common.h" @@ -77,12 +76,12 @@ class YaPluginBase : public Steinberg::IPluginBase { native_size_t instance_id; - std::optional host_context_args; + Vst3HostContextProxy::ConstructArgs host_context_args; template void serialize(S& s) { s.value8b(instance_id); - s.ext(host_context_args, bitsery::ext::StdOptional{}); + s.object(host_context_args); } }; diff --git a/src/plugin/bridges/vst3-impls/plugin-proxy.cpp b/src/plugin/bridges/vst3-impls/plugin-proxy.cpp index 6e6861b3..6f2c2ed6 100644 --- a/src/plugin/bridges/vst3-impls/plugin-proxy.cpp +++ b/src/plugin/bridges/vst3-impls/plugin-proxy.cpp @@ -394,23 +394,21 @@ tresult PLUGIN_API Vst3PluginProxyImpl::openAboutBox(TBool onlyCheck) { } tresult PLUGIN_API Vst3PluginProxyImpl::initialize(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; - std::optional host_context_args{}; - if (host_context) { - host_context_args = - Vst3HostContextProxy::ConstructArgs(host_context, instance_id()); + return bridge.send_message(YaPluginBase::Initialize{ + .instance_id = instance_id(), + .host_context_args = Vst3HostContextProxy::ConstructArgs( + host_context, instance_id())}); } else { bridge.logger.log("Null pointer passed to 'IPluginBase::initialize()'"); + return Steinberg::kInvalidArgument; } - - return bridge.send_message(YaPluginBase::Initialize{ - .instance_id = instance_id(), - .host_context_args = std::move(host_context_args)}); } tresult PLUGIN_API Vst3PluginProxyImpl::terminate() { diff --git a/src/wine-host/bridges/vst3.cpp b/src/wine-host/bridges/vst3.cpp index 0b0e173a..8a289086 100644 --- a/src/wine-host/bridges/vst3.cpp +++ b/src/wine-host/bridges/vst3.cpp @@ -405,22 +405,15 @@ void Vst3Bridge::run() { }, [&](YaPluginBase::Initialize& request) -> YaPluginBase::Initialize::Response { - // If we got passed a host context, we'll create a proxy object - // and pass that to the initialize function. The lifetime of - // this object is tied to that of the actual plugin object we're - // proxying for. + // We'll create a proxy object for the host context passed by + // the host and pass that to the initialize function. The + // lifetime of this object is tied to that of the actual plugin + // object we're proxying for. // TODO: This needs changing if it turns out we need a // `Vst3HostProxy` - // TODO: Does this have to be run from the UI thread? Figure out - // if it does - if (request.host_context_args) { - object_instances[request.instance_id].host_context_proxy = - Steinberg::owned(new Vst3HostContextProxyImpl( - *this, std::move(*request.host_context_args))); - } else { - object_instances[request.instance_id].host_context_proxy = - nullptr; - } + object_instances[request.instance_id].host_context_proxy = + Steinberg::owned(new Vst3HostContextProxyImpl( + *this, std::move(request.host_context_args))); // XXX: Should `IPlugView::{initialize,terminate}` be run from // the main UI thread? I can see how plugins would want to