mirror of
https://github.com/robbert-vdh/yabridge.git
synced 2026-06-16 08:23:55 +02:00
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:
+20
-9
@@ -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 {
|
||||
+13
-6
@@ -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,
|
||||
@@ -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
|
||||
|
||||
@@ -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:
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user