Create Vst3HostContextProxy from YaHostApplication

This is quite a huge refactor, but note everything is consistent (and
we're going to need one or two more of these `Vst3*Proxy` objects).
Right now nothing extends `IHostApplication`, but this way it will be
trivial to add support for more host context interfaces.
This commit is contained in:
Robbert van der Helm
2020-12-19 17:13:17 +01:00
parent c94089b832
commit 0522f84f4a
21 changed files with 301 additions and 184 deletions
@@ -100,24 +100,21 @@ YaPluginFactoryImpl::createInstance(Steinberg::FIDString cid,
tresult PLUGIN_API
YaPluginFactoryImpl::setHostContext(Steinberg::FUnknown* context) {
// This `context` will likely be an `IHostApplication`. If it is, we will
// store it for future calls, create a proxy object on the Wine side, and
// then pass it to the Windows VST3 plugin's plugin factory using the same
// function. If we get passed anything else we'll just return instead since
// there's nothing we can do with it.
host_application_context = 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 (host_application_context) {
YaHostApplication::ConstructArgs host_application_context_args(
host_application_context, std::nullopt);
return bridge.send_message(YaPluginFactory::SetHostContext{
.host_application_context_args =
std::move(host_application_context_args)});
std::optional<Vst3HostContextProxy::ConstructArgs> host_context_args{};
if (host_context) {
host_context_args =
Vst3HostContextProxy::ConstructArgs(host_context, std::nullopt);
} else {
bridge.logger.log_unknown_interface(
"In IPluginFactory3::setHostContext(), ignoring",
context ? std::optional(context->iid) : std::nullopt);
return Steinberg::kNotImplemented;
bridge.logger.log(
"Null pointer passed to 'IPluginFactory3::setHostContext()'");
}
return bridge.send_message(YaPluginFactory::SetHostContext{
.host_context_args = std::move(host_context_args)});
}
@@ -32,9 +32,8 @@ class YaPluginFactoryImpl : public YaPluginFactory {
Vst3PluginBridge& bridge;
/**
* An `IHostApplication` instance if we get one through
* An host context if we get passed one through
* `IPluginFactory3::setHostContext()`.
*/
Steinberg::FUnknownPtr<Steinberg::Vst::IHostApplication>
host_application_context;
Steinberg::IPtr<Steinberg::FUnknown> host_context;
};
+18 -22
View File
@@ -315,18 +315,18 @@ Vst3PluginProxyImpl::setParamNormalized(Steinberg::Vst::ParamID id,
tresult PLUGIN_API Vst3PluginProxyImpl::setComponentHandler(
Steinberg::Vst::IComponentHandler* handler) {
// We'll store the pointer for when the plugin later makes a callback to
// this component handler
component_handler = handler;
std::optional<Vst3ComponentHandlerProxy::ConstructArgs>
component_handler_proxy_args = std::nullopt;
if (handler) {
// We'll store the pointer for when the plugin later makes a callback to
// this component handler
component_handler = handler;
component_handler_proxy_args = Vst3ComponentHandlerProxy::ConstructArgs(
component_handler, instance_id());
} else {
bridge.logger.log(
"Null pointer passed to 'IEditController::setComponentHandler'");
"Null pointer passed to 'IEditController::setComponentHandler()'");
}
return bridge.send_message(YaEditController::SetComponentHandler{
@@ -362,27 +362,23 @@ tresult PLUGIN_API Vst3PluginProxyImpl::openAboutBox(TBool onlyCheck) {
}
tresult PLUGIN_API Vst3PluginProxyImpl::initialize(FUnknown* context) {
// This `context` will likely be an `IHostApplication`. If it is, we
// will store it here, and we'll proxy through all calls to it made from
// the Wine side. Otherwise we'll still call `IPluginBase::initialize()`
// but with a null pointer instead.
host_application_context = 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<YaHostApplication::ConstructArgs>
host_application_context_args = std::nullopt;
if (host_application_context) {
host_application_context_args = YaHostApplication::ConstructArgs(
host_application_context, instance_id());
std::optional<Vst3HostContextProxy::ConstructArgs> host_context_args{};
if (host_context) {
host_context_args =
Vst3HostContextProxy::ConstructArgs(host_context, instance_id());
} else {
bridge.logger.log_unknown_interface(
"In IPluginBase::initialize()",
context ? std::optional(context->iid) : std::nullopt);
bridge.logger.log("Null pointer passed to 'IPluginBase::initialize()'");
}
return bridge.send_message(
YaPluginBase::Initialize{.instance_id = instance_id(),
.host_application_context_args =
std::move(host_application_context_args)});
return bridge.send_message(YaPluginBase::Initialize{
.instance_id = instance_id(),
.host_context_args = std::move(host_context_args)});
}
tresult PLUGIN_API Vst3PluginProxyImpl::terminate() {
+9 -9
View File
@@ -122,15 +122,6 @@ class Vst3PluginProxyImpl : public Vst3PluginProxy {
tresult PLUGIN_API initialize(FUnknown* context) override;
tresult PLUGIN_API terminate() override;
/**
* An `IHostApplication` instance if we get one through
* `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;
/**
* The component handler the host passed to us during
* `IEditController::setComponentHandler()`. When the plugin makes a
@@ -141,4 +132,13 @@ class Vst3PluginProxyImpl : public Vst3PluginProxy {
private:
Vst3PluginBridge& bridge;
/**
* An host context if we get passed one through `IPluginBase::initialize()`.
* We'll read which interfaces it supports and we'll then create a proxy
* object that supports those same interfaces. 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::IPtr<Steinberg::FUnknown> host_context;
};