From cbb8ebaf5d067299e8c25c8262c4d7086aa636d2 Mon Sep 17 00:00:00 2001 From: Robbert van der Helm Date: Sun, 10 Jan 2021 23:44:10 +0100 Subject: [PATCH] Add a proxy class for IUnitHandler2 --- meson.build | 2 + src/common/serialization/vst3/README.md | 4 +- .../vst3/component-handler/unit-handler-2.cpp | 27 +++++++ .../vst3/component-handler/unit-handler-2.h | 70 +++++++++++++++++++ 4 files changed, 102 insertions(+), 1 deletion(-) create mode 100644 src/common/serialization/vst3/component-handler/unit-handler-2.cpp create mode 100644 src/common/serialization/vst3/component-handler/unit-handler-2.h diff --git a/meson.build b/meson.build index f3eb0d53..51a60d63 100644 --- a/meson.build +++ b/meson.build @@ -115,6 +115,7 @@ vst3_plugin_sources = [ 'src/common/serialization/vst3/component-handler/component-handler-2.cpp', 'src/common/serialization/vst3/component-handler/component-handler-3.cpp', 'src/common/serialization/vst3/component-handler/unit-handler.cpp', + 'src/common/serialization/vst3/component-handler/unit-handler-2.cpp', 'src/common/serialization/vst3/context-menu/context-menu.cpp', 'src/common/serialization/vst3/host-context/host-application.cpp', 'src/common/serialization/vst3/plug-view/parameter-finder.cpp', @@ -190,6 +191,7 @@ if with_vst3 'src/common/serialization/vst3/component-handler/component-handler-2.cpp', 'src/common/serialization/vst3/component-handler/component-handler-3.cpp', 'src/common/serialization/vst3/component-handler/unit-handler.cpp', + 'src/common/serialization/vst3/component-handler/unit-handler-2.cpp', 'src/common/serialization/vst3/context-menu/context-menu.cpp', 'src/common/serialization/vst3/host-context/host-application.cpp', 'src/common/serialization/vst3/plug-view/parameter-finder.cpp', diff --git a/src/common/serialization/vst3/README.md b/src/common/serialization/vst3/README.md index 9b22ab21..90f0f752 100644 --- a/src/common/serialization/vst3/README.md +++ b/src/common/serialization/vst3/README.md @@ -6,7 +6,8 @@ for more information on how the serialization works. The following interfaces are not yet implemented: -- Every interface introduced after VST 3.6.0 +- Interfaces introduced after VST 3.6.0, with some VST 3.6.5 interfaces already + being implemented - The [Presonus extensions](https://presonussoftware.com/en_US/developer), although most of these things seem to overlap with newer VST3 interfaces @@ -48,6 +49,7 @@ VST3 host interfaces are implemented as follows: | `YaComponentHandler2` | `Vst3ComponentHandlerProxy` | `IComponentHandler2` | | `YaComponentHandler3` | `Vst3ComponentHandlerProxy` | `IComponentHandler3` | | `YaUnitHandler` | `Vst3ComponentHandlerProxy` | `IUnitHandler` | +| `YaUnitHandler2` | `Vst3ComponentHandlerProxy` | `IUnitHandler2` | | `Vst3ContextMenuProxy` | | All of the below: | | `YaContextMenu` | `Vst3ContextMenuProxy` | `IContextMenu` | | `Vst3PlugFrameProxy` | | All of the below: | diff --git a/src/common/serialization/vst3/component-handler/unit-handler-2.cpp b/src/common/serialization/vst3/component-handler/unit-handler-2.cpp new file mode 100644 index 00000000..2a92276e --- /dev/null +++ b/src/common/serialization/vst3/component-handler/unit-handler-2.cpp @@ -0,0 +1,27 @@ +// 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 . + +#include "unit-handler-2.h" + +YaUnitHandler2::ConstructArgs::ConstructArgs() {} + +YaUnitHandler2::ConstructArgs::ConstructArgs( + Steinberg::IPtr object) + : supported(Steinberg::FUnknownPtr(object)) { +} + +YaUnitHandler2::YaUnitHandler2(const ConstructArgs&& args) + : arguments(std::move(args)) {} diff --git a/src/common/serialization/vst3/component-handler/unit-handler-2.h b/src/common/serialization/vst3/component-handler/unit-handler-2.h new file mode 100644 index 00000000..e2362c59 --- /dev/null +++ b/src/common/serialization/vst3/component-handler/unit-handler-2.h @@ -0,0 +1,70 @@ +// 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 . + +#pragma once + +#include + +#include "../../common.h" +#include "../base.h" + +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wnon-virtual-dtor" + +/** + * Wraps around `IUnitHandler2` for serialization purposes. This is instantiated + * as part of `Vst3UnitHandler2Proxy`. + */ +class YaUnitHandler2 : public Steinberg::Vst::IUnitHandler2 { + public: + /** + * These are the arguments for creating a `YaUnitHandler2`. + */ + struct ConstructArgs { + ConstructArgs(); + + /** + * Check whether an existing implementation implements `IUnitHandler2` + * 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. + */ + YaUnitHandler2(const ConstructArgs&& args); + + inline bool supported() const { return arguments.supported; } + + virtual tresult PLUGIN_API notifyUnitByBusChange() override = 0; + + protected: + ConstructArgs arguments; +}; + +#pragma GCC diagnostic pop