Remove cache_time_info and always cache time info

It sort of goes against yabridge's principles to not do these
unnecessary `audioMasterGetTime()` calls if the plugin does that, but it
also hurts the user experience to not have this as a default.
This commit is contained in:
Robbert van der Helm
2021-01-30 00:20:35 +01:00
parent f5b4a28bd0
commit cfb171c991
7 changed files with 29 additions and 44 deletions
+1 -7
View File
@@ -78,13 +78,7 @@ Configuration::Configuration(const fs::path& config_path,
// their defaults. At this point I'd really wish C++ could do pattern
// matching.
for (const auto& [key, value] : table) {
if (key == "cache_time_info") {
if (const auto parsed_value = value.as_boolean()) {
cache_time_info = parsed_value->get();
} else {
invalid_options.push_back(key);
}
} else if (key == "editor_double_embed") {
if (key == "editor_double_embed") {
if (const auto parsed_value = value.as_boolean()) {
editor_double_embed = parsed_value->get();
} else {
-15
View File
@@ -74,20 +74,6 @@ class Configuration {
Configuration(const boost::filesystem::path& config_path,
const boost::filesystem::path& yabridge_path);
/**
* If set to `true`, then after an `audioMasterGetTime()` call all
* subsequent calls to that function during a single processing cycle will
* reuse the results from the first call. In theory it would be a bug on the
* host's side if this did _not_ return the same value every time, but since
* yabridge tries to not have any behaviour of its own and since this
* function should only be called at most once every processing cycle this
* option is not enabled by default. An example of a situation where this
* does become necessary is the SWAM Cello plugin, which calls
* `audioMasterGetTime()` for every sample instead of only once. This would
* tank performance without this caching behaviour.
*/
bool cache_time_info = false;
/**
* If this is set to `true`, then the plugin editor should be embedded in
* yet another window. This would result in an embedding sequence of
@@ -180,7 +166,6 @@ class Configuration {
template <typename S>
void serialize(S& s) {
s.value1b(cache_time_info);
s.value1b(editor_double_embed);
s.value1b(editor_force_dnd);
s.value1b(editor_xembed);
-3
View File
@@ -168,9 +168,6 @@ class PluginBridge {
init_msg << "other options: ";
std::vector<std::string> other_options;
if (config.cache_time_info) {
other_options.push_back("hack: time info cache");
}
if (config.editor_double_embed) {
other_options.push_back("editor: double embed");
}
+7 -10
View File
@@ -178,9 +178,7 @@ Vst2Bridge::Vst2Bridge(MainContext& main_context,
// value returned by this function during an audio
// processing cycle will be reused for the rest of the
// cycle.
if (config.cache_time_info) {
time_info.reset();
}
cached_time_info.reset();
// Since the host should only be calling one of `process()`,
// processReplacing()` or `processDoubleReplacing()`, we can all
@@ -548,15 +546,14 @@ 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. 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);
// `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);
}
HostCallbackDataConverter converter(effect, time_info);
HostCallbackDataConverter converter(effect, cached_time_info);
return sockets.vst_host_callback.send_event(converter, std::nullopt, opcode,
index, value, data, option);
}
+13 -5
View File
@@ -77,12 +77,20 @@ class Vst2Bridge : public HostBridge {
intptr_t host_callback(AEffect*, int, int, intptr_t, void*, float);
/**
* 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.
* 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
*/
std::optional<VstTimeInfo> time_info;
std::optional<VstTimeInfo> cached_time_info;
private:
/**