mirror of
https://github.com/robbert-vdh/yabridge.git
synced 2026-05-07 03:50:11 +02:00
Split IPluginBase from IComponent
We're also going to need this for `IEditController`. Separating all of these classes will also keep everything much more maintainable with all of these associated structs.
This commit is contained in:
@@ -2,6 +2,8 @@
|
||||
|
||||
TODO: Flesh this out further
|
||||
|
||||
TODO: Link to `src/common/serialization/vst3/README.md`
|
||||
|
||||
The VST3 SDK uses an architecture where every concrete object inherits from an
|
||||
interface, and every interface inherits from `FUnknown`. `FUnkonwn` offers a
|
||||
dynamic casting interface through `queryInterface()` and a reference counting
|
||||
|
||||
@@ -83,6 +83,7 @@ vst3_plugin_sources = [
|
||||
'src/common/serialization/vst3/host-application.cpp',
|
||||
'src/common/serialization/vst3/param-value-queue.cpp',
|
||||
'src/common/serialization/vst3/parameter-changes.cpp',
|
||||
'src/common/serialization/vst3/plugin-base.cpp',
|
||||
'src/common/serialization/vst3/plugin-factory.cpp',
|
||||
'src/common/serialization/vst3/process-data.cpp',
|
||||
'src/common/configuration.cpp',
|
||||
@@ -122,6 +123,7 @@ if with_vst3
|
||||
'src/common/serialization/vst3/host-application.cpp',
|
||||
'src/common/serialization/vst3/param-value-queue.cpp',
|
||||
'src/common/serialization/vst3/parameter-changes.cpp',
|
||||
'src/common/serialization/vst3/plugin-base.cpp',
|
||||
'src/common/serialization/vst3/plugin-factory.cpp',
|
||||
'src/common/serialization/vst3/process-data.cpp',
|
||||
'src/wine-host/bridges/vst3-impls/host-application.cpp',
|
||||
|
||||
+21
-21
@@ -54,27 +54,6 @@ void Vst3Logger::log_request(bool is_host_vst,
|
||||
});
|
||||
}
|
||||
|
||||
void Vst3Logger::log_request(bool is_host_vst,
|
||||
const YaComponent::Initialize& request) {
|
||||
log_request_base(is_host_vst, [&](auto& message) {
|
||||
message << "<IComponent* #" << request.instance_id
|
||||
<< ">::initialize(context = ";
|
||||
if (request.host_application_context_args) {
|
||||
message << "<IHostApplication*>";
|
||||
} else {
|
||||
message << "<nullptr>";
|
||||
}
|
||||
message << ")";
|
||||
});
|
||||
}
|
||||
|
||||
void Vst3Logger::log_request(bool is_host_vst,
|
||||
const YaComponent::Terminate& request) {
|
||||
log_request_base(is_host_vst, [&](auto& message) {
|
||||
message << "<IComponent* #" << request.instance_id << ">::terminate()";
|
||||
});
|
||||
}
|
||||
|
||||
void Vst3Logger::log_request(bool is_host_vst,
|
||||
const YaComponent::SetIoMode& request) {
|
||||
log_request_base(is_host_vst, [&](auto& message) {
|
||||
@@ -227,6 +206,27 @@ void Vst3Logger::log_request(bool is_host_vst,
|
||||
});
|
||||
}
|
||||
|
||||
void Vst3Logger::log_request(bool is_host_vst,
|
||||
const YaPluginBase::Initialize& request) {
|
||||
log_request_base(is_host_vst, [&](auto& message) {
|
||||
message << "<IPluginBase* #" << request.instance_id
|
||||
<< ">::initialize(context = ";
|
||||
if (request.host_application_context_args) {
|
||||
message << "<IHostApplication*>";
|
||||
} else {
|
||||
message << "<nullptr>";
|
||||
}
|
||||
message << ")";
|
||||
});
|
||||
}
|
||||
|
||||
void Vst3Logger::log_request(bool is_host_vst,
|
||||
const YaPluginBase::Terminate& request) {
|
||||
log_request_base(is_host_vst, [&](auto& message) {
|
||||
message << "<IPluginBase* #" << request.instance_id << ">::terminate()";
|
||||
});
|
||||
}
|
||||
|
||||
void Vst3Logger::log_request(bool is_host_vst,
|
||||
const YaPluginFactory::Construct&) {
|
||||
log_request_base(is_host_vst,
|
||||
|
||||
@@ -58,8 +58,6 @@ class Vst3Logger {
|
||||
|
||||
void log_request(bool is_host_vst, const YaComponent::Construct&);
|
||||
void log_request(bool is_host_vst, const YaComponent::Destruct&);
|
||||
void log_request(bool is_host_vst, const YaComponent::Initialize&);
|
||||
void log_request(bool is_host_vst, const YaComponent::Terminate&);
|
||||
void log_request(bool is_host_vst, const YaComponent::SetIoMode&);
|
||||
void log_request(bool is_host_vst, const YaComponent::GetBusCount&);
|
||||
void log_request(bool is_host_vst, const YaComponent::GetBusInfo&);
|
||||
@@ -77,6 +75,8 @@ class Vst3Logger {
|
||||
void log_request(bool is_host_vst, const YaComponent::SetProcessing&);
|
||||
void log_request(bool is_host_vst, const YaComponent::Process&);
|
||||
void log_request(bool is_host_vst, const YaComponent::GetTailSamples&);
|
||||
void log_request(bool is_host_vst, const YaPluginBase::Initialize&);
|
||||
void log_request(bool is_host_vst, const YaPluginBase::Terminate&);
|
||||
void log_request(bool is_host_vst, const YaPluginFactory::Construct&);
|
||||
void log_request(bool is_host_vst, const YaPluginFactory::SetHostContext&);
|
||||
void log_request(bool is_host_vst, const WantsConfiguration&);
|
||||
|
||||
@@ -59,8 +59,6 @@ struct WantsConfiguration {
|
||||
*/
|
||||
using ControlRequest = std::variant<YaComponent::Construct,
|
||||
YaComponent::Destruct,
|
||||
YaComponent::Initialize,
|
||||
YaComponent::Terminate,
|
||||
YaComponent::SetIoMode,
|
||||
YaComponent::GetBusCount,
|
||||
YaComponent::GetBusInfo,
|
||||
@@ -77,6 +75,8 @@ using ControlRequest = std::variant<YaComponent::Construct,
|
||||
YaComponent::SetProcessing,
|
||||
YaComponent::Process,
|
||||
YaComponent::GetTailSamples,
|
||||
YaPluginBase::Initialize,
|
||||
YaPluginBase::Terminate,
|
||||
YaPluginFactory::Construct,
|
||||
YaPluginFactory::SetHostContext>;
|
||||
|
||||
|
||||
@@ -7,11 +7,12 @@ serialization works.
|
||||
|
||||
VST3 interfaces are implemented as follows:
|
||||
|
||||
| Yabridge class | Interfaces | Notes |
|
||||
| ------------------- | ------------------------------------------------------ | ---------------------------------------------------------- |
|
||||
| `YaComponent` | `IComponent`, `IPluginBase`, `IAudioProcessor` | |
|
||||
| `YaHostApplication` | `iHostAPplication` | Used as a 'context' to allow the plugin to maek callbacks. |
|
||||
| `YaPluginFactory` | `IPluginFactory`, `IPluginFactory2`, `IPluginFactory3` | |
|
||||
| Yabridge class | Included in | Interfaces |
|
||||
| ------------------- | ------------- | ------------------------------------------------------ |
|
||||
| `YaComponent` | | `IComponent`, `IAudioProcessor` |
|
||||
| `YaHostApplication` | | `iHostAPplication` |
|
||||
| `YaPluginBase` | `YaComponent` | `IPluginBase` |
|
||||
| `YaPluginFactory` | | `IPluginFactory`, `IPluginFactory2`, `IPluginFactory3` |
|
||||
|
||||
The following interfaces are implemented purely fur serialization purposes:
|
||||
|
||||
|
||||
@@ -21,30 +21,21 @@ YaComponent::ConstructArgs::ConstructArgs() {}
|
||||
YaComponent::ConstructArgs::ConstructArgs(
|
||||
Steinberg::IPtr<Steinberg::Vst::IComponent> component,
|
||||
size_t instance_id)
|
||||
: instance_id(instance_id) {
|
||||
known_iids.insert(component->iid);
|
||||
: instance_id(instance_id),
|
||||
audio_processor_supported(
|
||||
Steinberg::FUnknownPtr<Steinberg::Vst::IAudioProcessor>(component)) {
|
||||
// `IComponent::getControllerClassId`
|
||||
Steinberg::TUID cid;
|
||||
if (component->getControllerClassId(cid) == Steinberg::kResultOk) {
|
||||
edit_controller_cid = std::to_array(cid);
|
||||
}
|
||||
|
||||
// There's no static data we can copy from the audio processor
|
||||
if (auto audio_processor =
|
||||
Steinberg::FUnknownPtr<Steinberg::Vst::IAudioProcessor>(
|
||||
component)) {
|
||||
known_iids.insert(Steinberg::Vst::IAudioProcessor::iid);
|
||||
}
|
||||
}
|
||||
|
||||
YaComponent::YaComponent(const ConstructArgs&& args) : arguments(std::move(args)) {
|
||||
FUNKNOWN_CTOR
|
||||
YaComponent::YaComponent(const ConstructArgs&& args)
|
||||
: YaPluginBase(std::move(args.plugin_base_args)),
|
||||
arguments(std::move(args)){FUNKNOWN_CTOR}
|
||||
|
||||
// Everything else is handled directly through callbacks to minimize the
|
||||
// potential for errors
|
||||
}
|
||||
|
||||
YaComponent::~YaComponent() {
|
||||
YaComponent::~YaComponent() {
|
||||
FUNKNOWN_DTOR
|
||||
}
|
||||
|
||||
@@ -55,14 +46,22 @@ IMPLEMENT_REFCOUNT(YaComponent)
|
||||
|
||||
tresult PLUGIN_API YaComponent::queryInterface(Steinberg::FIDString _iid,
|
||||
void** obj) {
|
||||
QUERY_INTERFACE(_iid, obj, Steinberg::FUnknown::iid, Steinberg::IPluginBase)
|
||||
if (arguments.known_iids.contains(Steinberg::Vst::IComponent::iid)) {
|
||||
QUERY_INTERFACE(_iid, obj, Steinberg::IPluginBase::iid,
|
||||
Steinberg::IPluginBase)
|
||||
QUERY_INTERFACE(_iid, obj, Steinberg::Vst::IComponent::iid,
|
||||
Steinberg::Vst::IComponent)
|
||||
QUERY_INTERFACE(_iid, obj, Steinberg::FUnknown::iid,
|
||||
Steinberg::Vst::IComponent)
|
||||
if (YaPluginBase::supported()) {
|
||||
// We had to expand the macro here because we need to cast through
|
||||
// `YaPluginBase`, since `IpluginBase` is also a base of `IComponent`
|
||||
if (Steinberg::FUnknownPrivate ::iidEqual(
|
||||
_iid, Steinberg::IPluginBase::iid)) {
|
||||
addRef();
|
||||
*obj = static_cast<Steinberg ::IPluginBase*>(
|
||||
static_cast<YaPluginBase*>(this));
|
||||
return ::Steinberg ::kResultOk;
|
||||
}
|
||||
}
|
||||
if (arguments.known_iids.contains(Steinberg::Vst::IAudioProcessor::iid)) {
|
||||
QUERY_INTERFACE(_iid, obj, Steinberg::Vst::IComponent::iid,
|
||||
Steinberg::Vst::IComponent)
|
||||
if (arguments.audio_processor_supported) {
|
||||
QUERY_INTERFACE(_iid, obj, Steinberg::Vst::IAudioProcessor::iid,
|
||||
Steinberg::Vst::IAudioProcessor)
|
||||
}
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
#include "../common.h"
|
||||
#include "base.h"
|
||||
#include "host-application.h"
|
||||
#include "plugin-base.h"
|
||||
#include "process-data.h"
|
||||
|
||||
#pragma GCC diagnostic push
|
||||
@@ -43,18 +44,18 @@
|
||||
* used for serialization, and on the plugin side have an implementation that
|
||||
* can send control messages.
|
||||
*
|
||||
* This implements all interfaces that an `IComponent` might also implement.
|
||||
*
|
||||
* We might be able to do some caching here with the buss infos, but since that
|
||||
* sounds like a huge potential source of errors we'll just do pure callbacks
|
||||
* for everything other than the edit controller's class ID.
|
||||
*
|
||||
* TODO: Amplement IConnectionPoint
|
||||
* TODO: How should we support IComponents without a seperate edit controller?
|
||||
* Can we just use a separate `YaEditController` that just points to the
|
||||
* same implementation (with the same CID)? Check the reference
|
||||
* implementation in the framework to see how this is initialized, make
|
||||
* sure we support the reference w workflow.
|
||||
* TODO: Rework this into `YaPluginMonolith`
|
||||
* TODO: Eventually this should (optionally) implement everything supported by
|
||||
* the SDK's `AudioEffect` component.
|
||||
*/
|
||||
class YaComponent : public Steinberg::Vst::IComponent,
|
||||
public YaPluginBase,
|
||||
public Steinberg::Vst::IAudioProcessor {
|
||||
public:
|
||||
/**
|
||||
@@ -76,10 +77,10 @@ class YaComponent : public Steinberg::Vst::IComponent,
|
||||
*/
|
||||
native_size_t instance_id;
|
||||
|
||||
/**
|
||||
* The IIDs that the interface we serialized supports.
|
||||
*/
|
||||
std::set<Steinberg::FUID> known_iids;
|
||||
YaPluginBase::ConstructArgs plugin_base_args;
|
||||
|
||||
// TODO: Remove, transitional
|
||||
bool audio_processor_supported;
|
||||
|
||||
/**
|
||||
* The class ID of this component's corresponding editor controller. You
|
||||
@@ -90,10 +91,8 @@ class YaComponent : public Steinberg::Vst::IComponent,
|
||||
template <typename S>
|
||||
void serialize(S& s) {
|
||||
s.value8b(instance_id);
|
||||
s.ext(known_iids, bitsery::ext::StdSet{32},
|
||||
[](S& s, Steinberg::FUID& iid) {
|
||||
s.ext(iid, bitsery::ext::FUID{});
|
||||
});
|
||||
s.object(plugin_base_args);
|
||||
s.value1b(audio_processor_supported);
|
||||
s.ext(edit_controller_cid, bitsery::ext::StdOptional{},
|
||||
[](S& s, auto& cid) { s.container1b(cid); });
|
||||
}
|
||||
@@ -146,49 +145,6 @@ class YaComponent : public Steinberg::Vst::IComponent,
|
||||
|
||||
DECLARE_FUNKNOWN_METHODS
|
||||
|
||||
// From `IPluginBase`
|
||||
|
||||
/**
|
||||
* Message to pass through a call to `IPluginBase::initialize()` to the Wine
|
||||
* plugin host. if we pass an `IHostApplication` instance, then a proxy
|
||||
* `YaHostApplication` should be created and passed as an argument to
|
||||
* `IPluginBase::initialize()`. If this is absent a null pointer should be
|
||||
* passed. The lifetime of this `YaHostApplication` object should be bound
|
||||
* to the `IComponent` we are proxying.
|
||||
*/
|
||||
struct Initialize {
|
||||
using Response = UniversalTResult;
|
||||
|
||||
native_size_t instance_id;
|
||||
std::optional<YaHostApplication::ConstructArgs>
|
||||
host_application_context_args;
|
||||
|
||||
template <typename S>
|
||||
void serialize(S& s) {
|
||||
s.value8b(instance_id);
|
||||
s.ext(host_application_context_args, bitsery::ext::StdOptional{});
|
||||
}
|
||||
};
|
||||
|
||||
virtual tresult PLUGIN_API initialize(FUnknown* context) override = 0;
|
||||
|
||||
/**
|
||||
* Message to pass through a call to `IPluginBase::terminate()` to the Wine
|
||||
* plugin host.
|
||||
*/
|
||||
struct Terminate {
|
||||
using Response = UniversalTResult;
|
||||
|
||||
native_size_t instance_id;
|
||||
|
||||
template <typename S>
|
||||
void serialize(S& s) {
|
||||
s.value8b(instance_id);
|
||||
}
|
||||
};
|
||||
|
||||
virtual tresult PLUGIN_API terminate() override = 0;
|
||||
|
||||
// From `IComponent`
|
||||
tresult PLUGIN_API getControllerClassId(Steinberg::TUID classId) override;
|
||||
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
// yabridge: a Wine VST bridge
|
||||
// Copyright (C) 2020 Robbert van der Helm
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
#include "plugin-base.h"
|
||||
|
||||
YaPluginBase::ConstructArgs::ConstructArgs() {}
|
||||
|
||||
YaPluginBase::ConstructArgs::ConstructArgs(
|
||||
Steinberg::IPtr<Steinberg::FUnknown> component)
|
||||
: supported(Steinberg::FUnknownPtr<Steinberg::IPluginBase>(component)) {}
|
||||
|
||||
YaPluginBase::YaPluginBase(const ConstructArgs&& args)
|
||||
: arguments(std::move(args)) {}
|
||||
@@ -0,0 +1,113 @@
|
||||
// yabridge: a Wine VST bridge
|
||||
// Copyright (C) 2020 Robbert van der Helm
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <bitsery/ext/std_optional.h>
|
||||
#include <pluginterfaces/base/ipluginbase.h>
|
||||
|
||||
#include "../common.h"
|
||||
#include "base.h"
|
||||
#include "host-application.h"
|
||||
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wnon-virtual-dtor"
|
||||
|
||||
/**
|
||||
* Wraps around `IPluginBase` for serialization purposes. Both components and
|
||||
* edit controllers inherit from this. This is instantiated as part of
|
||||
* `YaComponent` or `YaEditController`.
|
||||
*/
|
||||
class YaPluginBase : public Steinberg::IPluginBase {
|
||||
public:
|
||||
/**
|
||||
* These are the arguments for creating a `YaPluginBase`.
|
||||
*/
|
||||
struct ConstructArgs {
|
||||
ConstructArgs();
|
||||
|
||||
/**
|
||||
* Read arguments from an existing implementation. Depending on the
|
||||
* supported interface function more or less of this struct will be left
|
||||
* empty, and `known_iids` will be set accordingly.
|
||||
*/
|
||||
ConstructArgs(Steinberg::IPtr<Steinberg::FUnknown> object);
|
||||
|
||||
/**
|
||||
* Whether the object supported this interface.
|
||||
*/
|
||||
bool supported;
|
||||
|
||||
template <typename S>
|
||||
void serialize(S& s) {
|
||||
s.value1b(supported);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Instantiate this instance with arguments read from another interface
|
||||
* implementation.
|
||||
*/
|
||||
YaPluginBase(const ConstructArgs&& args);
|
||||
|
||||
inline bool supported() { return arguments.supported; }
|
||||
|
||||
/**
|
||||
* Message to pass through a call to `IPluginBase::initialize()` to the Wine
|
||||
* plugin host. if we pass an `IHostApplication` instance, then a proxy
|
||||
* `YaHostApplication` should be created and passed as an argument to
|
||||
* `IPluginBase::initialize()`. If this is absent a null pointer should be
|
||||
* passed. The lifetime of this `YaHostApplication` object should be bound
|
||||
* to the `IComponent` we are proxying.
|
||||
*/
|
||||
struct Initialize {
|
||||
using Response = UniversalTResult;
|
||||
|
||||
native_size_t instance_id;
|
||||
std::optional<YaHostApplication::ConstructArgs>
|
||||
host_application_context_args;
|
||||
|
||||
template <typename S>
|
||||
void serialize(S& s) {
|
||||
s.value8b(instance_id);
|
||||
s.ext(host_application_context_args, bitsery::ext::StdOptional{});
|
||||
}
|
||||
};
|
||||
|
||||
virtual tresult PLUGIN_API initialize(FUnknown* context) override = 0;
|
||||
|
||||
/**
|
||||
* Message to pass through a call to `IPluginBase::terminate()` to the Wine
|
||||
* plugin host.
|
||||
*/
|
||||
struct Terminate {
|
||||
using Response = UniversalTResult;
|
||||
|
||||
native_size_t instance_id;
|
||||
|
||||
template <typename S>
|
||||
void serialize(S& s) {
|
||||
s.value8b(instance_id);
|
||||
}
|
||||
};
|
||||
|
||||
virtual tresult PLUGIN_API terminate() override = 0;
|
||||
|
||||
protected:
|
||||
ConstructArgs arguments;
|
||||
};
|
||||
|
||||
#pragma GCC diagnostic pop
|
||||
@@ -40,35 +40,6 @@ YaComponentPluginImpl::queryInterface(const Steinberg::TUID _iid, void** obj) {
|
||||
return result;
|
||||
}
|
||||
|
||||
tresult PLUGIN_API YaComponentPluginImpl::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;
|
||||
|
||||
std::optional<YaHostApplication::ConstructArgs>
|
||||
host_application_context_args = std::nullopt;
|
||||
if (host_application_context) {
|
||||
host_application_context_args = YaHostApplication::ConstructArgs(
|
||||
host_application_context, arguments.instance_id);
|
||||
} else {
|
||||
bridge.logger.log_unknown_interface(
|
||||
"In IPluginBase::initialize()",
|
||||
context ? std::optional(context->iid) : std::nullopt);
|
||||
}
|
||||
|
||||
return bridge.send_message(
|
||||
YaComponent::Initialize{.instance_id = arguments.instance_id,
|
||||
.host_application_context_args =
|
||||
std::move(host_application_context_args)});
|
||||
}
|
||||
|
||||
tresult PLUGIN_API YaComponentPluginImpl::terminate() {
|
||||
return bridge.send_message(
|
||||
YaComponent::Terminate{.instance_id = arguments.instance_id});
|
||||
}
|
||||
|
||||
tresult PLUGIN_API
|
||||
YaComponentPluginImpl::setIoMode(Steinberg::Vst::IoMode mode) {
|
||||
return bridge.send_message(YaComponent::SetIoMode{
|
||||
@@ -143,6 +114,35 @@ tresult PLUGIN_API YaComponentPluginImpl::getState(Steinberg::IBStream* state) {
|
||||
return response.result;
|
||||
}
|
||||
|
||||
tresult PLUGIN_API YaComponentPluginImpl::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;
|
||||
|
||||
std::optional<YaHostApplication::ConstructArgs>
|
||||
host_application_context_args = std::nullopt;
|
||||
if (host_application_context) {
|
||||
host_application_context_args = YaHostApplication::ConstructArgs(
|
||||
host_application_context, arguments.instance_id);
|
||||
} else {
|
||||
bridge.logger.log_unknown_interface(
|
||||
"In IPluginBase::initialize()",
|
||||
context ? std::optional(context->iid) : std::nullopt);
|
||||
}
|
||||
|
||||
return bridge.send_message(
|
||||
YaPluginBase::Initialize{.instance_id = arguments.instance_id,
|
||||
.host_application_context_args =
|
||||
std::move(host_application_context_args)});
|
||||
}
|
||||
|
||||
tresult PLUGIN_API YaComponentPluginImpl::terminate() {
|
||||
return bridge.send_message(
|
||||
YaPluginBase::Terminate{.instance_id = arguments.instance_id});
|
||||
}
|
||||
|
||||
tresult PLUGIN_API YaComponentPluginImpl::setBusArrangements(
|
||||
Steinberg::Vst::SpeakerArrangement* inputs,
|
||||
int32 numIns,
|
||||
|
||||
@@ -39,9 +39,7 @@ class YaComponentPluginImpl : public YaComponent {
|
||||
tresult PLUGIN_API queryInterface(const Steinberg::TUID _iid,
|
||||
void** obj) override;
|
||||
|
||||
tresult PLUGIN_API initialize(FUnknown* context) override;
|
||||
tresult PLUGIN_API terminate() override;
|
||||
|
||||
// From `IComponent`
|
||||
tresult PLUGIN_API setIoMode(Steinberg::Vst::IoMode mode) override;
|
||||
int32 PLUGIN_API getBusCount(Steinberg::Vst::MediaType type,
|
||||
Steinberg::Vst::BusDirection dir) override;
|
||||
@@ -61,6 +59,10 @@ class YaComponentPluginImpl : public YaComponent {
|
||||
tresult PLUGIN_API setState(Steinberg::IBStream* state) override;
|
||||
tresult PLUGIN_API getState(Steinberg::IBStream* state) override;
|
||||
|
||||
// From `IPluginBase`
|
||||
tresult PLUGIN_API initialize(FUnknown* context) override;
|
||||
tresult PLUGIN_API terminate() override;
|
||||
|
||||
tresult PLUGIN_API
|
||||
setBusArrangements(Steinberg::Vst::SpeakerArrangement* inputs,
|
||||
int32 numIns,
|
||||
|
||||
@@ -26,7 +26,9 @@ ComponentInstance::ComponentInstance() {}
|
||||
|
||||
ComponentInstance::ComponentInstance(
|
||||
Steinberg::IPtr<Steinberg::Vst::IComponent> component)
|
||||
: component(component), audio_processor(component) {}
|
||||
: component(component),
|
||||
plugin_base(component),
|
||||
audio_processor(component) {}
|
||||
|
||||
Vst3Bridge::Vst3Bridge(MainContext& main_context,
|
||||
std::string plugin_dll_path,
|
||||
@@ -86,8 +88,8 @@ void Vst3Bridge::run() {
|
||||
|
||||
return Ack{};
|
||||
},
|
||||
[&](YaComponent::Initialize& request)
|
||||
-> YaComponent::Initialize::Response {
|
||||
[&](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. This object should
|
||||
// be cleaned up again during `YaComponent::Destruct`.
|
||||
@@ -103,12 +105,12 @@ void Vst3Bridge::run() {
|
||||
}
|
||||
|
||||
return component_instances[request.instance_id]
|
||||
.component->initialize(context);
|
||||
.plugin_base->initialize(context);
|
||||
},
|
||||
[&](const YaComponent::Terminate& request)
|
||||
-> YaComponent::Terminate::Response {
|
||||
[&](const YaPluginBase::Terminate& request)
|
||||
-> YaPluginBase::Terminate::Response {
|
||||
return component_instances[request.instance_id]
|
||||
.component->terminate();
|
||||
.plugin_base->terminate();
|
||||
},
|
||||
[&](const YaComponent::SetIoMode& request)
|
||||
-> YaComponent::SetIoMode::Response {
|
||||
|
||||
@@ -28,6 +28,9 @@
|
||||
* A holder for an `IComponent` instance created from the factory along with any
|
||||
* host context proxy objects belonging to it, and several predefined
|
||||
* `FUnknownPtrs` so we don't have to do these dynamic casts all the times..
|
||||
*
|
||||
* TODO: When implementing `IEditController`, change this to use `IPluginBase`
|
||||
* as the base interface.
|
||||
*/
|
||||
struct ComponentInstance {
|
||||
ComponentInstance();
|
||||
@@ -37,7 +40,7 @@ struct ComponentInstance {
|
||||
/**
|
||||
* If the host passes an `IHostApplication` during
|
||||
* `IPluginBase::initialize()`, we'll store a proxy object here and then
|
||||
* pass it to `component->initialize()`.
|
||||
* pass it to `plugin_base->initialize()`.
|
||||
*/
|
||||
Steinberg::IPtr<YaHostApplication> hsot_application_context;
|
||||
|
||||
@@ -49,6 +52,7 @@ struct ComponentInstance {
|
||||
// All smart pointers below are created from `component`. They will be null
|
||||
// pointers if `component` did not implement the interface.
|
||||
|
||||
Steinberg::FUnknownPtr<Steinberg::IPluginBase> plugin_base;
|
||||
Steinberg::FUnknownPtr<Steinberg::Vst::IAudioProcessor> audio_processor;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user