arduino-audio-tools
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
BufferRTOS< T > Class Template Reference

Buffer implementation which is using a FreeRTOS StreamBuffer. The default allocator uses psram is available. More...

#include <BufferRTOS.h>

Inheritance diagram for BufferRTOS< T >:
BaseBuffer< T >

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 %.
 
peek () override
 peeks the actual entry from the buffer
 
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 >
 
Allocatorp_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
 

Detailed Description

template<typename T>
class audio_tools::BufferRTOS< T >

Buffer implementation which is using a FreeRTOS StreamBuffer. The default allocator uses psram is available.

Author
Phil Schatzmann
Template Parameters
T

Member Function Documentation

◆ setup()

bool setup ( )
inlineprotected

The allocation has been postponed to be done here, so that we can e.g. use psram


The documentation for this class was generated from the following file: