|
| DynamicMultiBuffer (size_t component_size, size_t initial_components=1, size_t max_components=0) |
| Constructor with buffer configuration.
|
|
virtual | ~DynamicMultiBuffer () |
| Destructor - releases all buffer components.
|
|
T * | address () override |
| Get pointer to current read position.
|
|
int | available () override |
| Get number of elements available to read.
|
|
int | availableForWrite () override |
| Get space available for writing.
|
|
bool | begin () |
| (Re)sets the read pos to the start
|
|
bool | begin (int pos) |
| (Re)sets the read pos to the indicated position
|
|
void | clear () |
| same as reset
|
|
virtual int | clearArray (int len) |
| Removes the next len entries.
|
|
size_t | getComponentCount () |
| Get the number of buffer components.
|
|
size_t | getComponentSize () |
| Get the size of each component.
|
|
bool | isEmpty () override |
| Check if the buffer is empty.
|
|
bool | isFull () override |
| Check if the buffer is full.
|
|
virtual float | levelPercent () |
| Returns the level of the buffer in %.
|
|
bool | peek (T &result) override |
| Peek at the next value without removing it.
|
|
bool | read (T &result) override |
| Read a single value from the buffer.
|
|
int | readArray (T data[], int len) override |
| Optimized bulk read operation.
|
|
void | reset () override |
| Reset the buffer to empty state.
|
|
bool | resize (int new_size) override |
| Resize the buffer.
|
|
size_t | size () override |
| Get total capacity of the buffer.
|
|
bool | write (T data) override |
| Write a value to the buffer.
|
|
int | writeArray (const T data[], int len) override |
| Optimized bulk write operation.
|
|
virtual int | writeArrayOverwrite (const T data[], int len) |
| Fills the buffer data and overwrites the oldest data if the buffer is full.
|
|
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 >.