mirror of
https://github.com/robbert-vdh/yabridge.git
synced 2026-05-07 03:50:11 +02:00
Implement IEditController::setComponentHandler()
This commit is contained in:
@@ -391,6 +391,21 @@ bool Vst3Logger::log_request(
|
||||
});
|
||||
}
|
||||
|
||||
bool Vst3Logger::log_request(
|
||||
bool is_host_vst,
|
||||
const YaEditController::SetComponentHandler& request) {
|
||||
return log_request_base(is_host_vst, [&](auto& message) {
|
||||
message << request.instance_id
|
||||
<< ": IEditController::setComponentHandler(handler = ";
|
||||
if (request.component_handler_proxy_args) {
|
||||
message << "<IComponentHandler*>";
|
||||
} else {
|
||||
message << "<nullptr>";
|
||||
}
|
||||
message << ")";
|
||||
});
|
||||
}
|
||||
|
||||
bool Vst3Logger::log_request(bool is_host_vst,
|
||||
const YaPluginBase::Initialize& request) {
|
||||
return log_request_base(is_host_vst, [&](auto& message) {
|
||||
|
||||
@@ -102,6 +102,8 @@ class Vst3Logger {
|
||||
const YaEditController::GetParamNormalized&);
|
||||
bool log_request(bool is_host_vst,
|
||||
const YaEditController::SetParamNormalized&);
|
||||
bool log_request(bool is_host_vst,
|
||||
const YaEditController::SetComponentHandler&);
|
||||
bool log_request(bool is_host_vst, const YaPluginBase::Initialize&);
|
||||
bool log_request(bool is_host_vst, const YaPluginBase::Terminate&);
|
||||
bool log_request(bool is_host_vst, const YaPluginFactory::Construct&);
|
||||
|
||||
@@ -87,6 +87,7 @@ using ControlRequest = std::variant<Vst3PluginProxy::Construct,
|
||||
YaEditController::PlainParamToNormalized,
|
||||
YaEditController::GetParamNormalized,
|
||||
YaEditController::SetParamNormalized,
|
||||
YaEditController::SetComponentHandler,
|
||||
YaPluginBase::Initialize,
|
||||
YaPluginBase::Terminate,
|
||||
YaPluginFactory::Construct,
|
||||
|
||||
@@ -16,10 +16,12 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <bitsery/ext/std_optional.h>
|
||||
#include <pluginterfaces/vst/ivsteditcontroller.h>
|
||||
|
||||
#include "../../common.h"
|
||||
#include "../base.h"
|
||||
#include "../component-handler-proxy.h"
|
||||
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wnon-virtual-dtor"
|
||||
@@ -328,6 +330,35 @@ class YaEditController : public Steinberg::Vst::IEditController {
|
||||
virtual tresult PLUGIN_API
|
||||
setParamNormalized(Steinberg::Vst::ParamID id,
|
||||
Steinberg::Vst::ParamValue value) override = 0;
|
||||
|
||||
/**
|
||||
* Message to pass through a call to
|
||||
* `IEditController::setComponentHandler(handler)` to the Wine plugin host.
|
||||
* Like when creating a proxy for a plugin object, we'll read all supported
|
||||
* interfaces form the component handler instance passed by the host. We'll
|
||||
* then create a perfect proxy on the plugin side, that can do callbacks to
|
||||
* the actual component handler passed by the host.
|
||||
*/
|
||||
struct SetComponentHandler {
|
||||
using Response = UniversalTResult;
|
||||
|
||||
native_size_t instance_id;
|
||||
|
||||
/**
|
||||
* Arguments for instantiating the proxy object. Even though it should
|
||||
* never happen, if the host passed a null pointer to this function
|
||||
* we'll mimic that as well.
|
||||
*/
|
||||
std::optional<Vst3ComponentHandlerProxy::ConstructArgs>
|
||||
component_handler_proxy_args;
|
||||
|
||||
template <typename S>
|
||||
void serialize(S& s) {
|
||||
s.value8b(instance_id);
|
||||
s.ext(component_handler_proxy_args, bitsery::ext::StdOptional{});
|
||||
}
|
||||
};
|
||||
|
||||
virtual tresult PLUGIN_API setComponentHandler(
|
||||
Steinberg::Vst::IComponentHandler* handler) override = 0;
|
||||
virtual Steinberg::IPlugView* PLUGIN_API
|
||||
|
||||
@@ -315,9 +315,24 @@ Vst3PluginProxyImpl::setParamNormalized(Steinberg::Vst::ParamID id,
|
||||
|
||||
tresult PLUGIN_API Vst3PluginProxyImpl::setComponentHandler(
|
||||
Steinberg::Vst::IComponentHandler* handler) {
|
||||
// TODO: Implement
|
||||
bridge.logger.log("TODO IEditController::setComponentHandler()");
|
||||
return Steinberg::kNotImplemented;
|
||||
std::optional<Vst3ComponentHandlerProxy::ConstructArgs>
|
||||
component_handler_proxy_args = std::nullopt;
|
||||
if (handler) {
|
||||
// We'll store the pointer for when the plugin later makes a callback to
|
||||
// this component handler
|
||||
component_handler = handler;
|
||||
|
||||
component_handler_proxy_args = Vst3ComponentHandlerProxy::ConstructArgs(
|
||||
host_application_context, instance_id());
|
||||
} else {
|
||||
bridge.logger.log(
|
||||
"Null pointer passed to 'IEditController::setComponentHandler'");
|
||||
}
|
||||
|
||||
return bridge.send_message(YaEditController::SetComponentHandler{
|
||||
.instance_id = instance_id(),
|
||||
.component_handler_proxy_args =
|
||||
std::move(component_handler_proxy_args)});
|
||||
}
|
||||
|
||||
Steinberg::IPlugView* PLUGIN_API
|
||||
|
||||
@@ -133,4 +133,12 @@ class Vst3PluginProxyImpl : public Vst3PluginProxy {
|
||||
*/
|
||||
Steinberg::FUnknownPtr<Steinberg::Vst::IHostApplication>
|
||||
host_application_context;
|
||||
|
||||
/**
|
||||
* The component handler the host passed to us during
|
||||
* `IEditController::setComponentHandler()`. When the plugin makes a
|
||||
* callback on a component handler proxy object, we'll pass the call through
|
||||
* to this object.
|
||||
*/
|
||||
Steinberg::IPtr<Steinberg::Vst::IComponentHandler> component_handler;
|
||||
};
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#include <boost/asio/dispatch.hpp>
|
||||
#include <public.sdk/source/vst/hosting/module_win32.cpp>
|
||||
|
||||
#include "vst3-impls/component-handler-proxy.h"
|
||||
#include "vst3-impls/host-application.h"
|
||||
|
||||
InstanceInterfaces::InstanceInterfaces() {}
|
||||
@@ -336,28 +337,55 @@ void Vst3Bridge::run() {
|
||||
.edit_controller->setParamNormalized(request.id,
|
||||
request.value);
|
||||
},
|
||||
[&](YaEditController::SetComponentHandler& request)
|
||||
-> YaEditController::SetComponentHandler::Response {
|
||||
// If we got passed a component handler, we'll create a proxy
|
||||
// object and pass that to the initialize function. The lifetime
|
||||
// of this object is tied to that of the actual plugin object
|
||||
// we're proxying for.
|
||||
// TODO: Does this have to be run from the UI thread? Figure out
|
||||
// if it does
|
||||
if (request.component_handler_proxy_args) {
|
||||
object_instances[request.instance_id]
|
||||
.component_handler_proxy =
|
||||
Steinberg::owned(new Vst3ComponentHandlerProxyImpl(
|
||||
*this,
|
||||
std::move(*request.component_handler_proxy_args)));
|
||||
} else {
|
||||
object_instances[request.instance_id]
|
||||
.component_handler_proxy = nullptr;
|
||||
}
|
||||
|
||||
return object_instances[request.instance_id]
|
||||
.edit_controller->setComponentHandler(
|
||||
object_instances[request.instance_id]
|
||||
.component_handler_proxy);
|
||||
},
|
||||
[&](YaPluginBase::Initialize& request)
|
||||
-> YaPluginBase::Initialize::Response {
|
||||
// If we got passed a host context, we'll create a proxy object
|
||||
// and pass that to the initialize function. This object should
|
||||
// be cleaned up again during `Vst3PluginProxy::Destruct`.
|
||||
// and pass that to the initialize function. The lifetime of
|
||||
// this object is tied to that of the actual plugin object we're
|
||||
// proxying for.
|
||||
// TODO: This needs changing if it turns out we need a
|
||||
// `Vst3HostProxy`
|
||||
// TODO: Does this have to be run from the UI thread? Figure out
|
||||
// if it does
|
||||
Steinberg::FUnknown* context = nullptr;
|
||||
if (request.host_application_context_args) {
|
||||
object_instances[request.instance_id]
|
||||
.hsot_application_context =
|
||||
.host_application_context =
|
||||
Steinberg::owned(new YaHostApplicationImpl(
|
||||
*this,
|
||||
std::move(*request.host_application_context_args)));
|
||||
context = object_instances[request.instance_id]
|
||||
.hsot_application_context;
|
||||
} else {
|
||||
object_instances[request.instance_id]
|
||||
.host_application_context = nullptr;
|
||||
}
|
||||
|
||||
return object_instances[request.instance_id]
|
||||
.plugin_base->initialize(context);
|
||||
.plugin_base->initialize(
|
||||
object_instances[request.instance_id]
|
||||
.host_application_context);
|
||||
},
|
||||
[&](const YaPluginBase::Terminate& request)
|
||||
-> YaPluginBase::Terminate::Response {
|
||||
|
||||
@@ -40,9 +40,19 @@ struct InstanceInterfaces {
|
||||
/**
|
||||
* If the host passes an `IHostApplication` during
|
||||
* `IPluginBase::initialize()`, we'll store a proxy object here and then
|
||||
* pass it to `plugin_base->initialize()`.
|
||||
* pass it to `plugin_base->initialize()`. Will be initialized with a null
|
||||
* pointer until used.
|
||||
*/
|
||||
Steinberg::IPtr<YaHostApplication> hsot_application_context;
|
||||
Steinberg::IPtr<YaHostApplication> host_application_context;
|
||||
|
||||
/**
|
||||
* After a call to `IEditController::setComponentHandler()`, we'll create a
|
||||
* proxy of that component handler just like we did for the plugin object.
|
||||
* When the plugin calls a function on this object, we make a callback to
|
||||
* the original object provided by the host. Will be initialized with a null
|
||||
* pointer until used.
|
||||
*/
|
||||
Steinberg::IPtr<Vst3ComponentHandlerProxy> component_handler_proxy;
|
||||
|
||||
/**
|
||||
* The base object we cast from.
|
||||
|
||||
Reference in New Issue
Block a user