mirror of
https://github.com/robbert-vdh/yabridge.git
synced 2026-05-06 19:40:10 +02:00
Use a statically allocated array for audio buffers
We wouldn't know the right size on the receiving end in advance.
This commit is contained in:
@@ -39,7 +39,6 @@ constexpr size_t max_audio_channels = 32;
|
|||||||
/**
|
/**
|
||||||
* The maximum number of samples in a buffer.
|
* The maximum number of samples in a buffer.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
constexpr size_t max_buffer_size = 16384;
|
constexpr size_t max_buffer_size = 16384;
|
||||||
/**
|
/**
|
||||||
* The maximum size in bytes of a string or buffer passed through a void pointer
|
* The maximum size in bytes of a string or buffer passed through a void pointer
|
||||||
@@ -55,12 +54,6 @@ constexpr size_t max_string_length = 128;
|
|||||||
template <std::size_t N>
|
template <std::size_t N>
|
||||||
using ArrayBuffer = std::array<uint8_t, N>;
|
using ArrayBuffer = std::array<uint8_t, N>;
|
||||||
|
|
||||||
/**
|
|
||||||
* A dynamically sized buffer, useful for larger types without known sizes. In
|
|
||||||
* other words, audio buffers.
|
|
||||||
*/
|
|
||||||
using VectorBuffer = std::vector<uint8_t>;
|
|
||||||
|
|
||||||
template <typename B>
|
template <typename B>
|
||||||
using OutputAdapter = bitsery::OutputBufferAdapter<B>;
|
using OutputAdapter = bitsery::OutputBufferAdapter<B>;
|
||||||
|
|
||||||
@@ -168,7 +161,11 @@ struct ParameterResult {
|
|||||||
* processing. The number of samples is encoded in each audio buffer's length.
|
* processing. The number of samples is encoded in each audio buffer's length.
|
||||||
*/
|
*/
|
||||||
struct AudioBuffer {
|
struct AudioBuffer {
|
||||||
using buffer_type = VectorBuffer;
|
// When sending data we could use a vector of the right size, but when
|
||||||
|
// receiving data we don't know how large this vector should be in advance
|
||||||
|
// (or without sending the message length first)
|
||||||
|
using buffer_type =
|
||||||
|
ArrayBuffer<max_audio_channels * max_buffer_size * sizeof(float)>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An audio buffer for each of the plugin's audio channels. The number of
|
* An audio buffer for each of the plugin's audio channels. The number of
|
||||||
@@ -224,8 +221,8 @@ struct buffer_t<AEffect> {
|
|||||||
*
|
*
|
||||||
* @param socket The Boost.Asio socket to write to.
|
* @param socket The Boost.Asio socket to write to.
|
||||||
* @param object The object to write to the stream.
|
* @param object The object to write to the stream.
|
||||||
* @param buffer The buffer to write to. Only needed for audio buffers
|
* @param buffer The buffer to write to. Only needed for when sending audio
|
||||||
* constantly allocating huge vectors would be a waste.
|
* because their buffers might be quite large.
|
||||||
*
|
*
|
||||||
* @relates read_object
|
* @relates read_object
|
||||||
*/
|
*/
|
||||||
@@ -254,8 +251,8 @@ inline void write_object(Socket& socket, const T& object) {
|
|||||||
* @param object The object to deserialize to, if given. This can be used to
|
* @param object The object to deserialize to, if given. This can be used to
|
||||||
* update an existing `AEffect` struct without losing the pointers set by the
|
* update an existing `AEffect` struct without losing the pointers set by the
|
||||||
* host and the bridge.
|
* host and the bridge.
|
||||||
* @param buffer The buffer to write to. Only needed for audio buffers
|
* @param buffer The buffer to write to. Only needed for when sending audio
|
||||||
* constantly allocating huge vectors would be a waste.
|
* because their buffers might be quite large.
|
||||||
*
|
*
|
||||||
* @throw std::runtime_error If the conversion to an object was not successful.
|
* @throw std::runtime_error If the conversion to an object was not successful.
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user