mirror of
https://github.com/robbert-vdh/yabridge.git
synced 2026-05-08 12:30:12 +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:
@@ -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
|
||||
Reference in New Issue
Block a user