Use the new approach for creating plugin factory

Directly serializing and deserializing into objects was and more
boilerplate heavy (since we now need two implementations even though we
only use one), and also much less flexible because we can't wrap
payloads in structs or provide optional values that way.
This commit is contained in:
Robbert van der Helm
2020-12-12 21:51:06 +01:00
parent 1b30000147
commit 39984ad442
14 changed files with 151 additions and 204 deletions
-35
View File
@@ -1,35 +0,0 @@
// 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 "vst3-impls.h"
YaPluginFactoryHostImpl::YaPluginFactoryHostImpl(
Steinberg::IPtr<Steinberg::IPluginFactory> factory)
: YaPluginFactory(factory) {}
tresult PLUGIN_API
YaPluginFactoryHostImpl::createInstance(Steinberg::FIDString /*cid*/,
Steinberg::FIDString /*_iid*/,
void** /*obj*/) {
throw std::runtime_error(
"Unexpected call to 'IPluginFactory::createInstance()'");
}
tresult PLUGIN_API
YaPluginFactoryHostImpl::setHostContext(Steinberg::FUnknown* /*context*/) {
throw std::runtime_error(
"Unexpected call to 'IPluginFactory3::setHostContext()'");
}
-31
View File
@@ -1,31 +0,0 @@
// 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 YaPluginFactoryHostImpl : public YaPluginFactory {
public:
YaPluginFactoryHostImpl(Steinberg::IPtr<Steinberg::IPluginFactory> factory);
tresult PLUGIN_API createInstance(Steinberg::FIDString cid,
Steinberg::FIDString _iid,
void** obj) override;
tresult PLUGIN_API
setHostContext(Steinberg::FUnknown* /*context*/) override;
};
+4 -8
View File
@@ -17,7 +17,6 @@
#include "vst3.h"
#include "../boost-fix.h"
#include "vst3-impls.h"
#include <public.sdk/source/vst/hosting/module_win32.cpp>
@@ -36,11 +35,6 @@ Vst3Bridge::Vst3Bridge(MainContext& main_context,
sockets.connect();
// Serialize the plugin's plugin factory. The native VST3 plugin will
// request a copy of this during its initialization.
plugin_factory =
std::make_unique<YaPluginFactoryHostImpl>(module->getFactory().get());
// Fetch this instance's configuration from the plugin to finish the setup
// process
config = sockets.vst_host_callback.send_message(WantsConfiguration{},
@@ -82,8 +76,10 @@ void Vst3Bridge::run() {
-> YaComponent::Terminate::Response {
return component_instances[request.instance_id]->terminate();
},
[&](const WantsPluginFactory&) -> WantsPluginFactory::Response {
return *plugin_factory;
[&](const YaPluginFactory::Construct&)
-> YaPluginFactory::Construct::Response {
return YaPluginFactory::ConstructArgs(
module->getFactory().get());
}});
}
-7
View File
@@ -91,13 +91,6 @@ class Vst3Bridge : public HostBridge {
*/
Vst3Sockets<Win32Thread> sockets;
/**
* A plugin factory copied from the Windows VST3 plugin during
* initialization. The native VST3 plugin will request a copy of this
* information during its initialization.
*/
std::unique_ptr<YaPluginFactory> plugin_factory;
/**
* Used to assign unique identifier to instances created for
* `IPluginFactory::createInstance()`.