arduino-audio-tools
Loading...
Searching...
No Matches
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)
 ~BufferRTOS ()
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
virtual int bufferCountEmpty ()
 Provides the number of entries that are available to write: -1 does not apply.
virtual int bufferCountFilled ()
 Provides the number of entries that are available to read: -1 does not apply.
void clear ()
 same as reset
virtual int clearArray (int len)
 Removes the next len entries.
virtual void flush ()
virtual float freePercent ()
 Returns the free space of the buffer in %.
bool isEmpty ()
bool isFull () override
 checks if the buffer is full
virtual float levelPercent ()
 Returns the level of the buffer in %.
 operator bool ()
bool peek (T &result) override
 peeks the actual entry from the buffer
bool read (T &result) override
 reads a single value
int readArray (T data[], int len)
 reads multiple values
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 ()

Protected Attributes

size_t current_size_bytes = 0
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

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.

Note
Supported by all ESP32 FreeRTOS platforms
Author
Phil Schatzmann
Template Parameters
T

Constructor & Destructor Documentation

◆ BufferRTOS()

template<typename T>
BufferRTOS ( size_t streamBufferSize,
size_t xTriggerLevel = 1,
TickType_t writeMaxWait = portMAX_DELAY,
TickType_t readMaxWait = portMAX_DELAY,
Allocator & allocator = DefaultAllocator )
inline

◆ ~BufferRTOS()

template<typename T>
~BufferRTOS ( )
inline

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 >.

◆ bufferCountEmpty()

virtual int bufferCountEmpty ( )
inlinevirtualinherited

Provides the number of entries that are available to write: -1 does not apply.

Reimplemented in NBuffer< T >, SynchronizedNBufferRTOST< T >, and SynchronizedNBufferZephyrT< T >.

◆ bufferCountFilled()

virtual int bufferCountFilled ( )
inlinevirtualinherited

Provides the number of entries that are available to read: -1 does not apply.

Reimplemented in NBuffer< T >, SynchronizedNBufferRTOST< T >, and SynchronizedNBufferZephyrT< T >.

◆ clear()

void clear ( )
inlineinherited

same as reset

◆ clearArray()

virtual int clearArray ( int len)
inlinevirtualinherited

Removes the next len entries.

Reimplemented in SingleBuffer< T >.

◆ end()

template<typename T>
void end ( )
inlineprotected

Release resurces: call resize to restart again.

◆ flush()

virtual void flush ( )
inlinevirtualinherited

Submit any partially-filled write buffer so the reader can access it. Only meaningful for NBuffer-style block pools; no-op for ring buffers.

Reimplemented in NBuffer< T >.

◆ freePercent()

virtual float freePercent ( )
inlinevirtualinherited

Returns the free space of the buffer in %.

◆ isEmpty()

template<typename T>
bool isEmpty ( )
inline

◆ isFull()

template<typename T>
bool isFull ( )
inlineoverridevirtual

checks if the buffer is full

Reimplemented from BaseBuffer< T >.

◆ levelPercent()

virtual float levelPercent ( )
inlinevirtualinherited

Returns the level of the buffer in %.

◆ operator bool()

template<typename T>
operator bool ( )
inline

◆ peek()

template<typename T>
bool peek ( T & result)
inlineoverridevirtual

peeks the actual entry from the buffer

Implements BaseBuffer< T >.

◆ read()

template<typename T>
bool read ( T & result)
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 >.

◆ resize()

template<typename T>
bool resize ( size_t size)
inlinevirtual

Re-Allocats the memory and the queue.

Reimplemented from BaseBuffer< T >.

◆ setReadFromISR()

template<typename T>
void setReadFromISR ( bool active)
inline

◆ setReadMaxWait()

template<typename T>
void setReadMaxWait ( TickType_t ticks)
inline

◆ setup()

template<typename T>
bool setup ( )
inlineprotected

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

◆ setWriteFromISR()

template<typename T>
void setWriteFromISR ( bool active)
inline

◆ setWriteMaxWait()

template<typename T>
void setWriteMaxWait ( TickType_t ticks)
inline

◆ 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 >.

◆ writeArrayOverwrite()

virtual int writeArrayOverwrite ( const T data[],
int len )
inlinevirtualinherited

Fills the buffer data and overwrites the oldest data if the buffer is full.

Member Data Documentation

◆ current_size_bytes

template<typename T>
size_t current_size_bytes = 0
protected

◆ p_allocator

template<typename T>
Allocator* p_allocator = nullptr
protected

◆ p_data

template<typename T>
uint8_t* p_data = nullptr
protected

◆ read_from_isr

template<typename T>
bool read_from_isr = false
protected

◆ readWait

template<typename T>
int readWait = portMAX_DELAY
protected

◆ static_stream_buffer

template<typename T>
StaticStreamBuffer_t static_stream_buffer
protected

◆ trigger_level

template<typename T>
size_t trigger_level = 0
protected

◆ write_from_isr

template<typename T>
bool write_from_isr = false
protected

◆ writeWait

template<typename T>
int writeWait = portMAX_DELAY
protected

◆ xHigherPriorityTaskWoken

template<typename T>
BaseType_t xHigherPriorityTaskWoken = pdFALSE
protected

◆ xStreamBuffer

template<typename T>
StreamBufferHandle_t xStreamBuffer = nullptr
protected

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