arduino-audio-tools
|
Buffer implementation which is using a FreeRTOS StreamBuffer. The default allocator uses psram is available. More...
#include <BufferRTOS.h>
Public Member Functions | |
BufferRTOS (size_t streamBufferSize, size_t xTriggerLevel=1, TickType_t writeMaxWait=portMAX_DELAY, TickType_t readMaxWait=portMAX_DELAY, Allocator &allocator=DefaultAllocator) | |
T * | address () override |
returns the address of the start of the physical read buffer | |
int | available () override |
provides the number of entries that are available to read | |
int | availableForWrite () override |
provides the number of entries that are available to write | |
void | clear () |
same as reset | |
virtual int | clearArray (int len) |
Removes the next len entries. | |
bool | isEmpty () |
bool | isFull () override |
checks if the buffer is full | |
virtual float | levelPercent () |
Returns the level of the buffer in %. | |
operator bool () | |
T | peek () override |
peeks the actual entry from the buffer | |
T | read () override |
reads a single value | |
int | readArray (T data[], int len) |
reads multiple values | |
int | readFrames (T data[][2], int len) |
reads multiple values for array of 2 dimensional frames | |
template<int rows, int channels> | |
int | readFrames (T(&data)[rows][channels]) |
void | reset () override |
clears the buffer | |
bool | resize (size_t size) |
Re-Allocats the memory and the queue. | |
void | setReadFromISR (bool active) |
void | setReadMaxWait (TickType_t ticks) |
void | setWriteFromISR (bool active) |
void | setWriteMaxWait (TickType_t ticks) |
size_t | size () |
bool | write (T data) override |
write add an entry to the buffer | |
int | writeArray (const T data[], int len) |
Fills the buffer data. | |
virtual int | writeArrayOverwrite (const T data[], int len) |
Fills the buffer data and overwrites the oldest data if the buffer is full. | |
Protected Member Functions | |
void | end () |
Release resurces: call resize to restart again. | |
bool | setup () |
void | setWritePos (int pos) |
Protected Attributes | |
size_t | current_size_bytes = 0 |
friend | NBuffer< T > |
Allocator * | p_allocator = nullptr |
uint8_t * | p_data = nullptr |
bool | read_from_isr = false |
int | readWait = portMAX_DELAY |
StaticStreamBuffer_t | static_stream_buffer |
size_t | trigger_level = 0 |
bool | write_from_isr = false |
int | writeWait = portMAX_DELAY |
BaseType_t | xHigherPriorityTaskWoken = pdFALSE |
StreamBufferHandle_t | xStreamBuffer = nullptr |
Buffer implementation which is using a FreeRTOS StreamBuffer. The default allocator uses psram is available.
T |
returns the address of the start of the physical read buffer
Implements BaseBuffer< T >.
provides the number of entries that are available to read
Implements BaseBuffer< T >.
provides the number of entries that are available to write
Implements BaseBuffer< T >.
Removes the next len entries.
Reimplemented in SingleBuffer< T >, SingleBuffer< int16_t >, and SingleBuffer< uint8_t >.
checks if the buffer is full
Implements BaseBuffer< T >.
peeks the actual entry from the buffer
Implements BaseBuffer< T >.
reads a single value
Implements BaseBuffer< T >.
reads multiple values
Reimplemented from BaseBuffer< T >.
clears the buffer
Implements BaseBuffer< T >.
The allocation has been postponed to be done here, so that we can e.g. use psram
Implements BaseBuffer< T >.
write add an entry to the buffer
Implements BaseBuffer< T >.
Fills the buffer data.
Reimplemented from BaseBuffer< T >.