mirror of
https://github.com/robbert-vdh/yabridge.git
synced 2026-05-07 03:50:11 +02:00
Split up the VST3 class implementations
This commit is contained in:
+2
-1
@@ -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',
|
||||
|
||||
@@ -14,57 +14,7 @@
|
||||
// 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 "vst3-impls.h"
|
||||
|
||||
#include <pluginterfaces/vst/ivstcomponent.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<YaComponent::Arguments> 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] = "<invalid_pointer>";
|
||||
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<const Steinberg::TUID*>(&_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)
|
||||
@@ -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:
|
||||
@@ -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 <https://www.gnu.org/licenses/>.
|
||||
|
||||
#include "plugin-factory.h"
|
||||
|
||||
#include <pluginterfaces/vst/ivstcomponent.h>
|
||||
|
||||
#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<YaComponent::Arguments> 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] = "<invalid_pointer>";
|
||||
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<const Steinberg::TUID*>(&_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;
|
||||
}
|
||||
@@ -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 <https://www.gnu.org/licenses/>.
|
||||
|
||||
#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;
|
||||
};
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user