arduino-audio-tools
Loading...
Searching...
No Matches
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)
 
Taddress () 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 >
 
Allocatorp_allocator = nullptr
 
uint8_tp_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

◆ address()

template<typename T >
T * address ( )
inlineoverridevirtual

returns the address of the start of the physical read buffer

Implements BaseBuffer< T >.

◆ available()

template<typename T >
int available ( )
inlineoverridevirtual

provides the number of entries that are available to read

Implements BaseBuffer< T >.

◆ availableForWrite()

template<typename T >
int availableForWrite ( )
inlineoverridevirtual

provides the number of entries that are available to write

Implements BaseBuffer< T >.

◆ clearArray()

template<typename T >
virtual int clearArray ( int  len)
inlinevirtualinherited

Removes the next len entries.

Reimplemented in SingleBuffer< T >, SingleBuffer< int16_t >, and SingleBuffer< uint8_t >.

◆ isFull()

template<typename T >
bool isFull ( )
inlineoverridevirtual

checks if the buffer is full

Implements BaseBuffer< T >.

◆ peek()

template<typename T >
T peek ( )
inlineoverridevirtual

peeks the actual entry from the buffer

Implements BaseBuffer< T >.

◆ read()

template<typename T >
T read ( )
inlineoverridevirtual

reads a single value

Implements BaseBuffer< T >.

◆ readArray()

template<typename T >
int readArray ( T  data[],
int  len 
)
inlinevirtual

reads multiple values

Reimplemented from BaseBuffer< T >.

◆ reset()

template<typename T >
void reset ( )
inlineoverridevirtual

clears the buffer

Implements BaseBuffer< T >.

◆ setup()

template<typename T >
bool setup ( )
inlineprotected

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

◆ size()

template<typename T >
size_t size ( )
inlinevirtual

Implements BaseBuffer< T >.

◆ write()

template<typename T >
bool write ( T  data)
inlineoverridevirtual

write add an entry to the buffer

Implements BaseBuffer< T >.

◆ writeArray()

template<typename T >
int writeArray ( const T  data[],
int  len 
)
inlinevirtual

Fills the buffer data.

Reimplemented from BaseBuffer< T >.


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