From f816b5ad5dceccb9d3dc8e05a284c375c89146b0 Mon Sep 17 00:00:00 2001 From: Robbert van der Helm Date: Sat, 19 Dec 2020 14:27:50 +0100 Subject: [PATCH] Add IComponentHandler to Vst3ComponentHandlerProxy --- meson.build | 4 + .../vst3/component-handler-proxy.cpp | 51 +++++++++++++ .../vst3/component-handler-proxy.h | 24 +----- .../component-handler/component-handler.cpp | 27 +++++++ .../component-handler/component-handler.h | 76 +++++++++++++++++++ 5 files changed, 162 insertions(+), 20 deletions(-) create mode 100644 src/common/serialization/vst3/component-handler-proxy.cpp create mode 100644 src/common/serialization/vst3/component-handler/component-handler.cpp create mode 100644 src/common/serialization/vst3/component-handler/component-handler.h diff --git a/meson.build b/meson.build index 6ff4cece..1c9efea5 100644 --- a/meson.build +++ b/meson.build @@ -83,7 +83,9 @@ vst3_plugin_sources = [ 'src/common/serialization/vst3/plugin/edit-controller.cpp', 'src/common/serialization/vst3/plugin/edit-controller-2.cpp', 'src/common/serialization/vst3/plugin/plugin-base.cpp', + 'src/common/serialization/vst3/component-handler/component-handler.cpp', 'src/common/serialization/vst3/base.cpp', + 'src/common/serialization/vst3/component-handler-proxy.cpp', 'src/common/serialization/vst3/event-list.cpp', 'src/common/serialization/vst3/host-application.cpp', 'src/common/serialization/vst3/param-value-queue.cpp', @@ -128,7 +130,9 @@ if with_vst3 'src/common/serialization/vst3/plugin/edit-controller.cpp', 'src/common/serialization/vst3/plugin/edit-controller-2.cpp', 'src/common/serialization/vst3/plugin/plugin-base.cpp', + 'src/common/serialization/vst3/component-handler/component-handler.cpp', 'src/common/serialization/vst3/base.cpp', + 'src/common/serialization/vst3/component-handler-proxy.cpp', 'src/common/serialization/vst3/event-list.cpp', 'src/common/serialization/vst3/host-application.cpp', 'src/common/serialization/vst3/param-value-queue.cpp', diff --git a/src/common/serialization/vst3/component-handler-proxy.cpp b/src/common/serialization/vst3/component-handler-proxy.cpp new file mode 100644 index 00000000..3961b91b --- /dev/null +++ b/src/common/serialization/vst3/component-handler-proxy.cpp @@ -0,0 +1,51 @@ +// 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 . + +#include "component-handler-proxy.h" + +Vst3ComponentHandlerProxy::ConstructArgs::ConstructArgs() {} + +Vst3ComponentHandlerProxy::ConstructArgs::ConstructArgs( + Steinberg::IPtr object, + size_t owner_instance_id) + : owner_instance_id(owner_instance_id), component_handler_args(object) {} + +Vst3ComponentHandlerProxy::Vst3ComponentHandlerProxy(const ConstructArgs&& args) + : YaComponentHandler(std::move(args.component_handler_args)), + arguments(std::move(args)){FUNKNOWN_CTOR} + + Vst3ComponentHandlerProxy::~Vst3ComponentHandlerProxy() { + FUNKNOWN_DTOR +} + +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wdelete-non-virtual-dtor" +IMPLEMENT_REFCOUNT(Vst3ComponentHandlerProxy) +#pragma GCC diagnostic pop + +tresult PLUGIN_API +Vst3ComponentHandlerProxy::queryInterface(Steinberg::FIDString _iid, + void** obj) { + if (YaComponentHandler::supported()) { + QUERY_INTERFACE(_iid, obj, Steinberg::FUnknown::iid, + Steinberg::Vst::IComponentHandler) + QUERY_INTERFACE(_iid, obj, Steinberg::Vst::IComponentHandler::iid, + Steinberg::Vst::IComponentHandler) + } + + *obj = nullptr; + return Steinberg::kNoInterface; +} diff --git a/src/common/serialization/vst3/component-handler-proxy.h b/src/common/serialization/vst3/component-handler-proxy.h index 597d6219..522392c6 100644 --- a/src/common/serialization/vst3/component-handler-proxy.h +++ b/src/common/serialization/vst3/component-handler-proxy.h @@ -17,13 +17,7 @@ #pragma once #include "../common.h" -#include "base.h" -#include "host-application.h" -#include "plugin/audio-processor.h" -#include "plugin/component.h" -#include "plugin/connection-point.h" -#include "plugin/edit-controller.h" -#include "plugin/plugin-base.h" +#include "component-handler/component-handler.h" #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wnon-virtual-dtor" @@ -36,7 +30,7 @@ * plugin we are proxying for the `IComponentHandler*` argument passed to plugin * by the host. */ -class Vst3ComponentHandlerProxy { +class Vst3ComponentHandlerProxy : public YaComponentHandler { public: /** * These are the arguments for constructing a @@ -60,22 +54,12 @@ class Vst3ComponentHandlerProxy { */ native_size_t owner_instance_id; - // TODO: - // YaAudioProcessor::ConstructArgs audio_processor_args; - // YaComponent::ConstructArgs component_args; - // YaConnectionPoint::ConstructArgs connection_point_args; - // YaEditController::ConstructArgs edit_controller_2_args; - // YaPluginBase::ConstructArgs plugin_base_args; + YaComponentHandler::ConstructArgs component_handler_args; template void serialize(S& s) { s.value8b(owner_instance_id); - // TODO: - // s.object(audio_processor_args); - // s.object(component_args); - // s.object(connection_point_args); - // s.object(edit_controller_2_args); - // s.object(plugin_base_args); + s.object(component_handler_args); } }; diff --git a/src/common/serialization/vst3/component-handler/component-handler.cpp b/src/common/serialization/vst3/component-handler/component-handler.cpp new file mode 100644 index 00000000..a9967efd --- /dev/null +++ b/src/common/serialization/vst3/component-handler/component-handler.cpp @@ -0,0 +1,27 @@ +// 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 . + +#include "component-handler.h" + +YaComponentHandler::ConstructArgs::ConstructArgs() {} + +YaComponentHandler::ConstructArgs::ConstructArgs( + Steinberg::IPtr object) + : supported( + Steinberg::FUnknownPtr(object)) {} + +YaComponentHandler::YaComponentHandler(const ConstructArgs&& args) + : arguments(std::move(args)) {} diff --git a/src/common/serialization/vst3/component-handler/component-handler.h b/src/common/serialization/vst3/component-handler/component-handler.h new file mode 100644 index 00000000..edca75f3 --- /dev/null +++ b/src/common/serialization/vst3/component-handler/component-handler.h @@ -0,0 +1,76 @@ +// 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 . + +#pragma once + +#include + +#include "../../common.h" +#include "../base.h" + +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wnon-virtual-dtor" + +/** + * Wraps around `IComponentHandler` for serialization purposes. This is + * instantiated as part of `Vst3ComponentHandlerProxy`. + */ +class YaComponentHandler : public Steinberg::Vst::IComponentHandler { + public: + /** + * These are the arguments for creating a `YaComponentHandler`. + */ + struct ConstructArgs { + ConstructArgs(); + + /** + * Check whether an existing implementation implements + * `IComponentHandler` and read arguments from it. + */ + ConstructArgs(Steinberg::IPtr object); + + /** + * Whether the object supported this interface. + */ + bool supported; + + template + void serialize(S& s) { + s.value1b(supported); + } + }; + + /** + * Instantiate this instance with arguments read from another interface + * implementation. + */ + YaComponentHandler(const ConstructArgs&& args); + + inline bool supported() const { return arguments.supported; } + + virtual tresult PLUGIN_API + beginEdit(Steinberg::Vst::ParamID id) override = 0; + virtual tresult PLUGIN_API + performEdit(Steinberg::Vst::ParamID id, + Steinberg::Vst::ParamValue valueNormalized) override = 0; + virtual tresult PLUGIN_API endEdit(Steinberg::Vst::ParamID id) override = 0; + virtual tresult PLUGIN_API restartComponent(int32 flags) override = 0; + + protected: + ConstructArgs arguments; +}; + +#pragma GCC diagnostic pop