Implement IPluginFactory3::setHostContext()

Now the plugin factories are fully implemented (at least, functionality
wise, we still can't create most kinds of objects).
This commit is contained in:
Robbert van der Helm
2020-12-13 15:50:41 +01:00
parent 7c5f7a2e0e
commit 32c1028736
14 changed files with 95 additions and 24 deletions
+2 -1
View File
@@ -61,7 +61,8 @@ using ControlRequest = std::variant<YaComponent::Construct,
YaComponent::Destruct,
YaComponent::Initialize,
YaComponent::Terminate,
YaPluginFactory::Construct>;
YaPluginFactory::Construct,
YaPluginFactory::SetHostContext>;
template <typename S>
void serialize(S& s, ControlRequest& payload) {
+3 -2
View File
@@ -43,7 +43,8 @@
* for everything other than the edit controller's class ID.
*
* TODO: I think it's expected that components also implement `IAudioProcessor`
* and `IConnectionPoint`.
* and `IConnectionPoint`. We should use the same approach as in the
* plugin factory to implement multiple, possibly optional, interfaces.
*/
class YaComponent : public Steinberg::Vst::IComponent {
public:
@@ -57,7 +58,7 @@ class YaComponent : public Steinberg::Vst::IComponent {
* Read arguments from an existing implementation.
*/
ConstructArgs(Steinberg::IPtr<Steinberg::Vst::IComponent> component,
size_t isntance_id);
size_t instance_id);
/**
* The unique identifier for this specific instance.
@@ -20,7 +20,7 @@ YaHostApplication::ConstructArgs::ConstructArgs() {}
YaHostApplication::ConstructArgs::ConstructArgs(
Steinberg::IPtr<Steinberg::Vst::IHostApplication> context,
size_t component_instance_id)
std::optional<size_t> component_instance_id)
: component_instance_id(component_instance_id) {
Steinberg::Vst::String128 name_array;
if (context->getName(name_array) == Steinberg::kResultOk) {
@@ -48,16 +48,15 @@ class YaHostApplication : public Steinberg::Vst::IHostApplication {
* Read arguments from an existing implementation.
*/
ConstructArgs(Steinberg::IPtr<Steinberg::Vst::IHostApplication> context,
size_t component_isntance_id);
std::optional<size_t> component_instance_id);
/**
* The unique instance identifier of the component this host context has
* been passed to and thus belongs to.
*
* TODO: When we implement `IPluginFactory3::setHostContext()` this
* should be made optional.
* been passed to and thus belongs to, if we are handling
* `IpluginBase::initialize()`. When handling
* `IPluginFactory::setHostContext()` this will be empty.
*/
native_size_t component_instance_id;
std::optional<native_size_t> component_instance_id;
/**
* For `IHostApplication::getName`.
@@ -66,7 +65,10 @@ class YaHostApplication : public Steinberg::Vst::IHostApplication {
template <typename S>
void serialize(S& s) {
s.value8b(component_instance_id);
s.ext(component_instance_id, bitsery::ext::StdOptional{},
[](S& s, native_size_t& instance_id) {
s.value8b(instance_id);
});
s.ext(name, bitsery::ext::StdOptional{},
[](S& s, std::u16string& name) {
s.text2b(name, std::extent_v<Steinberg::Vst::String128>);
+19 -2
View File
@@ -25,6 +25,7 @@
#include "../../bitsery/ext/vst3.h"
#include "base.h"
#include "host-application.h"
// TODO: After implementing one or two more of these, abstract away some of the
// nasty bits
@@ -155,10 +156,26 @@ class YaPluginFactory : public Steinberg::IPluginFactory3 {
// From `IPluginFactory3`
tresult PLUGIN_API
getClassInfoUnicode(int32 index, Steinberg::PClassInfoW* info) override;
/**
* We'll pass a `IHostApplication` to the Windows VST3 plugin's factory when
* this is called so it can send messages.
* Message to pass through a call to `IPluginFactory3::setHostContext()` to
* the Wine plugin host. A proxy `YaHostApplication` should be created on
* the Wine plugin host and then passed as an argument to
* `IPluginFactory3::setHostContext()`. If the host called
* `IPluginFactory3::setHostContext()` with something other than an
* `IHostApplication*`, we return an error immediately and log the call.
*/
struct SetHostContext {
using Response = UniversalTResult;
YaHostApplication::ConstructArgs host_application_context_args;
template <typename S>
void serialize(S& s) {
s.object(host_application_context_args);
}
};
virtual tresult PLUGIN_API
setHostContext(Steinberg::FUnknown* context) override = 0;