Split IPluginBase from IComponent

We're also going to need this for `IEditController`. Separating all of
these classes will also keep everything much more maintainable with all
of these associated structs.
This commit is contained in:
Robbert van der Helm
2020-12-16 23:46:47 +01:00
parent 97570a47ba
commit 6809e73d6b
14 changed files with 257 additions and 150 deletions
+29 -29
View File
@@ -40,35 +40,6 @@ YaComponentPluginImpl::queryInterface(const Steinberg::TUID _iid, void** obj) {
return result;
}
tresult PLUGIN_API YaComponentPluginImpl::initialize(FUnknown* context) {
// This `context` will likely be an `IHostApplication`. If it is, we will
// store it here, and we'll proxy through all calls to it made from the Wine
// side. Otherwise we'll still call `IPluginBase::initialize()` but with a
// null pointer instead.
host_application_context = context;
std::optional<YaHostApplication::ConstructArgs>
host_application_context_args = std::nullopt;
if (host_application_context) {
host_application_context_args = YaHostApplication::ConstructArgs(
host_application_context, arguments.instance_id);
} else {
bridge.logger.log_unknown_interface(
"In IPluginBase::initialize()",
context ? std::optional(context->iid) : std::nullopt);
}
return bridge.send_message(
YaComponent::Initialize{.instance_id = arguments.instance_id,
.host_application_context_args =
std::move(host_application_context_args)});
}
tresult PLUGIN_API YaComponentPluginImpl::terminate() {
return bridge.send_message(
YaComponent::Terminate{.instance_id = arguments.instance_id});
}
tresult PLUGIN_API
YaComponentPluginImpl::setIoMode(Steinberg::Vst::IoMode mode) {
return bridge.send_message(YaComponent::SetIoMode{
@@ -143,6 +114,35 @@ tresult PLUGIN_API YaComponentPluginImpl::getState(Steinberg::IBStream* state) {
return response.result;
}
tresult PLUGIN_API YaComponentPluginImpl::initialize(FUnknown* context) {
// This `context` will likely be an `IHostApplication`. If it is, we will
// store it here, and we'll proxy through all calls to it made from the Wine
// side. Otherwise we'll still call `IPluginBase::initialize()` but with a
// null pointer instead.
host_application_context = context;
std::optional<YaHostApplication::ConstructArgs>
host_application_context_args = std::nullopt;
if (host_application_context) {
host_application_context_args = YaHostApplication::ConstructArgs(
host_application_context, arguments.instance_id);
} else {
bridge.logger.log_unknown_interface(
"In IPluginBase::initialize()",
context ? std::optional(context->iid) : std::nullopt);
}
return bridge.send_message(
YaPluginBase::Initialize{.instance_id = arguments.instance_id,
.host_application_context_args =
std::move(host_application_context_args)});
}
tresult PLUGIN_API YaComponentPluginImpl::terminate() {
return bridge.send_message(
YaPluginBase::Terminate{.instance_id = arguments.instance_id});
}
tresult PLUGIN_API YaComponentPluginImpl::setBusArrangements(
Steinberg::Vst::SpeakerArrangement* inputs,
int32 numIns,
+5 -3
View File
@@ -39,9 +39,7 @@ class YaComponentPluginImpl : public YaComponent {
tresult PLUGIN_API queryInterface(const Steinberg::TUID _iid,
void** obj) override;
tresult PLUGIN_API initialize(FUnknown* context) override;
tresult PLUGIN_API terminate() override;
// From `IComponent`
tresult PLUGIN_API setIoMode(Steinberg::Vst::IoMode mode) override;
int32 PLUGIN_API getBusCount(Steinberg::Vst::MediaType type,
Steinberg::Vst::BusDirection dir) override;
@@ -61,6 +59,10 @@ class YaComponentPluginImpl : public YaComponent {
tresult PLUGIN_API setState(Steinberg::IBStream* state) override;
tresult PLUGIN_API getState(Steinberg::IBStream* state) override;
// From `IPluginBase`
tresult PLUGIN_API initialize(FUnknown* context) override;
tresult PLUGIN_API terminate() override;
tresult PLUGIN_API
setBusArrangements(Steinberg::Vst::SpeakerArrangement* inputs,
int32 numIns,