arduino-audio-tools
All Classes Namespaces Files Functions Variables Typedefs Enumerations Friends Modules Pages
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
SynchronizedNBufferRTOST< T > Class Template Reference

NBuffer which uses some RTOS queues to manage the available and filled buffers. More...

#include <SynchronizedNBufferRTOS.h>

Inheritance diagram for SynchronizedNBufferRTOST< T >:
NBuffer< T > BaseBuffer< T >

Public Member Functions

 SynchronizedNBufferRTOST (int bufferSize, int bufferCount, int writeMaxWait=portMAX_DELAY, int readMaxWait=portMAX_DELAY)
 
T * address ()
 returns the address of the start of the phsical read buffer
 
int available ()
 determines the available entries for the current read buffer
 
int availableForWrite ()
 determines the available entries for the write buffer
 
int bufferCountEmpty ()
 Provides the number of entries that are available to write.
 
int bufferCountFilled ()
 Provides the number of entries that are available to read.
 
void clear ()
 same as reset
 
virtual int clearArray (int len)
 Removes the next len entries.
 
bool isEmpty ()
 
bool isFull ()
 checks if the buffer is full
 
virtual float levelPercent ()
 Returns the level of the buffer in %.
 
bool peek (T &result) override
 peeks the actual entry from the buffer
 
bool read (T &result) override
 reads an entry from the buffer
 
virtual int readArray (T data[], int len)
 reads multiple values
 
void reset ()
 resets all buffers
 
void resize (int bufferSize, int bufferCount)
 Resize the buffers by defining a new buffer size and buffer count.
 
unsigned long sampleRate ()
 provides the actual sample rate
 
void setReadMaxWait (TickType_t ticks)
 
void setWriteMaxWait (TickType_t ticks)
 
size_t size ()
 Provides the total capacity (=buffer size * buffer count)
 
bool write (T data)
 write add an entry to the buffer
 
virtual 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

bool addAvailableBuffer (BaseBuffer< T > *buffer)
 
bool addFilledBuffer (BaseBuffer< T > *buffer)
 
void cleanup ()
 Removes all allocated buffers.
 
void freeMemory ()
 
BaseBuffer< T > * getNextAvailableBuffer ()
 
BaseBuffer< T > * getNextFilledBuffer ()
 
void resetCurrent ()
 

Protected Attributes

BaseBuffer< T > * actual_read_buffer = nullptr
 
BaseBuffer< T > * actual_write_buffer = nullptr
 
QueueRTOS< BaseBuffer< T > * > available_buffers {0,portMAX_DELAY,0}
 
int buffer_count = 0
 
int buffer_size = 0
 
QueueRTOS< BaseBuffer< T > * > filled_buffers {0,portMAX_DELAY,0}
 
size_t max_size
 
size_t read_max_wait
 
unsigned long sample_count = 0
 
unsigned long start_time = 0
 
size_t write_max_wait
 

Detailed Description

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

NBuffer which uses some RTOS queues to manage the available and filled buffers.

Template Parameters
T
COUNTnumber of buffers

Member Function Documentation

◆ addAvailableBuffer()

template<typename T >
bool addAvailableBuffer ( BaseBuffer< T > *  buffer)
inlineprotectedvirtual

Reimplemented from NBuffer< T >.

◆ addFilledBuffer()

template<typename T >
bool addFilledBuffer ( BaseBuffer< T > *  buffer)
inlineprotectedvirtual

Reimplemented from NBuffer< T >.

◆ address()

template<typename T >
T * address ( )
inlinevirtualinherited

returns the address of the start of the phsical read buffer

Implements BaseBuffer< T >.

◆ available()

template<typename T >
int available ( )
inlinevirtualinherited

determines the available entries for the current read buffer

Implements BaseBuffer< T >.

◆ availableForWrite()

template<typename T >
int availableForWrite ( )
inlinevirtualinherited

determines the available entries for the write buffer

Implements BaseBuffer< T >.

◆ bufferCountEmpty()

template<typename T >
int bufferCountEmpty ( )
inlinevirtual

Provides the number of entries that are available to write.

Reimplemented from NBuffer< T >.

◆ bufferCountFilled()

template<typename T >
int bufferCountFilled ( )
inlinevirtual

Provides the number of entries that are available to read.

Reimplemented from NBuffer< 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 >.

◆ getNextAvailableBuffer()

template<typename T >
BaseBuffer< T > * getNextAvailableBuffer ( )
inlineprotectedvirtual

Reimplemented from NBuffer< T >.

◆ getNextFilledBuffer()

template<typename T >
BaseBuffer< T > * getNextFilledBuffer ( )
inlineprotectedvirtual

Reimplemented from NBuffer< T >.

◆ isFull()

template<typename T >
bool isFull ( )
inlinevirtualinherited

checks if the buffer is full

Reimplemented from BaseBuffer< T >.

◆ peek()

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

peeks the actual entry from the buffer

Implements BaseBuffer< T >.

◆ read()

template<typename T >
bool read ( T &  result)
inlineoverridevirtualinherited

reads an entry from the buffer

Implements BaseBuffer< T >.

◆ readArray()

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

◆ reset()

template<typename T >
void reset ( )
inlinevirtualinherited

resets all buffers

Implements BaseBuffer< T >.

◆ resize()

template<typename T >
void resize ( int  size,
int  count 
)
inlinevirtual

Resize the buffers by defining a new buffer size and buffer count.

Reimplemented from NBuffer< T >.

◆ size()

template<typename T >
size_t size ( )
inlinevirtual

Provides the total capacity (=buffer size * buffer count)

Reimplemented from NBuffer< T >.

◆ write()

template<typename T >
bool write ( data)
inlinevirtualinherited

write add an entry to the buffer

Implements BaseBuffer< T >.

◆ writeArray()

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

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