From f1a7ad4dcbf83446c77c79b6ef9ad86f42f03ea7 Mon Sep 17 00:00:00 2001 From: Robbert van der Helm Date: Sun, 10 Dec 2023 22:30:52 +0100 Subject: [PATCH] Implement yabridge_version for all plugin bridges The host can use this to query the yabridge version in use. --- src/chainloader/clap-chainloader.cpp | 4 ++-- src/chainloader/vst2-chainloader.cpp | 4 ++-- src/chainloader/vst3-chainloader.cpp | 4 ++-- src/plugin/clap-plugin.cpp | 11 +++++++++++ src/plugin/vst2-plugin.cpp | 11 +++++++++++ src/plugin/vst3-plugin.cpp | 11 +++++++++++ 6 files changed, 39 insertions(+), 6 deletions(-) diff --git a/src/chainloader/clap-chainloader.cpp b/src/chainloader/clap-chainloader.cpp index 4d6de235..af6ba880 100644 --- a/src/chainloader/clap-chainloader.cpp +++ b/src/chainloader/clap-chainloader.cpp @@ -54,7 +54,7 @@ const void* (*yabridge_module_get_factory)(ClapPluginBridge* instance, // This bridges the `yabridge_version()` call from the plugin library. This // function was added later, so through weird version mixing it may be missing // on the yabridge library. -char* (*remote_yabridge_version)() = nullptr; +const char* (*remote_yabridge_version)() = nullptr; /** * The bridge instance for this chainloader. This is initialized when @@ -181,7 +181,7 @@ CLAP_EXPORT const clap_plugin_entry_t clap_entry = { * wouldn't be very useful, and that would also cause the chainloader to be * rebuilt on every git commit in development. */ -extern "C" YABRIDGE_EXPORT char* yabridge_version() { +extern "C" YABRIDGE_EXPORT const char* yabridge_version() { if (!initialize_library() || !remote_yabridge_version) { return nullptr; } diff --git a/src/chainloader/vst2-chainloader.cpp b/src/chainloader/vst2-chainloader.cpp index 444abf57..8e24367b 100644 --- a/src/chainloader/vst2-chainloader.cpp +++ b/src/chainloader/vst2-chainloader.cpp @@ -52,7 +52,7 @@ AEffect* (*yabridge_plugin_init)(audioMasterCallback host_callback, // This bridges the `yabridge_version()` call from the plugin library. This // function was added later, so through weird version mixing it may be missing // on the yabridge library. -char* (*remote_yabridge_version)() = nullptr; +const char* (*remote_yabridge_version)() = nullptr; /** * The first time one of the exported functions from this library gets called, @@ -127,7 +127,7 @@ YABRIDGE_EXPORT AEffect* deprecated_main(audioMasterCallback audioMaster) { * wouldn't be very useful, and that would also cause the chainloader to be * rebuilt on every git commit in development. */ -extern "C" YABRIDGE_EXPORT char* yabridge_version() { +extern "C" YABRIDGE_EXPORT const char* yabridge_version() { if (!initialize_library() || !remote_yabridge_version) { return nullptr; } diff --git a/src/chainloader/vst3-chainloader.cpp b/src/chainloader/vst3-chainloader.cpp index d2621555..7801ce1a 100644 --- a/src/chainloader/vst3-chainloader.cpp +++ b/src/chainloader/vst3-chainloader.cpp @@ -54,7 +54,7 @@ PluginFactory* (*yabridge_module_get_plugin_factory)( // This bridges the `yabridge_version()` call from the plugin library. This // function was added later, so through weird version mixing it may be missing // on the yabridge library. -char* (*remote_yabridge_version)() = nullptr; +const char* (*remote_yabridge_version)() = nullptr; /** * The bridge instance for this chainloader. This is initialized when @@ -164,7 +164,7 @@ extern "C" YABRIDGE_EXPORT PluginFactory* GetPluginFactory() { * wouldn't be very useful, and that would also cause the chainloader to be * rebuilt on every git commit in development. */ -extern "C" YABRIDGE_EXPORT char* yabridge_version() { +extern "C" YABRIDGE_EXPORT const char* yabridge_version() { if (!initialize_library() || !remote_yabridge_version) { return nullptr; } diff --git a/src/plugin/clap-plugin.cpp b/src/plugin/clap-plugin.cpp index bc3c137f..eadc099e 100644 --- a/src/plugin/clap-plugin.cpp +++ b/src/plugin/clap-plugin.cpp @@ -18,6 +18,9 @@ #include +// Generated inside of the build directory +#include + #include "bridges/clap.h" using namespace std::literals::string_literals; @@ -167,3 +170,11 @@ extern "C" YABRIDGE_EXPORT const void* yabridge_module_get_factory( return instance->get_factory(factory_id); } + +/** + * Returns the yabridge version in use. Can be queried by hosts through the + * chainloader. Both functions have the same name and signature. + */ +extern "C" YABRIDGE_EXPORT const char* yabridge_version() { + return yabridge_git_version; +} diff --git a/src/plugin/vst2-plugin.cpp b/src/plugin/vst2-plugin.cpp index 187404ce..2bed8dd3 100644 --- a/src/plugin/vst2-plugin.cpp +++ b/src/plugin/vst2-plugin.cpp @@ -16,6 +16,9 @@ #include +// Generated inside of the build directory +#include + #include "../common/linking.h" #include "bridges/vst2.h" @@ -130,3 +133,11 @@ extern "C" YABRIDGE_EXPORT AEffect* yabridge_plugin_init( return nullptr; } } + +/** + * Returns the yabridge version in use. Can be queried by hosts through the + * chainloader. Both functions have the same name and signature. + */ +extern "C" YABRIDGE_EXPORT const char* yabridge_version() { + return yabridge_git_version; +} diff --git a/src/plugin/vst3-plugin.cpp b/src/plugin/vst3-plugin.cpp index def050b9..a2c9385c 100644 --- a/src/plugin/vst3-plugin.cpp +++ b/src/plugin/vst3-plugin.cpp @@ -14,6 +14,9 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . +// Generated inside of the build directory +#include + #include "../common/linking.h" #include "bridges/vst3.h" @@ -165,3 +168,11 @@ yabridge_module_get_plugin_factory(Vst3PluginBridge* instance) { return instance->get_plugin_factory(); } + +/** + * Returns the yabridge version in use. Can be queried by hosts through the + * chainloader. Both functions have the same name and signature. + */ +extern "C" YABRIDGE_EXPORT const char* yabridge_version() { + return yabridge_git_version; +}