mirror of
https://github.com/robbert-vdh/yabridge.git
synced 2026-05-14 04:19:59 +02:00
Create Vst3HostContextProxy from YaHostApplication
This is quite a huge refactor, but note everything is consistent (and we're going to need one or two more of these `Vst3*Proxy` objects). Right now nothing extends `IHostApplication`, but this way it will be trivial to add support for more host context interfaces.
This commit is contained in:
+12
-10
@@ -14,24 +14,25 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
#include "host-application.h"
|
||||
#include "host-context-proxy.h"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
YaHostApplicationImpl::YaHostApplicationImpl(
|
||||
Vst3HostContextProxyImpl::Vst3HostContextProxyImpl(
|
||||
Vst3Bridge& bridge,
|
||||
YaHostApplication::ConstructArgs&& args)
|
||||
: YaHostApplication(std::move(args)), bridge(bridge) {
|
||||
Vst3HostContextProxy::ConstructArgs&& args)
|
||||
: Vst3HostContextProxy(std::move(args)), bridge(bridge) {
|
||||
// The lifecycle is thos object is managed together with that of the plugin
|
||||
// object instance this belongs to
|
||||
// object instance instance this belongs to
|
||||
}
|
||||
|
||||
tresult PLUGIN_API
|
||||
YaHostApplicationImpl::queryInterface(const Steinberg::TUID _iid, void** obj) {
|
||||
Vst3HostContextProxyImpl::queryInterface(const Steinberg::TUID _iid,
|
||||
void** obj) {
|
||||
// I don't think it's expected of a host to implement multiple interfaces on
|
||||
// this object, so if we do get a call here it's important that it's logged
|
||||
// TODO: Successful queries should also be logged
|
||||
const tresult result = YaHostApplication::queryInterface(_iid, obj);
|
||||
const tresult result = Vst3HostContextProxy::queryInterface(_iid, obj);
|
||||
if (result != Steinberg::kResultOk) {
|
||||
std::cerr << "TODO: Implement unknown interface logging on Wine side"
|
||||
<< std::endl;
|
||||
@@ -40,9 +41,10 @@ YaHostApplicationImpl::queryInterface(const Steinberg::TUID _iid, void** obj) {
|
||||
return result;
|
||||
}
|
||||
|
||||
tresult PLUGIN_API YaHostApplicationImpl::createInstance(Steinberg::TUID cid,
|
||||
Steinberg::TUID _iid,
|
||||
void** obj) {
|
||||
tresult PLUGIN_API
|
||||
Vst3HostContextProxyImpl::createInstance(Steinberg::TUID cid,
|
||||
Steinberg::TUID _iid,
|
||||
void** obj) {
|
||||
// TODO: Implement
|
||||
std::cerr << "TODO: IHostApplication::createInstance()" << std::endl;
|
||||
return Steinberg::kNotImplemented;
|
||||
+4
-3
@@ -18,10 +18,10 @@
|
||||
|
||||
#include "../vst3.h"
|
||||
|
||||
class YaHostApplicationImpl : public YaHostApplication {
|
||||
class Vst3HostContextProxyImpl : public Vst3HostContextProxy {
|
||||
public:
|
||||
YaHostApplicationImpl(Vst3Bridge& bridge,
|
||||
YaHostApplication::ConstructArgs&& args);
|
||||
Vst3HostContextProxyImpl(Vst3Bridge& bridge,
|
||||
Vst3HostContextProxy::ConstructArgs&& args);
|
||||
|
||||
/**
|
||||
* We'll override the query interface to log queries for interfaces we do
|
||||
@@ -30,6 +30,7 @@ class YaHostApplicationImpl : public YaHostApplication {
|
||||
tresult PLUGIN_API queryInterface(const Steinberg::TUID _iid,
|
||||
void** obj) override;
|
||||
|
||||
// From `IHostApplication`
|
||||
tresult PLUGIN_API createInstance(Steinberg::TUID cid,
|
||||
Steinberg::TUID _iid,
|
||||
void** obj) override;
|
||||
@@ -24,7 +24,7 @@
|
||||
#include <public.sdk/source/vst/hosting/module_win32.cpp>
|
||||
|
||||
#include "vst3-impls/component-handler-proxy.h"
|
||||
#include "vst3-impls/host-application.h"
|
||||
#include "vst3-impls/host-context-proxy.h"
|
||||
|
||||
InstanceInterfaces::InstanceInterfaces() {}
|
||||
|
||||
@@ -371,21 +371,19 @@ void Vst3Bridge::run() {
|
||||
// `Vst3HostProxy`
|
||||
// TODO: Does this have to be run from the UI thread? Figure out
|
||||
// if it does
|
||||
if (request.host_application_context_args) {
|
||||
object_instances[request.instance_id]
|
||||
.host_application_context =
|
||||
Steinberg::owned(new YaHostApplicationImpl(
|
||||
*this,
|
||||
std::move(*request.host_application_context_args)));
|
||||
if (request.host_context_args) {
|
||||
object_instances[request.instance_id].host_context_proxy =
|
||||
Steinberg::owned(new Vst3HostContextProxyImpl(
|
||||
*this, std::move(*request.host_context_args)));
|
||||
} else {
|
||||
object_instances[request.instance_id]
|
||||
.host_application_context = nullptr;
|
||||
object_instances[request.instance_id].host_context_proxy =
|
||||
nullptr;
|
||||
}
|
||||
|
||||
return object_instances[request.instance_id]
|
||||
.plugin_base->initialize(
|
||||
object_instances[request.instance_id]
|
||||
.host_application_context);
|
||||
.host_context_proxy);
|
||||
},
|
||||
[&](const YaPluginBase::Terminate& request)
|
||||
-> YaPluginBase::Terminate::Response {
|
||||
@@ -399,16 +397,19 @@ void Vst3Bridge::run() {
|
||||
},
|
||||
[&](YaPluginFactory::SetHostContext& request)
|
||||
-> YaPluginFactory::SetHostContext::Response {
|
||||
plugin_factory_host_application_context =
|
||||
Steinberg::owned(new YaHostApplicationImpl(
|
||||
*this,
|
||||
std::move(request.host_application_context_args)));
|
||||
if (request.host_context_args) {
|
||||
plugin_factory_host_context =
|
||||
Steinberg::owned(new Vst3HostContextProxyImpl(
|
||||
*this, std::move(*request.host_context_args)));
|
||||
} else {
|
||||
plugin_factory_host_context = nullptr;
|
||||
}
|
||||
|
||||
Steinberg::FUnknownPtr<Steinberg::IPluginFactory3> factory_3(
|
||||
module->getFactory().get());
|
||||
|
||||
assert(factory_3);
|
||||
return factory_3->setHostContext(
|
||||
plugin_factory_host_application_context);
|
||||
return factory_3->setHostContext(plugin_factory_host_context);
|
||||
}});
|
||||
}
|
||||
|
||||
|
||||
@@ -38,12 +38,12 @@ struct InstanceInterfaces {
|
||||
InstanceInterfaces(Steinberg::IPtr<Steinberg::FUnknown> object);
|
||||
|
||||
/**
|
||||
* If the host passes an `IHostApplication` during
|
||||
* If the host passes a host context object during
|
||||
* `IPluginBase::initialize()`, we'll store a proxy object here and then
|
||||
* pass it to `plugin_base->initialize()`. Will be initialized with a null
|
||||
* pointer until used.
|
||||
*/
|
||||
Steinberg::IPtr<YaHostApplication> host_application_context;
|
||||
Steinberg::IPtr<Vst3HostContextProxy> host_context_proxy;
|
||||
|
||||
/**
|
||||
* After a call to `IEditController::setComponentHandler()`, we'll create a
|
||||
@@ -155,11 +155,10 @@ class Vst3Bridge : public HostBridge {
|
||||
std::atomic_size_t current_instance_id;
|
||||
|
||||
/**
|
||||
* The host application context proxy object if we got passed a host
|
||||
* application context during a call to `IPluginFactory3::setHostContext()`
|
||||
* by the host.
|
||||
* The host context proxy object if we got passed a host context during a
|
||||
* call to `IPluginFactory3::setHostContext()` by the host.
|
||||
*/
|
||||
Steinberg::IPtr<YaHostApplication> plugin_factory_host_application_context;
|
||||
Steinberg::IPtr<Vst3HostContextProxy> plugin_factory_host_context;
|
||||
|
||||
/**
|
||||
* These are all the objects we have created through the Windows VST3
|
||||
|
||||
Reference in New Issue
Block a user