diff --git a/CHANGELOG.md b/CHANGELOG.md index 883250bd..03fd8b0e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,6 +23,9 @@ Versioning](https://semver.org/spec/v2.0.0.html). of only printing it to the logger. This makes diagnosing issues much faster if you didn't already start your DAW from a terminal. These notifications require `libnotify` and the `notify-send` application to be installed. +- Also added a warning and a desktop notification when there's a version + mismatch between the yabridge host application and the plugin to remind you to + rerun `yabridgectl sync`. - Added an environment variable to disable the watchdog timer. This allows the Wine process to run under a separate namespace. If you don't know that you need this, then you probably don't need this! diff --git a/src/common/serialization/vst3.h b/src/common/serialization/vst3.h index 09779134..c8baa61b 100644 --- a/src/common/serialization/vst3.h +++ b/src/common/serialization/vst3.h @@ -51,13 +51,19 @@ /** * Marker struct to indicate the other side (the plugin) should send a copy of - * the configuration. + * the configuration. During this process we will also transmit the version + * string from the host, so we can show a little warning when the user forgot to + * rerun `yabridgectl sync` (and the initialization was still successful). */ struct WantsConfiguration { using Response = Configuration; + std::string host_version; + template - void serialize(S&) {} + void serialize(S& s) { + s.text1b(host_version, 128); + } }; /** diff --git a/src/plugin/bridges/common.h b/src/plugin/bridges/common.h index fc4b555e..9bd4218e 100644 --- a/src/plugin/bridges/common.h +++ b/src/plugin/bridges/common.h @@ -339,6 +339,30 @@ class PluginBridge { #endif } + /** + * Show a desktop notification if the Wine plugin host is using a different + * version of yabridge than this library. Yabridge may still work (and we do + * this often during development), but at some point a request may fail the + * plugin and the host are out of sync. + */ + void warn_on_version_mismatch(const std::string& host_version) { + if (host_version != yabridge_git_version) { + generic_logger.log( + "WARNING: The host application's version does not match"); + generic_logger.log( + " this plugin's. If you just updated yabridge, then"); + generic_logger.log( + " you may need rerun 'yabridgectl sync' first to"); + generic_logger.log(" update your plugins."); + + send_notification( + "Version mismatch", + "If you just updated yabridge, then you may need " + "to rerun 'yabridgectl sync' first to update your plugins.", + true); + } + } + /** * The configuration for this instance of yabridge. Set based on the values * from a `yabridge.toml`, if it exists. diff --git a/src/plugin/bridges/vst3.cpp b/src/plugin/bridges/vst3.cpp index 3fdb5df1..ddcb27d8 100644 --- a/src/plugin/bridges/vst3.cpp +++ b/src/plugin/bridges/vst3.cpp @@ -63,7 +63,10 @@ Vst3PluginBridge::Vst3PluginBridge() return Ack{}; }, - [&](const WantsConfiguration&) -> WantsConfiguration::Response { + [&](const WantsConfiguration& request) + -> WantsConfiguration::Response { + warn_on_version_mismatch(request.host_version); + return config; }, [&](const YaComponentHandler::BeginEdit& request) diff --git a/src/wine-host/bridges/vst3.cpp b/src/wine-host/bridges/vst3.cpp index 8531e30f..db7928e7 100644 --- a/src/wine-host/bridges/vst3.cpp +++ b/src/wine-host/bridges/vst3.cpp @@ -24,6 +24,9 @@ #include "vst3-impls/host-context-proxy.h" #include "vst3-impls/plug-frame-proxy.h" +// Generated inside of the build directory +#include + // NOLINTNEXTLINE(bugprone-suspicious-include) #include @@ -100,8 +103,8 @@ Vst3Bridge::Vst3Bridge(MainContext& main_context, // Fetch this instance's configuration from the plugin to finish the setup // process - config = sockets.vst_host_callback.send_message(WantsConfiguration{}, - std::nullopt); + config = sockets.vst_host_callback.send_message( + WantsConfiguration{.host_version = yabridge_git_version}, std::nullopt); // Allow this plugin to configure the main context's tick rate main_context.update_timer_interval(config.event_loop_interval());