template<typename T, template< typename > class BufferType>
class audio_tools::DynamicMultiBuffer< T, BufferType >
Auto-expanding buffer composed of multiple buffer instances.
DynamicMultiBuffer manages a collection of buffer components, automatically adding new buffers when existing ones become full. This provides dynamically growing storage capacity while maintaining the performance characteristics of the underlying buffer implementation.
Ideal use cases:
- Recording audio of unknown duration
- Processing large audio files without pre-allocating maximum memory
- Audio applications where memory requirements grow unpredictably
- Efficient memory use by allocating only what's needed
- Author
- Phil Schatzmann
- Copyright
- GPLv3
- Template Parameters
-
T | Data type to be stored in the buffer |
BufferType | The buffer implementation to use for each component |
template<typename T , template< typename > class BufferType>
Get pointer to current read position.
Note: This method has limitations since data may span multiple buffer components. It returns the address from the current component.
- Returns
- Pointer to the current read position in memory
Implements BaseBuffer< T >.
template<typename T , template< typename > class BufferType>
int availableForWrite |
( |
| ) |
|
|
inlineoverridevirtual |
Get space available for writing.
Returns remaining space in existing components plus potential new components up to max_components limit.
- Returns
- Number of elements that can be written
Implements BaseBuffer< T >.
template<typename T , template< typename > class BufferType>
Check if the buffer is full.
Buffer is considered full only if we've reached max components and the last component is full.
- Returns
- true if no more elements can be written
Reimplemented from BaseBuffer< T >.
template<typename T , template< typename > class BufferType>
Peek at the next value without removing it.
Returns the next element that would be read without advancing the read position.
- Parameters
-
result | Reference where the peeked value will be stored |
- Returns
- true if peek was successful, false if buffer is empty
Implements BaseBuffer< T >.
template<typename T , template< typename > class BufferType>
Read a single value from the buffer.
Reads from the current read position, potentially spanning buffer components.
- Parameters
-
result | Reference where the read value will be stored |
- Returns
- true if read was successful, false if buffer is empty
Implements BaseBuffer< T >.
template<typename T , template< typename > class BufferType>
int readArray |
( |
T |
data[], |
|
|
int |
len |
|
) |
| |
|
inlineoverridevirtual |
Optimized bulk read operation.
Reads multiple elements, potentially spanning across buffer components.
- Parameters
-
data | Buffer where read data will be stored |
len | Number of elements to read |
- Returns
- Number of elements actually read
Reimplemented from BaseBuffer< T >.
template<typename T , template< typename > class BufferType>
Write a value to the buffer.
Adds an element to the buffer at the current write position, automatically expanding capacity by adding a new buffer component if needed.
- Parameters
-
- Returns
- true if write was successful, false if buffer is full (max components reached)
Implements BaseBuffer< T >.
template<typename T , template< typename > class BufferType>
int writeArray |
( |
const T |
data[], |
|
|
int |
len |
|
) |
| |
|
inlineoverridevirtual |
Optimized bulk write operation.
Writes multiple elements, automatically expanding capacity by adding new buffer components as needed.
- Parameters
-
data | Array of elements to write |
len | Number of elements to write |
- Returns
- Number of elements actually written
Reimplemented from BaseBuffer< T >.