mirror of
https://github.com/robbert-vdh/yabridge.git
synced 2026-05-15 21:15:51 +02:00
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:
@@ -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()'");
|
||||
}
|
||||
@@ -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;
|
||||
};
|
||||
@@ -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());
|
||||
}});
|
||||
}
|
||||
|
||||
|
||||
@@ -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()`.
|
||||
|
||||
Reference in New Issue
Block a user