From b52362e698e5fdd40619db4d4b7ada0d5b0d9ee7 Mon Sep 17 00:00:00 2001 From: Robbert van der Helm Date: Tue, 27 Apr 2021 17:31:23 +0200 Subject: [PATCH] Fix time info cache being applied to other opcodes I don't know how I've never noticed this, but we should of course only be handling `audioMasterGetTime()` this way. This also explains why enabling this permanently in the past broke some plugins. --- CHANGELOG.md | 2 ++ src/wine-host/bridges/vst2.cpp | 18 +++++++++++------- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 989b9219..17202753 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -38,6 +38,8 @@ Versioning](https://semver.org/spec/v2.0.0.html). fix, MIDI events are now deallocated later then when they normally would have to be. - Fixed _UVI Plugsound Free_ crashing during initialization. +- Fixed the `cache_time_info` `yabridge.toml` option also affecting the results + of other host callbacks during audio processing. ## [3.1.0] - 2021-04-15 diff --git a/src/wine-host/bridges/vst2.cpp b/src/wine-host/bridges/vst2.cpp index 6c0adbf4..a2af16e6 100644 --- a/src/wine-host/bridges/vst2.cpp +++ b/src/wine-host/bridges/vst2.cpp @@ -595,13 +595,17 @@ intptr_t Vst2Bridge::host_callback(AEffect* effect, intptr_t value, void* data, float option) { - // HACK: Workaround for a bug in SWAM Cello where it would call - // `audioMasterGetTime()` once for every sample. When this option is - // enabled `time_info` should be reset in the process function. The - // `time_info` value is assigned inside of - // `HostCallbackDataConverter::write()`. - if (config.cache_time_info && time_info) { - return reinterpret_cast(&*time_info); + switch (opcode) { + case audioMasterGetTime: { + // HACK: Workaround for a bug in SWAM Cello where it would call + // `audioMasterGetTime()` once for every sample. When this + // option is enabled `time_info` should be reset in the + // process function. The `time_info` value is assigned inside + // of `HostCallbackDataConverter::write()`. + if (config.cache_time_info && time_info) { + return reinterpret_cast(&*time_info); + } + } break; } HostCallbackDataConverter converter(effect, time_info);