Store plugin and host extension struct pointers

This commit is contained in:
Robbert van der Helm
2022-09-12 18:36:02 +02:00
parent d2cbc2f2ab
commit b31bee24b6
4 changed files with 68 additions and 8 deletions
+17 -4
View File
@@ -26,16 +26,20 @@
namespace fs = ghc::filesystem;
// TODO: Query extensions in the initializer list
ClapPluginExtensions::ClapPluginExtensions(const clap_plugin& plugin) noexcept {
}
ClapPluginExtensions::ClapPluginExtensions(const clap_plugin& plugin) noexcept
: audio_ports(static_cast<const clap_plugin_audio_ports_t*>(
plugin.get_extension(&plugin, CLAP_EXT_AUDIO_PORTS))) {}
ClapPluginExtensions::ClapPluginExtensions() noexcept {}
ClapPluginInstance::ClapPluginInstance(
const clap_plugin* plugin,
std::unique_ptr<clap_host_proxy> host_proxy) noexcept
: host_proxy(std::move(host_proxy)),
plugin((assert(plugin), plugin), plugin->destroy),
extensions(*plugin) {}
// We may only query the supported extensions after initializing the
// plugin
extensions() {}
ClapBridge::ClapBridge(MainContext& main_context,
// NOLINTNEXTLINE(bugprone-easily-swappable-parameters)
@@ -223,6 +227,15 @@ void ClapBridge::run() {
const bool result =
instance.plugin->init(instance.plugin.get());
if (result) {
// At this point we should also get the extension
// pointers for the plugin's supported extensions.
// In addition we'll send whether or not the plugin
// supports these extensions as booleans to the
// native plugin side so we can expose these same
// extensions to the host.
instance.extensions =
ClapPluginExtensions(*instance.plugin);
// This mimics the same behavior we had to implement
// for VST2 and VST3. The Win32 message loop is
// completely blocked while a plugin instance has