Refactor plugin factories into Vst3*Proxy format

Now every proxy object that's directly created by the host or plugin
shares the same structure.
This commit is contained in:
Robbert van der Helm
2021-02-13 15:42:05 +01:00
parent 4e4ed3a6b4
commit 4f8eaaaa75
14 changed files with 289 additions and 133 deletions
+5 -3
View File
@@ -147,6 +147,7 @@ vst3_plugin_sources = [
'src/common/serialization/vst3/plugin/unit-data.cpp',
'src/common/serialization/vst3/plugin/unit-info.cpp',
'src/common/serialization/vst3/plugin/xml-representation-controller.cpp',
'src/common/serialization/vst3/plugin-factory/plugin-factory.cpp',
'src/common/serialization/vst3/attribute-list.cpp',
'src/common/serialization/vst3/base.cpp',
'src/common/serialization/vst3/bstream.cpp',
@@ -163,14 +164,14 @@ vst3_plugin_sources = [
'src/common/serialization/vst3/plug-frame-proxy.cpp',
'src/common/serialization/vst3/plug-view-proxy.cpp',
'src/common/serialization/vst3/plugin-proxy.cpp',
'src/common/serialization/vst3/plugin-factory.cpp',
'src/common/serialization/vst3/plugin-factory-proxy.cpp',
'src/common/serialization/vst3/process-data.cpp',
'src/common/configuration.cpp',
'src/common/plugins.cpp',
'src/common/utils.cpp',
'src/plugin/bridges/vst3.cpp',
'src/plugin/bridges/vst3-impls/context-menu-target.cpp',
'src/plugin/bridges/vst3-impls/plugin-factory.cpp',
'src/plugin/bridges/vst3-impls/plugin-factory-proxy.cpp',
'src/plugin/bridges/vst3-impls/plug-view-proxy.cpp',
'src/plugin/bridges/vst3-impls/plugin-proxy.cpp',
'src/plugin/host-process.cpp',
@@ -234,6 +235,7 @@ if with_vst3
'src/common/serialization/vst3/plugin/unit-data.cpp',
'src/common/serialization/vst3/plugin/unit-info.cpp',
'src/common/serialization/vst3/plugin/xml-representation-controller.cpp',
'src/common/serialization/vst3/plugin-factory/plugin-factory.cpp',
'src/common/serialization/vst3/attribute-list.cpp',
'src/common/serialization/vst3/base.cpp',
'src/common/serialization/vst3/bstream.cpp',
@@ -250,7 +252,7 @@ if with_vst3
'src/common/serialization/vst3/plug-frame-proxy.cpp',
'src/common/serialization/vst3/plug-view-proxy.cpp',
'src/common/serialization/vst3/plugin-proxy.cpp',
'src/common/serialization/vst3/plugin-factory.cpp',
'src/common/serialization/vst3/plugin-factory-proxy.cpp',
'src/common/serialization/vst3/process-data.cpp',
'src/wine-host/bridges/vst3-impls/component-handler-proxy.cpp',
'src/wine-host/bridges/vst3-impls/connection-point-proxy.cpp',
+26 -15
View File
@@ -66,6 +66,12 @@ void Vst3Logger::log_query_interface(
}
}
bool Vst3Logger::log_request(bool is_host_vst,
const Vst3PluginFactoryProxy::Construct&) {
return log_request_base(
is_host_vst, [&](auto& message) { message << "GetPluginFactory()"; });
}
bool Vst3Logger::log_request(bool is_host_vst,
const Vst3PlugViewProxy::Destruct& request) {
return log_request_base(is_host_vst, [&](auto& message) {
@@ -690,13 +696,7 @@ bool Vst3Logger::log_request(bool is_host_vst,
}
bool Vst3Logger::log_request(bool is_host_vst,
const YaPluginFactory::Construct&) {
return log_request_base(
is_host_vst, [&](auto& message) { message << "GetPluginFactory()"; });
}
bool Vst3Logger::log_request(bool is_host_vst,
const YaPluginFactory::SetHostContext&) {
const YaPluginFactory3::SetHostContext&) {
return log_request_base(is_host_vst, [&](auto& message) {
message << "IPluginFactory3::setHostContext(context = <FUnknown*>)";
});
@@ -1381,6 +1381,25 @@ void Vst3Logger::log_response(bool is_host_vst, const Ack&) {
log_response_base(is_host_vst, [&](auto& message) { message << "ACK"; });
}
void Vst3Logger::log_response(
bool is_host_vst,
const Vst3PluginFactoryProxy::ConstructArgs& args) {
log_response_base(is_host_vst, [&](auto& message) {
message << "<";
if (args.plugin_factory_args.supports_plugin_factory_3) {
message << "IPluginFactory3*";
} else if (args.plugin_factory_args.supports_plugin_factory_2) {
message << "IPluginFactory2*";
} else if (args.plugin_factory_args.supports_plugin_factory) {
message << "IPluginFactory*";
} else {
message << "FUnknown*";
}
message << " with " << args.plugin_factory_args.num_classes
<< " registered classes>";
});
}
void Vst3Logger::log_response(bool is_host_vst,
const std::variant<Vst3PluginProxy::ConstructArgs,
UniversalTResult>& result) {
@@ -1591,14 +1610,6 @@ void Vst3Logger::log_response(
});
}
void Vst3Logger::log_response(bool is_host_vst,
const YaPluginFactory::ConstructArgs& args) {
log_response_base(is_host_vst, [&](auto& message) {
message << "<IPluginFactory* with " << args.num_classes
<< " registered classes>";
});
}
void Vst3Logger::log_response(bool is_host_vst, const Configuration&) {
log_response_base(is_host_vst,
[&](auto& message) { message << "<Configuration>"; });
+5 -3
View File
@@ -61,6 +61,8 @@ class Vst3Logger {
// `log_request()` call returned `true`. This way we can filter out the
// log message for the response together with the request.
bool log_request(bool is_host_vst,
const Vst3PluginFactoryProxy::Construct&);
bool log_request(bool is_host_vst, const Vst3PlugViewProxy::Destruct&);
bool log_request(bool is_host_vst, const Vst3PluginProxy::Construct&);
bool log_request(bool is_host_vst, const Vst3PluginProxy::Destruct&);
@@ -149,8 +151,7 @@ class Vst3Logger {
const YaPlugViewContentScaleSupport::SetContentScaleFactor&);
bool log_request(bool is_host_vst, const YaPluginBase::Initialize&);
bool log_request(bool is_host_vst, const YaPluginBase::Terminate&);
bool log_request(bool is_host_vst, const YaPluginFactory::Construct&);
bool log_request(bool is_host_vst, const YaPluginFactory::SetHostContext&);
bool log_request(bool is_host_vst, const YaPluginFactory3::SetHostContext&);
bool log_request(
bool is_host_vst,
const YaProcessContextRequirements::GetProcessContextRequirements&);
@@ -241,6 +242,8 @@ class Vst3Logger {
const YaUnitHandler2::NotifyUnitByBusChange&);
void log_response(bool is_host_vst, const Ack&);
void log_response(bool is_host_vst,
const Vst3PluginFactoryProxy::ConstructArgs&);
void log_response(
bool is_host_vst,
const std::variant<Vst3PluginProxy::ConstructArgs, UniversalTResult>&);
@@ -280,7 +283,6 @@ class Vst3Logger {
void log_response(bool is_host_vst, const YaPlugView::GetSizeResponse&);
void log_response(bool is_host_vst,
const YaPlugView::CheckSizeConstraintResponse&);
void log_response(bool is_host_vst, const YaPluginFactory::ConstructArgs&);
void log_response(bool is_host_vst, const Configuration&);
void log_response(bool is_host_vst,
const YaProgramListData::GetProgramDataResponse&);
+4 -4
View File
@@ -30,7 +30,7 @@
#include "vst3/host-context-proxy.h"
#include "vst3/plug-frame-proxy.h"
#include "vst3/plug-view-proxy.h"
#include "vst3/plugin-factory.h"
#include "vst3/plugin-factory-proxy.h"
#include "vst3/plugin-proxy.h"
// Event handling for our VST3 plugins works slightly different from how we
@@ -65,7 +65,8 @@ struct WantsConfiguration {
* request of type `ControlRequest(T)` should send back a `T::Response`.
*/
using ControlRequest =
std::variant<Vst3PlugViewProxy::Destruct,
std::variant<Vst3PluginFactoryProxy::Construct,
Vst3PlugViewProxy::Destruct,
Vst3PluginProxy::Construct,
Vst3PluginProxy::Destruct,
Vst3PluginProxy::SetState,
@@ -119,8 +120,7 @@ using ControlRequest =
YaPlugViewContentScaleSupport::SetContentScaleFactor,
YaPluginBase::Initialize,
YaPluginBase::Terminate,
YaPluginFactory::Construct,
YaPluginFactory::SetHostContext,
YaPluginFactory3::SetHostContext,
YaProcessContextRequirements::GetProcessContextRequirements,
YaProgramListData::ProgramDataSupported,
YaProgramListData::GetProgramData,
+2 -1
View File
@@ -10,7 +10,8 @@ VST3 plugin interfaces are implemented as follows:
| yabridge class | Included in | Interfaces |
| ----------------------------------- | ------------------- | ------------------------------------------------------ |
| `YaPluginFactory` | | `IPluginFactory`, `IPluginFactory2`, `IPluginFactory3` |
| `Vst3PluginFactoryProxy` | | All of the below: |
| `YaPluginFactory3` | | `IPluginFactory`, `IPluginFactory2`, `IPluginFactory3` |
| `Vst3ConnectionPointProxy` | | `IConnectionPoint` through `YaConnectionPoint` |
| `Vst3PlugViewProxy` | | All of the below: |
| `YaParameterFinder` | `Vst3PlugViewProxy` | `IParameterFinder` |
@@ -0,0 +1,58 @@
// yabridge: a Wine VST bridge
// Copyright (C) 2020-2021 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-factory-proxy.h"
Vst3PluginFactoryProxy::ConstructArgs::ConstructArgs() {}
Vst3PluginFactoryProxy::ConstructArgs::ConstructArgs(
Steinberg::IPtr<Steinberg::FUnknown> object)
: plugin_factory_args(object) {}
Vst3PluginFactoryProxy::Vst3PluginFactoryProxy(const ConstructArgs&& args)
: YaPluginFactory3(std::move(args.plugin_factory_args)),
arguments(std::move(args)){FUNKNOWN_CTOR}
// clang-format just doesn't understand these macros, I guess
Vst3PluginFactoryProxy::~Vst3PluginFactoryProxy() {
FUNKNOWN_DTOR
}
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdelete-non-virtual-dtor"
IMPLEMENT_REFCOUNT(Vst3PluginFactoryProxy)
#pragma GCC diagnostic pop
tresult PLUGIN_API
Vst3PluginFactoryProxy::queryInterface(Steinberg::FIDString _iid, void** obj) {
if (YaPluginFactory3::supports_plugin_factory()) {
QUERY_INTERFACE(_iid, obj, Steinberg::FUnknown::iid,
Steinberg::IPluginFactory)
QUERY_INTERFACE(_iid, obj, Steinberg::IPluginFactory::iid,
Steinberg::IPluginFactory)
}
if (YaPluginFactory3::supports_plugin_factory_2()) {
QUERY_INTERFACE(_iid, obj, Steinberg::IPluginFactory2::iid,
Steinberg::IPluginFactory2)
}
if (YaPluginFactory3::supports_plugin_factory_3()) {
QUERY_INTERFACE(_iid, obj, Steinberg::IPluginFactory3::iid,
Steinberg::IPluginFactory3)
}
*obj = nullptr;
return Steinberg::kNoInterface;
}
@@ -0,0 +1,86 @@
// yabridge: a Wine VST bridge
// Copyright (C) 2020-2021 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 "../common.h"
#include "plugin-factory/plugin-factory.h"
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wnon-virtual-dtor"
/**
* An abstract class that `IPluginFactory`, and optionally also
* `IPluginFactory2` and `IPluginFactory3` depending on what the Windows VST3
* plugin's plugin factory supports. All information is read once the Wine
* plugin host side, so the only callbacks that we'll make from here are to
* create new objects and to set a host context for the factory (if the host and
* the plugin supports that).
*/
class Vst3PluginFactoryProxy : public YaPluginFactory3 {
public:
/**
* These are the arguments for constructing a `Vst3PluginFactoryProxyImpl`.
*/
struct ConstructArgs {
ConstructArgs();
/**
* Read from an existing object. We will try to mimic this object, so
* we'll support any interfaces this object also supports.
*/
ConstructArgs(Steinberg::IPtr<FUnknown> object);
YaPluginFactory3::ConstructArgs plugin_factory_args;
template <typename S>
void serialize(S& s) {
s.object(plugin_factory_args);
}
};
/**
* Message to request the Windows VST3 plugin's plugin factory information
* from the Wine plugin host.
*/
struct Construct {
using Response = ConstructArgs;
template <typename S>
void serialize(S&) {}
};
/**
* Instantiate this instance with arguments read from an actual plugin
* factory. The is done once during startup and the plugin factory gets
* reused for the lifetime of the module.
*/
Vst3PluginFactoryProxy(const ConstructArgs&& args);
/**
* We do not need special handling here since the Window VST3 plugin's
* plugin factory will also be destroyed when we terminate the Wine plugin
* host or unload the plugin there.
*/
virtual ~Vst3PluginFactoryProxy();
DECLARE_FUNKNOWN_METHODS
private:
ConstructArgs arguments;
};
#pragma GCC diagnostic pop
@@ -21,10 +21,16 @@
#include <public.sdk/source/vst/utility/stringconvert.h>
YaPluginFactory::ConstructArgs::ConstructArgs() {}
YaPluginFactory3::ConstructArgs::ConstructArgs() {}
YaPluginFactory::ConstructArgs::ConstructArgs(
Steinberg::IPtr<Steinberg::IPluginFactory> factory) {
YaPluginFactory3::ConstructArgs::ConstructArgs(
Steinberg::IPtr<Steinberg::FUnknown> object) {
Steinberg::FUnknownPtr<Steinberg::IPluginFactory> factory(object);
if (!factory) {
return;
}
supports_plugin_factory = true;
// `IPluginFactory::getFactoryInfo`
if (Steinberg::PFactoryInfo info;
factory->getFactoryInfo(&info) == Steinberg::kResultOk) {
@@ -93,40 +99,11 @@ YaPluginFactory::ConstructArgs::ConstructArgs(
}
}
YaPluginFactory::YaPluginFactory(const ConstructArgs&& args)
: arguments(std::move(args)){FUNKNOWN_CTOR}
// clang-format just doesn't understand these macros, I guess
YaPluginFactory::~YaPluginFactory() {
FUNKNOWN_DTOR
}
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdelete-non-virtual-dtor"
IMPLEMENT_REFCOUNT(YaPluginFactory)
#pragma GCC diagnostic pop
tresult PLUGIN_API YaPluginFactory::queryInterface(Steinberg::FIDString _iid,
void** obj) {
QUERY_INTERFACE(_iid, obj, Steinberg::FUnknown::iid,
Steinberg::IPluginFactory)
QUERY_INTERFACE(_iid, obj, Steinberg::IPluginFactory::iid,
Steinberg::IPluginFactory)
if (arguments.supports_plugin_factory_2) {
QUERY_INTERFACE(_iid, obj, Steinberg::IPluginFactory2::iid,
Steinberg::IPluginFactory2)
}
if (arguments.supports_plugin_factory_3) {
QUERY_INTERFACE(_iid, obj, Steinberg::IPluginFactory3::iid,
Steinberg::IPluginFactory3)
}
*obj = nullptr;
return Steinberg::kNoInterface;
}
YaPluginFactory3::YaPluginFactory3(const ConstructArgs&& args)
: arguments(std::move(args)) {}
tresult PLUGIN_API
YaPluginFactory::getFactoryInfo(Steinberg::PFactoryInfo* info) {
YaPluginFactory3::getFactoryInfo(Steinberg::PFactoryInfo* info) {
if (info && arguments.factory_info) {
*info = *arguments.factory_info;
return Steinberg::kResultOk;
@@ -135,18 +112,18 @@ YaPluginFactory::getFactoryInfo(Steinberg::PFactoryInfo* info) {
}
}
int32 PLUGIN_API YaPluginFactory::countClasses() {
int32 PLUGIN_API YaPluginFactory3::countClasses() {
return arguments.num_classes;
}
tresult PLUGIN_API YaPluginFactory::getClassInfo(Steinberg::int32 index,
Steinberg::PClassInfo* info) {
tresult PLUGIN_API YaPluginFactory3::getClassInfo(Steinberg::int32 index,
Steinberg::PClassInfo* info) {
if (index >= static_cast<int32>(arguments.class_infos_1.size())) {
return Steinberg::kInvalidArgument;
}
// We will have already converted these class IDs to the native
// representation in `YaPluginFactory::ConstructArgs`
// representation in `YaPluginFactory3::ConstructArgs`
if (arguments.class_infos_1[index]) {
*info = *arguments.class_infos_1[index];
return Steinberg::kResultOk;
@@ -156,13 +133,13 @@ tresult PLUGIN_API YaPluginFactory::getClassInfo(Steinberg::int32 index,
}
tresult PLUGIN_API
YaPluginFactory::getClassInfo2(int32 index, Steinberg::PClassInfo2* info) {
YaPluginFactory3::getClassInfo2(int32 index, Steinberg::PClassInfo2* info) {
if (index >= static_cast<int32>(arguments.class_infos_2.size())) {
return Steinberg::kInvalidArgument;
}
// We will have already converted these class IDs to the native
// representation in `YaPluginFactory::ConstructArgs`
// representation in `YaPluginFactory3::ConstructArgs`
if (arguments.class_infos_2[index]) {
*info = *arguments.class_infos_2[index];
return Steinberg::kResultOk;
@@ -172,14 +149,14 @@ YaPluginFactory::getClassInfo2(int32 index, Steinberg::PClassInfo2* info) {
}
tresult PLUGIN_API
YaPluginFactory::getClassInfoUnicode(int32 index,
Steinberg::PClassInfoW* info) {
YaPluginFactory3::getClassInfoUnicode(int32 index,
Steinberg::PClassInfoW* info) {
if (index >= static_cast<int32>(arguments.class_infos_unicode.size())) {
return Steinberg::kInvalidArgument;
}
// We will have already converted these class IDs to the native
// representation in `YaPluginFactory::ConstructArgs`
// representation in `YaPluginFactory3::ConstructArgs`
if (arguments.class_infos_unicode[index]) {
*info = *arguments.class_infos_unicode[index];
return Steinberg::kResultOk;
@@ -20,40 +20,45 @@
#include <bitsery/traits/string.h>
#include <pluginterfaces/base/ipluginbase.h>
#include "base.h"
#include "host-context-proxy.h"
#include "../base.h"
#include "../host-context-proxy.h"
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wnon-virtual-dtor"
/**
* Wraps around `IPluginFactory{1,2,3}` for serialization purposes. See
* `docs/vst3.md` for more information on how this works.
*
* TODO: Redo this in the new 'Vst3PluginFactoryProxy' style
* Wraps around `IPluginFactory{1,2,3}` for serialization purposes. This is
* instantiated as part of `Vst3PluginFactoryProxy`.
*/
class YaPluginFactory : public Steinberg::IPluginFactory3 {
class YaPluginFactory3 : public Steinberg::IPluginFactory3 {
public:
/**
* These are the arguments for constructing a `YaPluginFactoryImpl`.
* These are the arguments for creating a `YaPluginFactory3`. All class
* infos in all available formats are read from the plugin so the host can
* query them.
*/
struct ConstructArgs {
ConstructArgs();
/**
* Create a copy of an existing plugin factory. Depending on the
* supported interface function more or less of this struct will be left
* empty, and `known_iids` will be set accordingly.
* Check whether an existing implementation implements
* `IPluginFactory1`, `IPluginFactory2`, and ``IPluginFactory3`` and
* read arguments from it.
*/
ConstructArgs(Steinberg::IPtr<Steinberg::IPluginFactory> factory);
ConstructArgs(Steinberg::IPtr<Steinberg::FUnknown> object);
/**
* Whether `factory` supported `IPluginFactory2`.
* Whether the object supported `IPluginFactory`.
*/
bool supports_plugin_factory = false;
/**
* Whether the object supported `IPluginFactory2`.
*/
bool supports_plugin_factory_2 = false;
/**
* Whether `factory` supported `IPluginFactory3`.
* Whether the object supported `IPluginFactory3`.
*/
bool supports_plugin_factory_3 = false;
@@ -93,6 +98,7 @@ class YaPluginFactory : public Steinberg::IPluginFactory3 {
template <typename S>
void serialize(S& s) {
s.value1b(supports_plugin_factory);
s.value1b(supports_plugin_factory_2);
s.value1b(supports_plugin_factory_3);
s.ext(factory_info, bitsery::ext::StdOptional{});
@@ -112,31 +118,27 @@ class YaPluginFactory : public Steinberg::IPluginFactory3 {
}
};
/**
* Message to request the `IPluginFactory{,2,3}`'s information from the Wine
* plugin host.
*/
struct Construct {
using Response = ConstructArgs;
template <typename S>
void serialize(S&) {}
};
/**
* Instantiate this instance with arguments read from the Windows VST3
* plugin's plugin factory.
*/
YaPluginFactory(const ConstructArgs&& args);
YaPluginFactory3(const ConstructArgs&& args);
/**
* We do not need to implement the destructor in `YaPluginFactoryImpl`,
* since when the sockets are closed, RAII will clean up the Windows VST3
* module we loaded along with its factory for us.
*/
virtual ~YaPluginFactory();
inline bool supports_plugin_factory() const {
return arguments.supports_plugin_factory;
}
DECLARE_FUNKNOWN_METHODS
inline bool supports_plugin_factory_2() const {
return arguments.supports_plugin_factory_2;
}
inline bool supports_plugin_factory_3() const {
return arguments.supports_plugin_factory_3;
}
// All of these functiosn returning class information are fetched once on
// the Wine side since they'll be static so we can just copy over the
// responses
// From `IPluginFactory`
tresult PLUGIN_API getFactoryInfo(Steinberg::PFactoryInfo* info) override;
@@ -144,7 +146,8 @@ class YaPluginFactory : public Steinberg::IPluginFactory3 {
tresult PLUGIN_API getClassInfo(Steinberg::int32 index,
Steinberg::PClassInfo* info) override;
/**
* See the implementation in `YaPluginFactoryImpl` for how this is handled.
* See the implementation in `Vst3PluginFactoryProxyImpl` for how this is
* handled. We'll create new managed `Vst3PluginProxy` objects from here.
*/
virtual tresult PLUGIN_API createInstance(Steinberg::FIDString cid,
Steinberg::FIDString _iid,
@@ -14,21 +14,32 @@
// 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-factory.h"
#include "plugin-factory-proxy.h"
#include <pluginterfaces/vst/ivstcomponent.h>
#include "../vst3.h"
#include "plugin-proxy.h"
YaPluginFactoryImpl::YaPluginFactoryImpl(Vst3PluginBridge& bridge,
YaPluginFactory::ConstructArgs&& args)
: YaPluginFactory(std::move(args)), bridge(bridge) {}
Vst3PluginFactoryProxyImpl::Vst3PluginFactoryProxyImpl(
Vst3PluginBridge& bridge,
Vst3PluginFactoryProxy::ConstructArgs&& args)
: Vst3PluginFactoryProxy(std::move(args)), bridge(bridge) {}
tresult PLUGIN_API
YaPluginFactoryImpl::createInstance(Steinberg::FIDString cid,
Steinberg::FIDString _iid,
void** obj) {
Vst3PluginFactoryProxyImpl::queryInterface(const Steinberg::TUID _iid,
void** obj) {
const tresult result = Vst3PluginFactoryProxy::queryInterface(_iid, obj);
bridge.logger.log_query_interface("In IPluginFactory::queryInterface()",
result, Steinberg::FUID::fromTUID(_iid));
return result;
}
tresult PLUGIN_API
Vst3PluginFactoryProxyImpl::createInstance(Steinberg::FIDString cid,
Steinberg::FIDString _iid,
void** obj) {
// Class IDs may be padded with null bytes
constexpr size_t uid_size = sizeof(Steinberg::TUID);
if (!cid || !_iid || !obj || strnlen(_iid, uid_size) < uid_size) {
@@ -94,7 +105,7 @@ YaPluginFactoryImpl::createInstance(Steinberg::FIDString cid,
}
tresult PLUGIN_API
YaPluginFactoryImpl::setHostContext(Steinberg::FUnknown* context) {
Vst3PluginFactoryProxyImpl::setHostContext(Steinberg::FUnknown* 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
@@ -107,7 +118,7 @@ YaPluginFactoryImpl::setHostContext(Steinberg::FUnknown* context) {
host_application = host_context;
plug_interface_support = host_context;
return bridge.send_message(YaPluginFactory::SetHostContext{
return bridge.send_message(YaPluginFactory3::SetHostContext{
.host_context_args = Vst3HostContextProxy::ConstructArgs(
host_context, std::nullopt)});
} else {
@@ -16,16 +16,23 @@
#pragma once
#include "../../../common/serialization/vst3/plugin-factory.h"
#include "../../../common/serialization/vst3/plugin-factory-proxy.h"
// We need an `IPtr<YaPluginFactoryImpl>` in `Vst3PluginBridge`, so we need to
// declare this slightly differently to avoid circular includes.
// We need an `IPtr<Vst3PluginFactoryProxyImpl>` in `Vst3PluginBridge`, so we
// need to declare this slightly differently to avoid circular includes.
class Vst3PluginBridge;
class YaPluginFactoryImpl : public YaPluginFactory {
class Vst3PluginFactoryProxyImpl : public Vst3PluginFactoryProxy {
public:
YaPluginFactoryImpl(Vst3PluginBridge& bridge,
YaPluginFactory::ConstructArgs&& args);
Vst3PluginFactoryProxyImpl(Vst3PluginBridge& bridge,
Vst3PluginFactoryProxy::ConstructArgs&& args);
/**
* We'll override the query interface to log queries for interfaces we do
* not (yet) support.
*/
tresult PLUGIN_API queryInterface(const Steinberg::TUID _iid,
void** obj) override;
tresult PLUGIN_API createInstance(Steinberg::FIDString cid,
Steinberg::FIDString _iid,
+3 -4
View File
@@ -18,7 +18,6 @@
#include "src/common/serialization/vst3.h"
#include "vst3-impls/context-menu-target.h"
#include "vst3-impls/plugin-factory.h"
#include "vst3-impls/plugin-proxy.h"
using namespace std::literals::string_literals;
@@ -368,12 +367,12 @@ Steinberg::IPluginFactory* Vst3PluginBridge::get_plugin_factory() {
// will request after loading the module. Host callback handlers should
// have started before this since the Wine plugin host will request a
// copy of the configuration during its initialization.
YaPluginFactory::ConstructArgs factory_args =
Vst3PluginFactoryProxy::ConstructArgs factory_args =
sockets.host_vst_control.send_message(
YaPluginFactory::Construct{},
Vst3PluginFactoryProxy::Construct{},
std::pair<Vst3Logger&, bool>(logger, true));
plugin_factory = Steinberg::owned(
new YaPluginFactoryImpl(*this, std::move(factory_args)));
new Vst3PluginFactoryProxyImpl(*this, std::move(factory_args)));
}
// Because we're returning a raw pointer, we have to increase the reference
+2 -3
View File
@@ -18,11 +18,10 @@
#include <thread>
#include "../..//common/serialization/vst3/plugin-factory.h"
#include "../../common/communication/vst3.h"
#include "../../common/logging/vst3.h"
#include "common.h"
#include "vst3-impls/plugin-factory.h"
#include "vst3-impls/plugin-factory-proxy.h"
// Forward declarations
class Vst3PluginProxyImpl;
@@ -143,7 +142,7 @@ class Vst3PluginBridge : PluginBridge<Vst3Sockets<std::jthread>> {
*
* @related get_plugin_factory
*/
Steinberg::IPtr<YaPluginFactoryImpl> plugin_factory = nullptr;
Steinberg::IPtr<Vst3PluginFactoryProxyImpl> plugin_factory = nullptr;
private:
/**
+7 -7
View File
@@ -113,6 +113,11 @@ void Vst3Bridge::run() {
sockets.host_vst_control.receive_messages(
std::nullopt,
overload{
[&](const Vst3PluginFactoryProxy::Construct&)
-> Vst3PluginFactoryProxy::Construct::Response {
return Vst3PluginFactoryProxy::ConstructArgs(
module->getFactory().get());
},
[&](const Vst3PlugViewProxy::Destruct& request)
-> Vst3PlugViewProxy::Destruct::Response {
main_context
@@ -927,13 +932,8 @@ void Vst3Bridge::run() {
return object_instances[request.instance_id]
.unit_data->setUnitData(request.unit_id, &request.data);
},
[&](const YaPluginFactory::Construct&)
-> YaPluginFactory::Construct::Response {
return YaPluginFactory::ConstructArgs(
module->getFactory().get());
},
[&](YaPluginFactory::SetHostContext& request)
-> YaPluginFactory::SetHostContext::Response {
[&](YaPluginFactory3::SetHostContext& request)
-> YaPluginFactory3::SetHostContext::Response {
plugin_factory_host_context =
Steinberg::owned(new Vst3HostContextProxyImpl(
*this, std::move(request.host_context_args)));