diff --git a/src/common/serialization/clap/audio-buffer.h b/src/common/serialization/clap/audio-buffer.h new file mode 100644 index 00000000..511c555e --- /dev/null +++ b/src/common/serialization/clap/audio-buffer.h @@ -0,0 +1,50 @@ +// yabridge: a Wine plugin bridge +// Copyright (C) 2020-2022 Robbert van der Helm +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more destates. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +#pragma once + +#include + +// Serialization messages for `clap/audio-buffer.h` + +namespace clap { +namespace audio_buffer { + +/** + * Metadata used to encode whether an audio port/buffer carries 32-=bit or + * 64-bit audio data. This needs to be stored separately because CLAP uses + * whether or not one of the two pointers is null to indicate the type of data + * stored in the audio buffer. + */ +enum class AudioBufferType : uint8_t { + Float32, + Double64, +}; + +} // namespace audio_buffer +} // namespace clap + +template +void serialize(S& s, clap_audio_buffer_t& buffer) { + // These need to be set later using the shared memory object and depending + // on the `AudioBufferType`. We'll zero them out so default initialized + // objects created by bitsery won't contain uninitialized memory. + buffer.data32 = nullptr; + buffer.data64 = nullptr; + s.value4b(buffer.channel_count); + s.value4b(buffer.latency); + s.value8b(buffer.constant_mask); +}