Refactor plugin factories into Vst3*Proxy format

Now every proxy object that's directly created by the host or plugin
shares the same structure.
This commit is contained in:
Robbert van der Helm
2021-02-13 15:42:05 +01:00
parent 4e4ed3a6b4
commit 4f8eaaaa75
14 changed files with 289 additions and 133 deletions
@@ -14,21 +14,32 @@
// 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 "plugin-factory-proxy.h"
#include <pluginterfaces/vst/ivstcomponent.h>
#include "../vst3.h"
#include "plugin-proxy.h"
YaPluginFactoryImpl::YaPluginFactoryImpl(Vst3PluginBridge& bridge,
YaPluginFactory::ConstructArgs&& args)
: YaPluginFactory(std::move(args)), bridge(bridge) {}
Vst3PluginFactoryProxyImpl::Vst3PluginFactoryProxyImpl(
Vst3PluginBridge& bridge,
Vst3PluginFactoryProxy::ConstructArgs&& args)
: Vst3PluginFactoryProxy(std::move(args)), bridge(bridge) {}
tresult PLUGIN_API
YaPluginFactoryImpl::createInstance(Steinberg::FIDString cid,
Steinberg::FIDString _iid,
void** obj) {
Vst3PluginFactoryProxyImpl::queryInterface(const Steinberg::TUID _iid,
void** obj) {
const tresult result = Vst3PluginFactoryProxy::queryInterface(_iid, obj);
bridge.logger.log_query_interface("In IPluginFactory::queryInterface()",
result, Steinberg::FUID::fromTUID(_iid));
return result;
}
tresult PLUGIN_API
Vst3PluginFactoryProxyImpl::createInstance(Steinberg::FIDString cid,
Steinberg::FIDString _iid,
void** obj) {
// Class IDs may be padded with null bytes
constexpr size_t uid_size = sizeof(Steinberg::TUID);
if (!cid || !_iid || !obj || strnlen(_iid, uid_size) < uid_size) {
@@ -94,7 +105,7 @@ YaPluginFactoryImpl::createInstance(Steinberg::FIDString cid,
}
tresult PLUGIN_API
YaPluginFactoryImpl::setHostContext(Steinberg::FUnknown* context) {
Vst3PluginFactoryProxyImpl::setHostContext(Steinberg::FUnknown* context) {
if (context) {
// We will create a proxy object that that supports all the same
// interfaces as `context`, and then we'll store `context` in this
@@ -107,7 +118,7 @@ YaPluginFactoryImpl::setHostContext(Steinberg::FUnknown* context) {
host_application = host_context;
plug_interface_support = host_context;
return bridge.send_message(YaPluginFactory::SetHostContext{
return bridge.send_message(YaPluginFactory3::SetHostContext{
.host_context_args = Vst3HostContextProxy::ConstructArgs(
host_context, std::nullopt)});
} else {
@@ -16,16 +16,23 @@
#pragma once
#include "../../../common/serialization/vst3/plugin-factory.h"
#include "../../../common/serialization/vst3/plugin-factory-proxy.h"
// We need an `IPtr<YaPluginFactoryImpl>` in `Vst3PluginBridge`, so we need to
// declare this slightly differently to avoid circular includes.
// We need an `IPtr<Vst3PluginFactoryProxyImpl>` in `Vst3PluginBridge`, so we
// need to declare this slightly differently to avoid circular includes.
class Vst3PluginBridge;
class YaPluginFactoryImpl : public YaPluginFactory {
class Vst3PluginFactoryProxyImpl : public Vst3PluginFactoryProxy {
public:
YaPluginFactoryImpl(Vst3PluginBridge& bridge,
YaPluginFactory::ConstructArgs&& args);
Vst3PluginFactoryProxyImpl(Vst3PluginBridge& bridge,
Vst3PluginFactoryProxy::ConstructArgs&& args);
/**
* We'll override the query interface to log queries for interfaces we do
* not (yet) support.
*/
tresult PLUGIN_API queryInterface(const Steinberg::TUID _iid,
void** obj) override;
tresult PLUGIN_API createInstance(Steinberg::FIDString cid,
Steinberg::FIDString _iid,