Implement IComponent::terminate()

This commit is contained in:
Robbert van der Helm
2020-12-12 16:11:48 +01:00
parent d80ba10f06
commit 68084bc555
6 changed files with 37 additions and 5 deletions
+7
View File
@@ -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 << "<IComponent* #" << request.instance_id << ">::terminate()";
});
}
void Vst3Logger::log_request(bool is_host_vst, const WantsConfiguration&) {
log_request_base(is_host_vst, [](auto& message) {
message << "Requesting <Configuration>";
+1
View File
@@ -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&);
+4 -2
View File
@@ -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<YaComponent::Create, YaComponent::Destroy, WantsPluginFactory>;
using ControlRequest = std::variant<YaComponent::Create,
YaComponent::Destroy,
YaComponent::Terminate,
WantsPluginFactory>;
template <typename S>
void serialize(S& s, ControlRequest& payload) {
+17 -1
View File
@@ -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 <typename S>
void serialize(S& s) {
s.value8b(instance_id);
}
};
virtual tresult PLUGIN_API terminate() override = 0;
// From `IComponent`
+4 -2
View File
@@ -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
+4
View File
@@ -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;
}});