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