Fix serializing silence flags

We didn't initialize the field, and we also didn't copy the updated
value back (since everything else is a pointer to the original data).
This fixes audio channels in REAPER randomly being silence, as this
field would otherwise be uninitialized.

Thanks a lot to @kytdkut for finding this issue!
This commit is contained in:
Robbert van der Helm
2021-01-26 23:50:48 +01:00
parent cf9ae47f99
commit 04d0ff0949
2 changed files with 20 additions and 8 deletions
@@ -233,6 +233,15 @@ Steinberg::Vst::ProcessData& YaProcessData::get() {
} }
YaProcessDataResponse YaProcessData::move_outputs_to_response() { YaProcessDataResponse YaProcessData::move_outputs_to_response() {
// NOTE: We _have_ to manually copy over the silence flags from the
// `ProcessData` object generated in `get()` here sicne these of
// course are not references or pointers like all other fields, so
// they're not implicitly copied like all of our other fields
for (int i = 0; i < reconstructed_process_data.numOutputs; i++) {
outputs[i].silence_flags =
reconstructed_process_data.outputs[i].silenceFlags;
}
return YaProcessDataResponse{ return YaProcessDataResponse{
.outputs = std::move(outputs), .outputs = std::move(outputs),
.output_parameter_changes = std::move(output_parameter_changes), .output_parameter_changes = std::move(output_parameter_changes),
+11 -8
View File
@@ -69,6 +69,9 @@ class YaAudioBusBuffers {
* constructor and return it. This is used as part of * constructor and return it. This is used as part of
* `YaProcessData::get()`. The object contains pointers to `buffers`, so it * `YaProcessData::get()`. The object contains pointers to `buffers`, so it
* may not outlive this object. * may not outlive this object.
*
* NOTE: The `silenceFlags` field is of course not a reference, so writing
* to that will not modify `silence_flags`.
*/ */
Steinberg::Vst::AudioBusBuffers get(); Steinberg::Vst::AudioBusBuffers get();
@@ -103,13 +106,6 @@ class YaAudioBusBuffers {
}); });
} }
private:
/**
* We need these during the reconstruction process to provide a pointer to
* an array of pointers to the actual buffers.
*/
std::vector<void*> buffer_pointers;
/** /**
* A bitfield for silent channels copied directly from the input struct. * A bitfield for silent channels copied directly from the input struct.
* *
@@ -117,7 +113,14 @@ class YaAudioBusBuffers {
* these silence flags are set, but since it's an optional feature we * these silence flags are set, but since it's an optional feature we
* shouldn't risk it. * shouldn't risk it.
*/ */
uint64 silence_flags; uint64 silence_flags = 0;
private:
/**
* We need these during the reconstruction process to provide a pointer to
* an array of pointers to the actual buffers.
*/
std::vector<void*> buffer_pointers;
/** /**
* The original implementation uses heap arrays and it stores a * The original implementation uses heap arrays and it stores a