Revert "Remove cache_time_info and always cache time info"

This reverts commit cfb171c991.

No idea why, but this cache breaks SPL Transient Designer Plus. Perhaps
it overwrites the time info?
This commit is contained in:
Robbert van der Helm
2021-01-30 02:37:27 +01:00
parent 9858db25d2
commit 0adca3e33c
7 changed files with 44 additions and 29 deletions
+10 -7
View File
@@ -178,7 +178,9 @@ Vst2Bridge::Vst2Bridge(MainContext& main_context,
// value returned by this function during an audio
// processing cycle will be reused for the rest of the
// cycle.
cached_time_info.reset();
if (config.cache_time_info) {
time_info.reset();
}
// Since the host should only be calling one of `process()`,
// processReplacing()` or `processDoubleReplacing()`, we can all
@@ -546,14 +548,15 @@ intptr_t Vst2Bridge::host_callback(AEffect* effect,
void* data,
float option) {
// HACK: Workaround for a bug in SWAM Cello where it would call
// `audioMasterGetTime()` once for every sample. The `time_info` value
// is assigned inside of `HostCallbackDataConverter::write()`. At the
// beginning of the processing cycle this value will be reset.
if (cached_time_info) {
return reinterpret_cast<intptr_t>(&*cached_time_info);
// `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<intptr_t>(&*time_info);
}
HostCallbackDataConverter converter(effect, cached_time_info);
HostCallbackDataConverter converter(effect, time_info);
return sockets.vst_host_callback.send_event(converter, std::nullopt, opcode,
index, value, data, option);
}
+5 -13
View File
@@ -77,20 +77,12 @@ class Vst2Bridge : public HostBridge {
intptr_t host_callback(AEffect*, int, int, intptr_t, void*, float);
/**
* The time information returned by the host after the plugin calls
* `audioMasterGetTime()`. We'll have to return a pointer to this, so we'll
* store it here. If the host returned a null pointer, then we'll just store
* a nullopt.
*
* We'll keep this information around for the entire processing cycle, in
* case a plugin somehow calls this function more than once, like the SWAM
* Cello plugin does.
*
* XXX: We don't have any logging for when the plugin calls
* `audioMasterGetTime()` more than once, but printing some message
* 44100 times per second also doesn't sound great
* With the `audioMasterGetTime` host callback the plugin expects the return
* value from the calblack to be a pointer to a VstTimeInfo struct. If the
* host did not support a certain time info query, than we'll store the
* returned null pointer as a nullopt.
*/
std::optional<VstTimeInfo> cached_time_info;
std::optional<VstTimeInfo> time_info;
private:
/**