mirror of
https://github.com/robbert-vdh/yabridge.git
synced 2026-05-08 04:20:13 +02:00
Rename register_component to register_plugin_proxy
This commit is contained in:
@@ -34,7 +34,7 @@
|
||||
class YaPluginFactory : public Steinberg::IPluginFactory3 {
|
||||
public:
|
||||
/**
|
||||
* These are the arguments for creating a `YaPluginFactoryPluginImpl`.
|
||||
* These are the arguments for creating a `YaPluginFactoryImpl`.
|
||||
*/
|
||||
struct ConstructArgs {
|
||||
ConstructArgs();
|
||||
@@ -125,9 +125,9 @@ class YaPluginFactory : public Steinberg::IPluginFactory3 {
|
||||
YaPluginFactory(const ConstructArgs&& args);
|
||||
|
||||
/**
|
||||
* We do not need to implement the destructor in
|
||||
* `YaPluginFactoryPluginImpl`, since when the sockets are closed, RAII will
|
||||
* clean up the Windows VST3 module we loaded along with its factory for us.
|
||||
* We do not need to implement the destructor in `YaPluginFactoryImpl`,
|
||||
* since when the sockets are closed, RAII will clean up the Windows VST3
|
||||
* module we loaded along with its factory for us.
|
||||
*/
|
||||
virtual ~YaPluginFactory();
|
||||
|
||||
@@ -139,8 +139,7 @@ class YaPluginFactory : public Steinberg::IPluginFactory3 {
|
||||
tresult PLUGIN_API getClassInfo(Steinberg::int32 index,
|
||||
Steinberg::PClassInfo* info) override;
|
||||
/**
|
||||
* See the implementation in `YaPluginFactoryPluginImpl` for how this is
|
||||
* handled.
|
||||
* See the implementation in `YaPluginFactoryImpl` for how this is handled.
|
||||
*/
|
||||
virtual tresult PLUGIN_API createInstance(Steinberg::FIDString cid,
|
||||
Steinberg::FIDString _iid,
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
YaPluginProxyImplYaPluginProxyImplYaPluginProxyImpl
|
||||
@@ -19,13 +19,13 @@
|
||||
Vst3PluginProxyImpl::Vst3PluginProxyImpl(Vst3PluginBridge& bridge,
|
||||
Vst3PluginProxy::ConstructArgs&& args)
|
||||
: Vst3PluginProxy(std::move(args)), bridge(bridge) {
|
||||
bridge.register_component(arguments.instance_id, *this);
|
||||
bridge.register_plugin_proxy(*this);
|
||||
}
|
||||
|
||||
Vst3PluginProxyImpl::~Vst3PluginProxyImpl() {
|
||||
bridge.send_message(
|
||||
Vst3PluginProxy::Destruct{.instance_id = arguments.instance_id});
|
||||
bridge.unregister_component(arguments.instance_id);
|
||||
bridge.unregister_plugin_proxy(arguments.instance_id);
|
||||
}
|
||||
|
||||
tresult PLUGIN_API
|
||||
|
||||
@@ -39,6 +39,8 @@ class Vst3PluginProxyImpl : public Vst3PluginProxy {
|
||||
tresult PLUGIN_API queryInterface(const Steinberg::TUID _iid,
|
||||
void** obj) override;
|
||||
|
||||
inline size_t instance_id() { return arguments.instance_id; }
|
||||
|
||||
// From `IAudioProcessor`
|
||||
tresult PLUGIN_API
|
||||
setBusArrangements(Steinberg::Vst::SpeakerArrangement* inputs,
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
#include "src/common/serialization/vst3.h"
|
||||
#include "vst3-impls/plugin-factory.h"
|
||||
#include "vst3-impls/plugin-proxy.h"
|
||||
|
||||
// There are still some design decisions that need some more thought
|
||||
// TODO: Check whether `IPlugView::isPlatformTypeSupported` needs special
|
||||
@@ -114,14 +115,13 @@ Steinberg::IPluginFactory* Vst3PluginBridge::get_plugin_factory() {
|
||||
return plugin_factory;
|
||||
}
|
||||
|
||||
void Vst3PluginBridge::register_component(size_t instance_id,
|
||||
Vst3PluginProxyImpl& component) {
|
||||
std::lock_guard lock(component_instances_mutex);
|
||||
component_instances.emplace(instance_id,
|
||||
std::ref<Vst3PluginProxyImpl>(component));
|
||||
void Vst3PluginBridge::register_plugin_proxy(Vst3PluginProxyImpl& component) {
|
||||
std::lock_guard lock(plugin_proxies_mutex);
|
||||
plugin_proxies.emplace(component.instance_id(),
|
||||
std::ref<Vst3PluginProxyImpl>(component));
|
||||
}
|
||||
|
||||
void Vst3PluginBridge::unregister_component(size_t instance_id) {
|
||||
std::lock_guard lock(component_instances_mutex);
|
||||
component_instances.erase(instance_id);
|
||||
void Vst3PluginBridge::unregister_plugin_proxy(size_t instance_id) {
|
||||
std::lock_guard lock(plugin_proxies_mutex);
|
||||
plugin_proxies.erase(instance_id);
|
||||
}
|
||||
|
||||
+20
-24
@@ -73,34 +73,32 @@ class Vst3PluginBridge : PluginBridge<Vst3Sockets<std::jthread>> {
|
||||
Steinberg::IPluginFactory* get_plugin_factory();
|
||||
|
||||
/**
|
||||
* Add a `YaComponentPluginImpl` to the list of registered components so we
|
||||
* can handle host callbacks, called during its constructor.
|
||||
* Add a `Vst3PluginProxyImpl` to the list of registered proxy objects so we
|
||||
* can handle host callbacks. This function is called in
|
||||
* `Vst3PluginProxyImpl`'s constructor.
|
||||
*
|
||||
* @param instance_id The instance ID generated by the plugin host when
|
||||
* instantiating the `IComponent`. Used as a stable name to refer to
|
||||
* these.
|
||||
* @param component The actual component instance so we can use its host
|
||||
* @param plugin_proxy The actual proxy object we can access its host
|
||||
* context.
|
||||
*
|
||||
* @see component_instances
|
||||
*
|
||||
* TODO: REname to `register_instance` or `register_object`
|
||||
* @see plugin_proxies
|
||||
*/
|
||||
void register_component(size_t instance_id, Vst3PluginProxyImpl& component);
|
||||
void register_plugin_proxy(Vst3PluginProxyImpl& proxy_object);
|
||||
|
||||
/**
|
||||
* Remove a previously registered `YaComponentPluginImpl` from the list of
|
||||
* registered components so we can handle host callbacks, called during its
|
||||
* destructor after asking the Wine plugin host to destroy the component on
|
||||
* its side..
|
||||
* Remove a previously registered `Vst3PluginProxyImpl` from the list of
|
||||
* registered proxy objects. Called during the object's destructor after
|
||||
* asking the Wine plugin host to destroy the component on its side.
|
||||
*
|
||||
* @param instance_id The instance ID generated by the plugin host when
|
||||
* instantiating the `IComponent`. Used as a stable name to refer to
|
||||
* these.
|
||||
*
|
||||
* @see component_instances
|
||||
* @see plugin_proxies
|
||||
*/
|
||||
void unregister_component(size_t instance_id);
|
||||
void unregister_plugin_proxy(size_t instance_id);
|
||||
|
||||
/**
|
||||
* Send a control message to the Wine plugin host return the response. This
|
||||
@@ -140,17 +138,15 @@ class Vst3PluginBridge : PluginBridge<Vst3Sockets<std::jthread>> {
|
||||
|
||||
private:
|
||||
/**
|
||||
* All `IComponent` instances we created from this plugin. We only need to
|
||||
* keep track of them in case the 'real' `IComponent` instance tries to do a
|
||||
* callback through the host context. We store the copy of the host context
|
||||
* passed during `initialize()` in the `YaComponentPluginImpl`. The IDs here
|
||||
* are the same IDs as generated by the Wine plugin host. We store raw
|
||||
* pointers instead of smart pointers because this shouldn't affect the
|
||||
* reference counting. An instance is added here through a call by
|
||||
* `register_component()` in the constractor, and an instance is then
|
||||
* removed through a call to `unregister_component()` in the destructor.
|
||||
* All VST3 plugin objects we created from this plugin. We keep track of
|
||||
* these in case the plugin does a host callback, so we can associate that
|
||||
* call with the exact host context object passed to it during a call to
|
||||
* `initialize()`. The IDs here are the same IDs as generated by the Wine
|
||||
* plugin host. An instance is added here through a call by
|
||||
* `register_plugin_proxy()` in the constractor, and an instance is then
|
||||
* removed through a call to `unregister_plugin_proxy()` in the destructor.
|
||||
*/
|
||||
std::map<size_t, std::reference_wrapper<Vst3PluginProxyImpl>>
|
||||
component_instances;
|
||||
std::mutex component_instances_mutex;
|
||||
plugin_proxies;
|
||||
std::mutex plugin_proxies_mutex;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user