diff --git a/src/common/logging/vst3.cpp b/src/common/logging/vst3.cpp index 299043c2..1fa0a09a 100644 --- a/src/common/logging/vst3.cpp +++ b/src/common/logging/vst3.cpp @@ -38,6 +38,13 @@ void Vst3Logger::log_request(bool is_host_vst, }); } +void Vst3Logger::log_request(bool is_host_vst, + const YaComponent::Terminate& request) { + log_request_base(is_host_vst, [&](auto& message) { + message << "::terminate()"; + }); +} + void Vst3Logger::log_request(bool is_host_vst, const WantsConfiguration&) { log_request_base(is_host_vst, [](auto& message) { message << "Requesting "; diff --git a/src/common/logging/vst3.h b/src/common/logging/vst3.h index f958d0b6..a4dfe316 100644 --- a/src/common/logging/vst3.h +++ b/src/common/logging/vst3.h @@ -49,6 +49,7 @@ class Vst3Logger { void log_request(bool is_host_vst, const YaComponent::Create&); void log_request(bool is_host_vst, const YaComponent::Destroy&); + void log_request(bool is_host_vst, const YaComponent::Terminate&); void log_request(bool is_host_vst, const WantsConfiguration&); void log_request(bool is_host_vst, const WantsPluginFactory&); diff --git a/src/common/serialization/vst3.h b/src/common/serialization/vst3.h index f037a44c..8c34e6fa 100644 --- a/src/common/serialization/vst3.h +++ b/src/common/serialization/vst3.h @@ -68,8 +68,10 @@ struct WantsPluginFactory { * encodes the information we request or the operation we want to perform. A * request of type `ControlRequest(T)` should send back a `T::Response`. */ -using ControlRequest = - std::variant; +using ControlRequest = std::variant; template void serialize(S& s, ControlRequest& payload) { diff --git a/src/common/serialization/vst3/component.h b/src/common/serialization/vst3/component.h index 0c7e7ade..9d6d9923 100644 --- a/src/common/serialization/vst3/component.h +++ b/src/common/serialization/vst3/component.h @@ -79,7 +79,7 @@ class YaComponent : public Steinberg::Vst::IComponent { /** * Message to request the Wine plugin host to instantiate a new IComponent - * to pass through a call to `IPluginFactory::createInstance(cid, + * to pass through a call to `IComponent::createInstance(cid, * IComponent::iid, * ...)`. */ @@ -126,6 +126,22 @@ class YaComponent : public Steinberg::Vst::IComponent { // From `IPluginBase` virtual tresult PLUGIN_API initialize(FUnknown* context) override = 0; + + /** + * Message to pass through a call to `IComponent::terminate()` to the Wine + * plugin host. + */ + struct Terminate { + using Response = UniversalTResult; + + native_size_t instance_id; + + template + void serialize(S& s) { + s.value8b(instance_id); + } + }; + virtual tresult PLUGIN_API terminate() override = 0; // From `IComponent` diff --git a/src/plugin/bridges/vst3-impls/component.cpp b/src/plugin/bridges/vst3-impls/component.cpp index 3b4062fb..3d035a03 100644 --- a/src/plugin/bridges/vst3-impls/component.cpp +++ b/src/plugin/bridges/vst3-impls/component.cpp @@ -40,8 +40,10 @@ tresult PLUGIN_API YaComponentPluginImpl::initialize(FUnknown* context) { } tresult PLUGIN_API YaComponentPluginImpl::terminate() { - // TODO: Implement - return Steinberg::kNotImplemented; + return bridge + .send_message( + YaComponent::Terminate{.instance_id = arguments.instance_id}) + .native(); } tresult PLUGIN_API diff --git a/src/wine-host/bridges/vst3.cpp b/src/wine-host/bridges/vst3.cpp index 01d86b4a..0e321644 100644 --- a/src/wine-host/bridges/vst3.cpp +++ b/src/wine-host/bridges/vst3.cpp @@ -78,6 +78,10 @@ void Vst3Bridge::run() { return Ack{}; }, + [&](const YaComponent::Terminate& request) + -> YaComponent::Terminate::Response { + return component_instances[request.instance_id]->terminate(); + }, [&](const WantsPluginFactory&) -> WantsPluginFactory::Response { return *plugin_factory; }});