mirror of
https://github.com/robbert-vdh/yabridge.git
synced 2026-05-10 04:30:12 +02:00
Remove null pointer supported in initialize()
This commit is contained in:
@@ -322,13 +322,7 @@ bool Vst3Logger::log_request(bool is_host_vst,
|
|||||||
const YaPluginBase::Initialize& request) {
|
const YaPluginBase::Initialize& request) {
|
||||||
return log_request_base(is_host_vst, [&](auto& message) {
|
return log_request_base(is_host_vst, [&](auto& message) {
|
||||||
message << request.instance_id
|
message << request.instance_id
|
||||||
<< ": IPluginBase::initialize(context = ";
|
<< ": IPluginBase::initialize(context = <FUnknown*>)";
|
||||||
if (request.host_context_args) {
|
|
||||||
message << "<FUnknown*>";
|
|
||||||
} else {
|
|
||||||
message << "<nullptr>";
|
|
||||||
}
|
|
||||||
message << ")";
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,6 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <bitsery/ext/std_optional.h>
|
|
||||||
#include <pluginterfaces/base/ipluginbase.h>
|
#include <pluginterfaces/base/ipluginbase.h>
|
||||||
|
|
||||||
#include "../../common.h"
|
#include "../../common.h"
|
||||||
@@ -77,12 +76,12 @@ class YaPluginBase : public Steinberg::IPluginBase {
|
|||||||
|
|
||||||
native_size_t instance_id;
|
native_size_t instance_id;
|
||||||
|
|
||||||
std::optional<Vst3HostContextProxy::ConstructArgs> host_context_args;
|
Vst3HostContextProxy::ConstructArgs host_context_args;
|
||||||
|
|
||||||
template <typename S>
|
template <typename S>
|
||||||
void serialize(S& s) {
|
void serialize(S& s) {
|
||||||
s.value8b(instance_id);
|
s.value8b(instance_id);
|
||||||
s.ext(host_context_args, bitsery::ext::StdOptional{});
|
s.object(host_context_args);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -394,23 +394,21 @@ tresult PLUGIN_API Vst3PluginProxyImpl::openAboutBox(TBool onlyCheck) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
tresult PLUGIN_API Vst3PluginProxyImpl::initialize(FUnknown* context) {
|
tresult PLUGIN_API Vst3PluginProxyImpl::initialize(FUnknown* context) {
|
||||||
// We will create a proxy object that that supports all the same interfaces
|
if (context) {
|
||||||
// as `context`, and then we'll store `context` in this object. We can then
|
// We will create a proxy object that that supports all the same
|
||||||
// use it to handle callbacks made by the Windows VST3 plugin to this
|
// interfaces as `context`, and then we'll store `context` in this
|
||||||
// context.
|
// object. We can then use it to handle callbacks made by the Windows
|
||||||
host_context = context;
|
// VST3 plugin to this context.
|
||||||
|
host_context = context;
|
||||||
|
|
||||||
std::optional<Vst3HostContextProxy::ConstructArgs> host_context_args{};
|
return bridge.send_message(YaPluginBase::Initialize{
|
||||||
if (host_context) {
|
.instance_id = instance_id(),
|
||||||
host_context_args =
|
.host_context_args = Vst3HostContextProxy::ConstructArgs(
|
||||||
Vst3HostContextProxy::ConstructArgs(host_context, instance_id());
|
host_context, instance_id())});
|
||||||
} else {
|
} else {
|
||||||
bridge.logger.log("Null pointer passed to 'IPluginBase::initialize()'");
|
bridge.logger.log("Null pointer passed to 'IPluginBase::initialize()'");
|
||||||
|
return Steinberg::kInvalidArgument;
|
||||||
}
|
}
|
||||||
|
|
||||||
return bridge.send_message(YaPluginBase::Initialize{
|
|
||||||
.instance_id = instance_id(),
|
|
||||||
.host_context_args = std::move(host_context_args)});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
tresult PLUGIN_API Vst3PluginProxyImpl::terminate() {
|
tresult PLUGIN_API Vst3PluginProxyImpl::terminate() {
|
||||||
|
|||||||
@@ -405,22 +405,15 @@ void Vst3Bridge::run() {
|
|||||||
},
|
},
|
||||||
[&](YaPluginBase::Initialize& request)
|
[&](YaPluginBase::Initialize& request)
|
||||||
-> YaPluginBase::Initialize::Response {
|
-> YaPluginBase::Initialize::Response {
|
||||||
// If we got passed a host context, we'll create a proxy object
|
// We'll create a proxy object for the host context passed by
|
||||||
// and pass that to the initialize function. The lifetime of
|
// the host and pass that to the initialize function. The
|
||||||
// this object is tied to that of the actual plugin object we're
|
// lifetime of this object is tied to that of the actual plugin
|
||||||
// proxying for.
|
// object we're proxying for.
|
||||||
// TODO: This needs changing if it turns out we need a
|
// TODO: This needs changing if it turns out we need a
|
||||||
// `Vst3HostProxy`
|
// `Vst3HostProxy`
|
||||||
// TODO: Does this have to be run from the UI thread? Figure out
|
object_instances[request.instance_id].host_context_proxy =
|
||||||
// if it does
|
Steinberg::owned(new Vst3HostContextProxyImpl(
|
||||||
if (request.host_context_args) {
|
*this, std::move(request.host_context_args)));
|
||||||
object_instances[request.instance_id].host_context_proxy =
|
|
||||||
Steinberg::owned(new Vst3HostContextProxyImpl(
|
|
||||||
*this, std::move(*request.host_context_args)));
|
|
||||||
} else {
|
|
||||||
object_instances[request.instance_id].host_context_proxy =
|
|
||||||
nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
// XXX: Should `IPlugView::{initialize,terminate}` be run from
|
// XXX: Should `IPlugView::{initialize,terminate}` be run from
|
||||||
// the main UI thread? I can see how plugins would want to
|
// the main UI thread? I can see how plugins would want to
|
||||||
|
|||||||
Reference in New Issue
Block a user