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
SynchronizedBuffer< T > Class Template Reference

Wrapper class that can turn any Buffer into a thread save implementation. More...

#include <SynchronizedBuffer.h>

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

Public Member Functions

 SynchronizedBuffer (BaseBuffer< T > &buffer, MutexBase &mutex, bool syncAvailable=false)
 
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 %.
 
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
 
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 setWritePos (int pos)
 

Protected Attributes

bool is_sync_available = false
 
friend NBuffer< T >
 
BaseBuffer< T > * p_buffer = nullptr
 
MutexBasep_mutex = nullptr
 

Detailed Description

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

Wrapper class that can turn any Buffer into a thread save implementation.

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

Reimplemented from BaseBuffer< T >.

◆ 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 ( data[],
int  len 
)
inlinevirtual

reads multiple values

Reimplemented from BaseBuffer< T >.

◆ reset()

template<typename T >
void reset ( )
inlineoverridevirtual

clears the buffer

Implements BaseBuffer< T >.

◆ size()

template<typename T >
size_t size ( )
inlinevirtual

Implements BaseBuffer< T >.

◆ write()

template<typename T >
bool write ( 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: