mirror of
https://github.com/robbert-vdh/yabridge.git
synced 2026-05-10 04:30:12 +02:00
Implement YaComponentPluginImpl destructor
When the object gets dropped through the reference counting system, the object should also be dropped in the Wine plugin host.
This commit is contained in:
@@ -30,6 +30,14 @@ void Vst3Logger::log_request(bool is_host_vst, const YaComponent::Create&) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Vst3Logger::log_request(bool is_host_vst,
|
||||||
|
const YaComponent::Destroy& request) {
|
||||||
|
log_request_base(is_host_vst, [&](auto& message) {
|
||||||
|
message << "<IPluginFactory* #" << request.instance_id
|
||||||
|
<< ">::~IPluginFactory()";
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
void Vst3Logger::log_request(bool is_host_vst, const WantsConfiguration&) {
|
void Vst3Logger::log_request(bool is_host_vst, const WantsConfiguration&) {
|
||||||
log_request_base(is_host_vst, [](auto& message) {
|
log_request_base(is_host_vst, [](auto& message) {
|
||||||
message << "Requesting <Configuration>";
|
message << "Requesting <Configuration>";
|
||||||
@@ -42,6 +50,10 @@ void Vst3Logger::log_request(bool is_host_vst, const WantsPluginFactory&) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Vst3Logger::log_response(bool is_host_vst, const Ack&) {
|
||||||
|
log_response_base(is_host_vst, [&](auto& message) { message << "ACK"; });
|
||||||
|
}
|
||||||
|
|
||||||
void Vst3Logger::log_response(
|
void Vst3Logger::log_response(
|
||||||
bool is_host_vst,
|
bool is_host_vst,
|
||||||
const std::optional<YaComponent::CreateArgs>& args) {
|
const std::optional<YaComponent::CreateArgs>& args) {
|
||||||
|
|||||||
@@ -48,9 +48,11 @@ class Vst3Logger {
|
|||||||
// (what we'll call a control message).
|
// (what we'll call a control message).
|
||||||
|
|
||||||
void log_request(bool is_host_vst, const YaComponent::Create&);
|
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 WantsConfiguration&);
|
void log_request(bool is_host_vst, const WantsConfiguration&);
|
||||||
void log_request(bool is_host_vst, const WantsPluginFactory&);
|
void log_request(bool is_host_vst, const WantsPluginFactory&);
|
||||||
|
|
||||||
|
void log_response(bool is_host_vst, const Ack&);
|
||||||
void log_response(bool is_host_vst,
|
void log_response(bool is_host_vst,
|
||||||
const std::optional<YaComponent::CreateArgs>&);
|
const std::optional<YaComponent::CreateArgs>&);
|
||||||
void log_response(bool is_host_vst, const Configuration&);
|
void log_response(bool is_host_vst, const Configuration&);
|
||||||
|
|||||||
@@ -68,7 +68,8 @@ struct WantsPluginFactory {
|
|||||||
* encodes the information we request or the operation we want to perform. A
|
* encodes the information we request or the operation we want to perform. A
|
||||||
* request of type `ControlRequest(T)` should send back a `T::Response`.
|
* request of type `ControlRequest(T)` should send back a `T::Response`.
|
||||||
*/
|
*/
|
||||||
using ControlRequest = std::variant<YaComponent::Create, WantsPluginFactory>;
|
using ControlRequest =
|
||||||
|
std::variant<YaComponent::Create, YaComponent::Destroy, WantsPluginFactory>;
|
||||||
|
|
||||||
template <typename S>
|
template <typename S>
|
||||||
void serialize(S& s, ControlRequest& payload) {
|
void serialize(S& s, ControlRequest& payload) {
|
||||||
|
|||||||
@@ -34,3 +34,12 @@ using Steinberg::TBool, Steinberg::int8, Steinberg::int32, Steinberg::tresult;
|
|||||||
using ArrayUID = std::array<
|
using ArrayUID = std::array<
|
||||||
std::remove_reference_t<decltype(std::declval<Steinberg::TUID>()[0])>,
|
std::remove_reference_t<decltype(std::declval<Steinberg::TUID>()[0])>,
|
||||||
std::extent_v<Steinberg::TUID>>;
|
std::extent_v<Steinberg::TUID>>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Empty struct for when we have send a response to some operation without any
|
||||||
|
* result values.
|
||||||
|
*/
|
||||||
|
struct Ack {
|
||||||
|
template <typename S>
|
||||||
|
void serialize(S&) {}
|
||||||
|
};
|
||||||
|
|||||||
@@ -93,6 +93,22 @@ class YaComponent : public Steinberg::Vst::IComponent {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Message to request the Wine plugin host to destroy the IComponent
|
||||||
|
* instance with the given instance ID. Sent from the destructor of
|
||||||
|
* `YaComponentPluginImpl`.
|
||||||
|
*/
|
||||||
|
struct Destroy {
|
||||||
|
using Response = Ack;
|
||||||
|
|
||||||
|
native_size_t instance_id;
|
||||||
|
|
||||||
|
template <typename S>
|
||||||
|
void serialize(S& s) {
|
||||||
|
s.value8b(instance_id);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Instantiate this instance with arguments read from another interface
|
* Instantiate this instance with arguments read from another interface
|
||||||
* implementation.
|
* implementation.
|
||||||
@@ -136,11 +152,8 @@ class YaComponent : public Steinberg::Vst::IComponent {
|
|||||||
virtual tresult PLUGIN_API
|
virtual tresult PLUGIN_API
|
||||||
getState(Steinberg::IBStream* state) override = 0;
|
getState(Steinberg::IBStream* state) override = 0;
|
||||||
|
|
||||||
private:
|
protected:
|
||||||
CreateArgs arguments;
|
CreateArgs arguments;
|
||||||
|
|
||||||
// TODO: As explained in a few other places, `YaComponent` objects should be
|
|
||||||
// assigned a unique ID for identification
|
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename S>
|
template <typename S>
|
||||||
|
|||||||
@@ -21,7 +21,8 @@ YaComponentPluginImpl::YaComponentPluginImpl(Vst3PluginBridge& bridge,
|
|||||||
: YaComponent(std::move(args)), bridge(bridge) {}
|
: YaComponent(std::move(args)), bridge(bridge) {}
|
||||||
|
|
||||||
YaComponentPluginImpl::~YaComponentPluginImpl() {
|
YaComponentPluginImpl::~YaComponentPluginImpl() {
|
||||||
// TODO: Send a control message to destroy the instance on the Wine side
|
bridge.send_message(
|
||||||
|
YaComponent::Destroy{.instance_id = arguments.instance_id});
|
||||||
}
|
}
|
||||||
|
|
||||||
tresult PLUGIN_API
|
tresult PLUGIN_API
|
||||||
|
|||||||
@@ -70,6 +70,13 @@ void Vst3Bridge::run() {
|
|||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
[&](const YaComponent::Destroy& request)
|
||||||
|
-> YaComponent::Destroy::Response {
|
||||||
|
std::lock_guard lock(component_instances_mutex);
|
||||||
|
component_instances.erase(request.instance_id);
|
||||||
|
|
||||||
|
return Ack{};
|
||||||
|
},
|
||||||
[&](const WantsPluginFactory&) -> WantsPluginFactory::Response {
|
[&](const WantsPluginFactory&) -> WantsPluginFactory::Response {
|
||||||
return *plugin_factory;
|
return *plugin_factory;
|
||||||
}});
|
}});
|
||||||
|
|||||||
Reference in New Issue
Block a user