mirror of
https://github.com/robbert-vdh/yabridge.git
synced 2026-05-10 04:30:12 +02:00
Implement plugin side of IPluginBase::initialize()
This commit is contained in:
@@ -52,6 +52,19 @@ void Vst3Logger::log_request(bool is_host_vst,
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Vst3Logger::log_request(bool is_host_vst,
|
||||||
|
const YaComponent::Initialize& request) {
|
||||||
|
log_request_base(is_host_vst, [&](auto& message) {
|
||||||
|
message << "<IComponent* #" << request.instance_id << ">::initialize(";
|
||||||
|
if (request.host_application_context_args) {
|
||||||
|
message << "IHostApplication*";
|
||||||
|
} else {
|
||||||
|
message << "nullptr";
|
||||||
|
}
|
||||||
|
message << ")";
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
void Vst3Logger::log_request(bool is_host_vst,
|
void Vst3Logger::log_request(bool is_host_vst,
|
||||||
const YaComponent::Terminate& request) {
|
const YaComponent::Terminate& request) {
|
||||||
log_request_base(is_host_vst, [&](auto& message) {
|
log_request_base(is_host_vst, [&](auto& message) {
|
||||||
|
|||||||
@@ -58,6 +58,7 @@ class Vst3Logger {
|
|||||||
|
|
||||||
void log_request(bool is_host_vst, const YaComponent::Construct&);
|
void log_request(bool is_host_vst, const YaComponent::Construct&);
|
||||||
void log_request(bool is_host_vst, const YaComponent::Destruct&);
|
void log_request(bool is_host_vst, const YaComponent::Destruct&);
|
||||||
|
void log_request(bool is_host_vst, const YaComponent::Initialize&);
|
||||||
void log_request(bool is_host_vst, const YaComponent::Terminate&);
|
void log_request(bool is_host_vst, const YaComponent::Terminate&);
|
||||||
void log_request(bool is_host_vst, const YaPluginFactory::Construct&);
|
void log_request(bool is_host_vst, const YaPluginFactory::Construct&);
|
||||||
void log_request(bool is_host_vst, const WantsConfiguration&);
|
void log_request(bool is_host_vst, const WantsConfiguration&);
|
||||||
|
|||||||
@@ -59,6 +59,7 @@ struct WantsConfiguration {
|
|||||||
*/
|
*/
|
||||||
using ControlRequest = std::variant<YaComponent::Construct,
|
using ControlRequest = std::variant<YaComponent::Construct,
|
||||||
YaComponent::Destruct,
|
YaComponent::Destruct,
|
||||||
|
YaComponent::Initialize,
|
||||||
YaComponent::Terminate,
|
YaComponent::Terminate,
|
||||||
YaPluginFactory::Construct>;
|
YaPluginFactory::Construct>;
|
||||||
|
|
||||||
|
|||||||
@@ -27,6 +27,7 @@
|
|||||||
|
|
||||||
#include "../common.h"
|
#include "../common.h"
|
||||||
#include "base.h"
|
#include "base.h"
|
||||||
|
#include "host-application.h"
|
||||||
|
|
||||||
#pragma GCC diagnostic push
|
#pragma GCC diagnostic push
|
||||||
#pragma GCC diagnostic ignored "-Wnon-virtual-dtor"
|
#pragma GCC diagnostic ignored "-Wnon-virtual-dtor"
|
||||||
@@ -125,6 +126,29 @@ class YaComponent : public Steinberg::Vst::IComponent {
|
|||||||
DECLARE_FUNKNOWN_METHODS
|
DECLARE_FUNKNOWN_METHODS
|
||||||
|
|
||||||
// From `IPluginBase`
|
// From `IPluginBase`
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Message to pass through a call to `IPluginBase::initialize()` to the Wine
|
||||||
|
* plugin host. if we pass an `IHostApplication` instance, then a proxy
|
||||||
|
* `YaHostApplication` should be created and passed as an argument to
|
||||||
|
* `IPluginBase::initialize()`. If this is absent a null pointer should be
|
||||||
|
* passed. The lifetime of this `YaHostApplication` object should be bound
|
||||||
|
* to the `IComponent` we are proxying.
|
||||||
|
*/
|
||||||
|
struct Initialize {
|
||||||
|
using Response = UniversalTResult;
|
||||||
|
|
||||||
|
native_size_t instance_id;
|
||||||
|
std::optional<YaHostApplication::ConstructArgs>
|
||||||
|
host_application_context_args;
|
||||||
|
|
||||||
|
template <typename S>
|
||||||
|
void serialize(S& s) {
|
||||||
|
s.value8b(instance_id);
|
||||||
|
s.ext(host_application_context_args, bitsery::ext::StdOptional{});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
virtual tresult PLUGIN_API initialize(FUnknown* context) override = 0;
|
virtual tresult PLUGIN_API initialize(FUnknown* context) override = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ class YaHostApplication : public Steinberg::Vst::IHostApplication {
|
|||||||
void serialize(S& s) {
|
void serialize(S& s) {
|
||||||
s.value8b(component_instance_id);
|
s.value8b(component_instance_id);
|
||||||
s.ext(name, bitsery::ext::StdOptional{},
|
s.ext(name, bitsery::ext::StdOptional{},
|
||||||
[](S& s, std::string& name) {
|
[](S& s, std::u16string& name) {
|
||||||
s.text2b(name, std::extent_v<Steinberg::Vst::String128>);
|
s.text2b(name, std::extent_v<Steinberg::Vst::String128>);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -78,9 +78,9 @@ class YaHostApplication : public Steinberg::Vst::IHostApplication {
|
|||||||
* Instantiate this instance with arguments read from an actual host
|
* Instantiate this instance with arguments read from an actual host
|
||||||
* context.
|
* context.
|
||||||
*
|
*
|
||||||
* @note Since this is passed as part of ``IPluginBase::intialize()` and
|
* @note Since this is passed as part of `IPluginBase::intialize()` and
|
||||||
* `IPluginFactory3::setHostContext()``, there are no direct `Construct`
|
* `IPluginFactory3::setHostContext()`, there are no direct `Construct` or
|
||||||
* or `Destruct` messages. This object's lifetime is bound to that of the
|
* `Destruct` messages. This object's lifetime is bound to that of the
|
||||||
* objects they are passed to. If those objects get dropped, then the host
|
* objects they are passed to. If those objects get dropped, then the host
|
||||||
* contexts should also be dropped.
|
* contexts should also be dropped.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -45,18 +45,24 @@ tresult PLUGIN_API YaComponentPluginImpl::initialize(FUnknown* context) {
|
|||||||
// side. Otherwise we'll still call `IPluginBase::initialize()` but with a
|
// side. Otherwise we'll still call `IPluginBase::initialize()` but with a
|
||||||
// null pointer instead.
|
// null pointer instead.
|
||||||
host_application_context = context;
|
host_application_context = context;
|
||||||
|
|
||||||
|
std::optional<YaHostApplication::ConstructArgs>
|
||||||
|
host_application_context_args = std::nullopt;
|
||||||
if (host_application_context) {
|
if (host_application_context) {
|
||||||
// TODO: Init with `YaHostApplication`
|
host_application_context_args = YaHostApplication::ConstructArgs(
|
||||||
|
host_application_context, arguments.instance_id);
|
||||||
} else {
|
} else {
|
||||||
bridge.logger.log_unknown_interface(
|
bridge.logger.log_unknown_interface(
|
||||||
"In IPluginBase::initialize()",
|
"In IPluginBase::initialize()",
|
||||||
context ? std::optional(context->iid) : std::nullopt);
|
context ? std::optional(context->iid) : std::nullopt);
|
||||||
|
|
||||||
// TODO: Init with null pointer
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Implement
|
return bridge
|
||||||
return Steinberg::kNotImplemented;
|
.send_message(YaComponent::Initialize{
|
||||||
|
.instance_id = arguments.instance_id,
|
||||||
|
.host_application_context_args =
|
||||||
|
std::move(host_application_context_args)})
|
||||||
|
.native();
|
||||||
}
|
}
|
||||||
|
|
||||||
tresult PLUGIN_API YaComponentPluginImpl::terminate() {
|
tresult PLUGIN_API YaComponentPluginImpl::terminate() {
|
||||||
|
|||||||
@@ -72,6 +72,14 @@ void Vst3Bridge::run() {
|
|||||||
|
|
||||||
return Ack{};
|
return Ack{};
|
||||||
},
|
},
|
||||||
|
[&](const YaComponent::Initialize& request)
|
||||||
|
-> YaComponent::Initialize::Response {
|
||||||
|
// TODO: If `request.host_context_args` has a value, we should
|
||||||
|
// initialize a proxy object and pass a pointer to that
|
||||||
|
// instead
|
||||||
|
return component_instances[request.instance_id]->initialize(
|
||||||
|
nullptr);
|
||||||
|
},
|
||||||
[&](const YaComponent::Terminate& request)
|
[&](const YaComponent::Terminate& request)
|
||||||
-> YaComponent::Terminate::Response {
|
-> YaComponent::Terminate::Response {
|
||||||
return component_instances[request.instance_id]->terminate();
|
return component_instances[request.instance_id]->terminate();
|
||||||
|
|||||||
Reference in New Issue
Block a user