diff --git a/meson.build b/meson.build index 648911d6..20f455a6 100644 --- a/meson.build +++ b/meson.build @@ -83,7 +83,8 @@ vst3_plugin_sources = [ 'src/common/plugins.cpp', 'src/common/utils.cpp', 'src/plugin/bridges/vst3.cpp', - 'src/plugin/bridges/vst3-impls.cpp', + 'src/plugin/bridges/vst3-impls/component.cpp', + 'src/plugin/bridges/vst3-impls/plugin-factory.cpp', 'src/plugin/host-process.cpp', 'src/plugin/utils.cpp', 'src/plugin/vst3-plugin.cpp', diff --git a/src/plugin/bridges/vst3-impls.cpp b/src/plugin/bridges/vst3-impls/component.cpp similarity index 60% rename from src/plugin/bridges/vst3-impls.cpp rename to src/plugin/bridges/vst3-impls/component.cpp index fd0d683e..1b8b0db1 100644 --- a/src/plugin/bridges/vst3-impls.cpp +++ b/src/plugin/bridges/vst3-impls/component.cpp @@ -14,57 +14,7 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . -#include "vst3-impls.h" - -#include - -YaPluginFactoryPluginImpl::YaPluginFactoryPluginImpl(Vst3PluginBridge& bridge) - : bridge(bridge) {} - -tresult PLUGIN_API -YaPluginFactoryPluginImpl::createInstance(Steinberg::FIDString cid, - Steinberg::FIDString _iid, - void** obj) { - // TODO: Do the same thing for other types - ArrayUID cid_array; - std::copy(cid, cid + sizeof(Steinberg::TUID), cid_array.begin()); - if (Steinberg::FIDStringsEqual(_iid, Steinberg::Vst::IComponent::iid)) { - std::optional args = - bridge.send_message(YaComponent::Create{.cid = cid_array}); - if (args) { - // I find all of these raw pointers scary - *obj = new YaComponentPluginImpl(bridge, std::move(*args)); - return Steinberg::kResultOk; - } else { - return Steinberg::kNotImplemented; - } - } else { - // When the host requests an interface we do not (yet) implement, we'll - // print a recognizable log message. I don't think they include a safe - // way to convert a `FIDString/char*` into a `FUID`, so this will have - // to do. - char iid_string[128] = ""; - constexpr size_t uid_size = sizeof(Steinberg::TUID); - if (_iid && strnlen(_iid, uid_size + 1) == uid_size) { - Steinberg::FUID iid = Steinberg::FUID::fromTUID( - *reinterpret_cast(&_iid)); - iid.print(iid_string, Steinberg::FUID::UIDPrintStyle::kCLASS_UID); - } - - bridge.logger.log("[Unknown interface] " + std::string(iid_string)); - - return Steinberg::kNotImplemented; - } -} - -tresult PLUGIN_API -YaPluginFactoryPluginImpl::setHostContext(Steinberg::FUnknown* /*context*/) { - // TODO: The docs don't clearly specify what this should be doing, but from - // what I've seen this is only used to pass a `IHostApplication` - // instance. That's used to allow the plugin to create objects in the - // host. - return Steinberg::kNotImplemented; -} +#include "component.h" YaComponentPluginImpl::YaComponentPluginImpl(Vst3PluginBridge& bridge, YaComponent::Arguments&& args) diff --git a/src/plugin/bridges/vst3-impls.h b/src/plugin/bridges/vst3-impls/component.h similarity index 78% rename from src/plugin/bridges/vst3-impls.h rename to src/plugin/bridges/vst3-impls/component.h index 303eab67..a9f34b84 100644 --- a/src/plugin/bridges/vst3-impls.h +++ b/src/plugin/bridges/vst3-impls/component.h @@ -16,25 +16,7 @@ #pragma once -#include "vst3.h" - -// These are implementation of the serialization clases in -// `src/common/serialization/vst3/` to provide callback support -// TODO: Split this up in multiple headers. I hoped it might stay small and easy -// to oversee. It won't. - -class YaPluginFactoryPluginImpl : public YaPluginFactory { - public: - YaPluginFactoryPluginImpl(Vst3PluginBridge& bridge); - - tresult PLUGIN_API createInstance(Steinberg::FIDString cid, - Steinberg::FIDString _iid, - void** obj) override; - tresult PLUGIN_API setHostContext(Steinberg::FUnknown* context) override; - - private: - Vst3PluginBridge& bridge; -}; +#include "../vst3.h" class YaComponentPluginImpl : public YaComponent { public: diff --git a/src/plugin/bridges/vst3-impls/plugin-factory.cpp b/src/plugin/bridges/vst3-impls/plugin-factory.cpp new file mode 100644 index 00000000..07ac1c19 --- /dev/null +++ b/src/plugin/bridges/vst3-impls/plugin-factory.cpp @@ -0,0 +1,69 @@ +// 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 "plugin-factory.h" + +#include + +#include "component.h" + +YaPluginFactoryPluginImpl::YaPluginFactoryPluginImpl(Vst3PluginBridge& bridge) + : bridge(bridge) {} + +tresult PLUGIN_API +YaPluginFactoryPluginImpl::createInstance(Steinberg::FIDString cid, + Steinberg::FIDString _iid, + void** obj) { + // TODO: Do the same thing for other types + ArrayUID cid_array; + std::copy(cid, cid + sizeof(Steinberg::TUID), cid_array.begin()); + if (Steinberg::FIDStringsEqual(_iid, Steinberg::Vst::IComponent::iid)) { + std::optional args = + bridge.send_message(YaComponent::Create{.cid = cid_array}); + if (args) { + // I find all of these raw pointers scary + *obj = new YaComponentPluginImpl(bridge, std::move(*args)); + return Steinberg::kResultOk; + } else { + return Steinberg::kNotImplemented; + } + } else { + // When the host requests an interface we do not (yet) implement, we'll + // print a recognizable log message. I don't think they include a safe + // way to convert a `FIDString/char*` into a `FUID`, so this will have + // to do. + char iid_string[128] = ""; + constexpr size_t uid_size = sizeof(Steinberg::TUID); + if (_iid && strnlen(_iid, uid_size + 1) == uid_size) { + Steinberg::FUID iid = Steinberg::FUID::fromTUID( + *reinterpret_cast(&_iid)); + iid.print(iid_string, Steinberg::FUID::UIDPrintStyle::kCLASS_UID); + } + + bridge.logger.log("[Unknown interface] " + std::string(iid_string)); + + return Steinberg::kNotImplemented; + } +} + +tresult PLUGIN_API +YaPluginFactoryPluginImpl::setHostContext(Steinberg::FUnknown* /*context*/) { + // TODO: The docs don't clearly specify what this should be doing, but from + // what I've seen this is only used to pass a `IHostApplication` + // instance. That's used to allow the plugin to create objects in the + // host. + return Steinberg::kNotImplemented; +} diff --git a/src/plugin/bridges/vst3-impls/plugin-factory.h b/src/plugin/bridges/vst3-impls/plugin-factory.h new file mode 100644 index 00000000..8d877640 --- /dev/null +++ b/src/plugin/bridges/vst3-impls/plugin-factory.h @@ -0,0 +1,32 @@ +// 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 "../vst3.h" + +class YaPluginFactoryPluginImpl : public YaPluginFactory { + public: + YaPluginFactoryPluginImpl(Vst3PluginBridge& bridge); + + tresult PLUGIN_API createInstance(Steinberg::FIDString cid, + Steinberg::FIDString _iid, + void** obj) override; + tresult PLUGIN_API setHostContext(Steinberg::FUnknown* context) override; + + private: + Vst3PluginBridge& bridge; +}; diff --git a/src/plugin/bridges/vst3.cpp b/src/plugin/bridges/vst3.cpp index ae2887e5..e7815fa9 100644 --- a/src/plugin/bridges/vst3.cpp +++ b/src/plugin/bridges/vst3.cpp @@ -17,7 +17,7 @@ #include "vst3.h" #include "src/common/serialization/vst3.h" -#include "vst3-impls.h" +#include "vst3-impls/plugin-factory.h" // There are still some design decisions that need some more thought // TODO: Check whether `IPlugView::isPlatformTypeSupported` needs special