Pass pointers to IMessage objects around

Instead of serializing the actual `YaMessage`, for the reasons mentioned
in the comments. This was needed to stop iZotope VocalSynth 2 in Ardour
from segfaulting when editing parameters, because that plugin is
apparently being very naughty.
This commit is contained in:
Robbert van der Helm
2020-12-28 13:19:34 +01:00
parent 2c3312b452
commit 4226ab6e43
9 changed files with 181 additions and 53 deletions
@@ -55,15 +55,14 @@ Vst3ConnectionPointProxyImpl::disconnect(IConnectionPoint* /*other*/) {
tresult PLUGIN_API
Vst3ConnectionPointProxyImpl::notify(Steinberg::Vst::IMessage* message) {
// As explained in `YaMessage` and `Vst3PluginProxyImpl::notify`, we can
// only support our own `IMessage implementation here`
if (auto message_impl = dynamic_cast<YaMessage*>(message)) {
return bridge.send_message(YaConnectionPoint::Notify{
.instance_id = owner_instance_id(), .message = *message_impl});
if (message) {
return bridge.send_message(
YaConnectionPoint::Notify{.instance_id = owner_instance_id(),
.message_ptr = YaMessagePtr(*message)});
} else {
std::cerr << "WARNING: Unknown message type passed to "
std::cerr << "WARNING: Null pointer passed to "
"'IConnectionPoint::notify()', ignoring"
<< std::endl;
return Steinberg::kNotImplemented;
return Steinberg::kInvalidArgument;
}
}
+13 -13
View File
@@ -223,21 +223,21 @@ void Vst3Bridge::run() {
return result;
}
},
[&](YaConnectionPoint::Notify& request)
[&](const YaConnectionPoint::Notify& request)
-> YaConnectionPoint::Notify::Response {
// FIXME: This needs to be redesigned. We should only send a
// pointer to the `IMessage` instead of copying the
// actual message. What ends up happening is that iZotope
// VocalSynth 2 exchanges pointers to the processor and
// the controller. Then at some point during an
// `IAudioProcessor::process()` call after a parameter
// changes, it will try to access the pointers stored in
// that message. So to be able to support that, the
// message object we pass to notify here still has to be
// alive at that point. This goes 100% against the design
// of VST3, but there's nothing we can do about it.
// NOTE: We're using a few tricks here to pass through a pointer
// to the _original_ `IMessage` object passed to a
// connection proxy. This is needed because some plugins
// like iZotope VocalSynth 2 use these messages to
// exchange pointers between their objects so they can
// break out of VST3's separation, but they might also
// store the message object and not the actual pointers.
// We should thus be passing a (raw) pointer to the
// original object so we can pretend none of this wrapping
// and serializing has ever happened.
return object_instances[request.instance_id]
.connection_point->notify(&request.message);
.connection_point->notify(
request.message_ptr.get_original());
},
[&](YaEditController::SetComponentState& request)
-> YaEditController::SetComponentState::Response {