From 4d7724c5b60e93a82a34177ca840b8d8ad3b3afc Mon Sep 17 00:00:00 2001 From: Robbert van der Helm Date: Fri, 1 May 2020 17:53:06 +0200 Subject: [PATCH] Add a workaround for a bug in Ardour 5.X Ardour will send events to the plugin before it has even finished initializing. This has been fixed back in 2018 but Ardour has not seen a stable release since then. https://tracker.ardour.org/view.php?id=7668 --- README.md | 9 ++++----- src/plugin/host-bridge.cpp | 16 ++++++++++++++++ 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 1d2555b9..ec8dab95 100644 --- a/README.md +++ b/README.md @@ -10,18 +10,17 @@ also staying easy to debug and maintain. There are a few things that should be done before releasing this, including: -- Do some final refactoring/clean up. There are a few small todos left for - things that could be a made little bit prettier. - Add missing details if any to the architecture section. - Rewrite parts of this readme. - Briefly verify that this also works fine in Reaper and Ardour. ## Tested with -yabridge has been primarily tested under and verified to work correctly with: +Yabridge has been verified to work correctly with: - Bitwig Studio 3.1 and the beta releases of 3.2 - Carla 2.1 +- Ardour 5.12 - Wine Staging 5.5 and 5.6 (the wine-staging-5.7-1 package currently in Arch and Manjaro's repositories is broken because of a regression in application startup behavior) @@ -70,8 +69,8 @@ find "$HOME/.wine/drive_c/Program Files/Steinberg/VstPlugins" -type f -iname '*. ### Copying It is also possible to use yabridge by creating copies of `libyabridge.so` -instead of making symlinks. This is not recommended as it makes updating a -hassle, but it may be required if your host has issues using symlinks. If you +instead of making symlinks. This is not recommended as it makes updating more +difficult, but it may be required if your host has issues using symlinks. If you choose to do this, then you'll have to make sure `yabridge-host.exe` and `yabridge-host.exe.so` are somewhere in your search path as otherwise yabridge won't be able to find them. Either copy them to `/usr/local/bin` (not diff --git a/src/plugin/host-bridge.cpp b/src/plugin/host-bridge.cpp index 86be85ba..a7b69abc 100644 --- a/src/plugin/host-bridge.cpp +++ b/src/plugin/host-bridge.cpp @@ -330,6 +330,22 @@ intptr_t HostBridge::dispatch(AEffect* /*plugin*/, intptr_t value, void* data, float option) { + // HACK: Ardour 5.X has a bug in its VST implementation where it calls the + // plugin's dispatcher before the plugin has even finished + // initializing. This has been fixed back in 2018, but there has not + // been a release that contains the fix yet. This should be removed + // once Ardour 6.0 gets released. + // https://tracker.ardour.org/view.php?id=7668 + if (BOOST_UNLIKELY(plugin.magic == 0)) { + logger.log_event(true, opcode, index, value, nullptr, option); + logger.log( + " WARNING: The host has dispatched an event before the plugin " + "has finished initializing, ignoring the event. (are we running " + "Ardour 5.X?)"); + logger.log_event_response(true, opcode, 0, nullptr); + return 0; + } + DispatchDataConverter converter(chunk_data, editor_rectangle); switch (opcode) {