Don't cache IHostApplication::getName()

As it turns out there are only two or three functions where we can do
this. It also breaks logging, and this function will probably only be
called once anyways. More consistency is always better.
This commit is contained in:
Robbert van der Helm
2020-12-19 18:28:16 +01:00
parent 01d84b0029
commit 63ae5f330c
13 changed files with 124 additions and 41 deletions
@@ -106,6 +106,10 @@ YaPluginFactoryImpl::setHostContext(Steinberg::FUnknown* context) {
// context.
host_context = context;
// Automatically converted smart pointers for when the plugin performs a
// callback later
host_application = host_context;
std::optional<Vst3HostContextProxy::ConstructArgs> host_context_args{};
if (host_context) {
host_context_args =
@@ -28,6 +28,11 @@ class YaPluginFactoryImpl : public YaPluginFactory {
void** obj) override;
tresult PLUGIN_API setHostContext(Steinberg::FUnknown* context) override;
// The following pointers are cast from `host_context` if `setHostContext()`
// has been called
Steinberg::FUnknownPtr<Steinberg::Vst::IHostApplication> host_application;
private:
Vst3PluginBridge& bridge;
@@ -323,6 +323,10 @@ tresult PLUGIN_API Vst3PluginProxyImpl::setComponentHandler(
// this component handler
component_handler = handler;
// Automatically converted smart pointers for when the plugin performs a
// callback later
host_application = host_context;
std::optional<Vst3ComponentHandlerProxy::ConstructArgs>
component_handler_proxy_args = std::nullopt;
if (handler) {
@@ -130,6 +130,11 @@ class Vst3PluginProxyImpl : public Vst3PluginProxy {
*/
Steinberg::IPtr<Steinberg::Vst::IComponentHandler> component_handler;
// The following pointers are cast from `host_context` if `setHostContext()`
// has been called
Steinberg::FUnknownPtr<Steinberg::Vst::IHostApplication> host_application;
private:
Vst3PluginBridge& bridge;
+18
View File
@@ -83,6 +83,24 @@ Vst3PluginBridge::Vst3PluginBridge()
[&](const WantsConfiguration&) -> WantsConfiguration::Response {
return config;
},
[&](const YaHostApplication::GetName& request)
-> YaHostApplication::GetName::Response {
tresult result;
Steinberg::Vst::String128 name{0};
if (request.owner_instance_id) {
result = plugin_proxies.at(*request.owner_instance_id)
.get()
.host_application->getName(name);
} else {
result =
plugin_factory->host_application->getName(name);
}
return YaHostApplication::GetNameResponse{
.result = result,
.name = tchar_pointer_to_u16string(name),
};
},
[&](const YaComponentHandler::BeginEdit& request)
-> YaComponentHandler::BeginEdit::Response {
return plugin_proxies.at(request.owner_instance_id)
+3 -2
View File
@@ -23,8 +23,9 @@
#include "../../common/logging/vst3.h"
#include "common.h"
// Forward declaration
// Forward declarations
class Vst3PluginProxyImpl;
class YaPluginFactoryImpl;
/**
* This handles the communication between the native host and a VST3 plugin
@@ -134,7 +135,7 @@ class Vst3PluginBridge : PluginBridge<Vst3Sockets<std::jthread>> {
*
* @related get_plugin_factory
*/
YaPluginFactory* plugin_factory = nullptr;
YaPluginFactoryImpl* plugin_factory = nullptr;
private:
/**