Add manual reference counting to GetPluginFactory

Since even though we're passign raw pointers, it's expected that they
are actually `IPtr<T>`s.
This commit is contained in:
Robbert van der Helm
2020-12-07 14:53:55 +01:00
parent 547b11e8ba
commit 9954282065
4 changed files with 46 additions and 37 deletions
+20 -9
View File
@@ -81,13 +81,24 @@ Vst3PluginBridge::Vst3PluginBridge()
overload{[&](const WantsConfiguration&)
-> WantsConfiguration::Response { return config; }});
});
// Set up the plugin factory, since this is the first thing the host will
// request after loading the module. Host callback handlers should have
// started before this since the Wine plugin host will request a copy of the
// configuration during its initialization.
plugin_factory = std::make_unique<YaPluginFactoryPluginImpl>(*this);
sockets.host_vst_control.receive_into(
WantsPluginFactory{}, *plugin_factory,
std::pair<Vst3Logger&, bool>(logger, true));
}
Steinberg::IPluginFactory* Vst3PluginBridge::get_plugin_factory() {
// Even though we're working with raw pointers here, we should pretend that
// we're `IPtr<Steinberg::IPluginFactory>` and do the reference counting
// ourselves because you can't always safely pass those around
if (plugin_factory) {
plugin_factory->addRef();
} else {
// Set up the plugin factory, since this is the first thing the host
// will request after loading the module. Host callback handlers should
// have started before this since the Wine plugin host will request a
// copy of the configuration during its initialization.
plugin_factory = std::make_unique<YaPluginFactoryPluginImpl>(*this);
sockets.host_vst_control.receive_into(
WantsPluginFactory{}, *plugin_factory,
std::pair<Vst3Logger&, bool>(logger, true));
}
return plugin_factory.get();
}