arduino-audio-tools
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
SynchronizedNBufferZephyrT< T > Class Template Reference

NBuffer using Zephyr queues for available and filled buffers. More...

#include <SynchronizedNBufferZephyr.h>

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

Public Member Functions

 SynchronizedNBufferZephyrT (int bufferSize, int bufferCount, int writeMaxWait=1000, int readMaxWait=1000)
 
 ~SynchronizedNBufferZephyrT ()
 
Taddress ()
 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.
 
void flush ()
 
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
 
int readArray (T data[], int len) override
 
void reset ()
 resets all buffers
 
bool resize (size_t bufferSize, int bufferCount)
 Resize the buffers by defining a new buffer size and buffer count.
 
virtual bool resize (size_t bytes)
 Resizes the buffer if supported: returns false if not supported.
 
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
 
BaseBuffer< T > * actual_write_buffer
 
QueueZephyr< BaseBuffer< T > * > available_buffers {0, 1000 , 0}
 
int buffer_count = 0
 
int buffer_size = 0
 
QueueZephyr< BaseBuffer< T > * > filled_buffers {0, 1000 , 0}
 
size_t max_size = 0
 
size_t read_max_wait = 1000
 
unsigned long sample_count
 
unsigned long start_time
 
size_t write_max_wait = 1000
 

Detailed Description

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

NBuffer using Zephyr queues for available and filled buffers.

Note
Supported by all Zephyr platforms

Constructor & Destructor Documentation

◆ SynchronizedNBufferZephyrT()

template<typename T >
SynchronizedNBufferZephyrT ( int  bufferSize,
int  bufferCount,
int  writeMaxWait = 1000,
int  readMaxWait = 1000 
)
inline

◆ ~SynchronizedNBufferZephyrT()

template<typename T >
~SynchronizedNBufferZephyrT ( )
inline

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()

T * address ( )
inlinevirtualinherited

returns the address of the start of the phsical read buffer

Implements BaseBuffer< T >.

◆ available()

int available ( )
inlinevirtualinherited

determines the available entries for the current read buffer

Implements BaseBuffer< T >.

◆ availableForWrite()

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

◆ cleanup()

template<typename T >
void cleanup ( )
inlineprotected

Removes all allocated buffers.

◆ clear()

void clear ( )
inlineinherited

same as reset

◆ clearArray()

virtual int clearArray ( int  len)
inlinevirtualinherited

Removes the next len entries.

Reimplemented in SingleBuffer< T >.

◆ flush()

void flush ( )
inlinevirtualinherited

Submit the partially-filled write buffer to the filled queue so the reader can access it immediately. Call after writeArray() when the writer won't add more data to the current block for a while.

Reimplemented from BaseBuffer< T >.

◆ freeMemory()

void freeMemory ( )
inlineprotectedinherited

◆ getNextAvailableBuffer()

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

Reimplemented from NBuffer< T >.

◆ getNextFilledBuffer()

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

Reimplemented from NBuffer< T >.

◆ isEmpty()

bool isEmpty ( )
inlineinherited

◆ isFull()

bool isFull ( )
inlinevirtualinherited

checks if the buffer is full

Reimplemented from BaseBuffer< T >.

◆ levelPercent()

virtual float levelPercent ( )
inlinevirtualinherited

Returns the level of the buffer in %.

◆ peek()

bool peek ( T &  result)
inlineoverridevirtualinherited

peeks the actual entry from the buffer

Implements BaseBuffer< T >.

◆ read()

bool read ( T &  result)
inlineoverridevirtualinherited

reads an entry from the buffer

Implements BaseBuffer< T >.

◆ readArray()

int readArray ( data[],
int  len 
)
inlineoverridevirtualinherited

Reads up to len entries, spanning across multiple blocks. BaseBuffer::readArray stops at the first block boundary because it calls available() once. This override keeps reading across blocks.

Reimplemented from BaseBuffer< T >.

◆ reset()

void reset ( )
inlinevirtualinherited

resets all buffers

Implements BaseBuffer< T >.

◆ resetCurrent()

void resetCurrent ( )
inlineprotectedinherited

◆ resize() [1/2]

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

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

Reimplemented from NBuffer< T >.

◆ resize() [2/2]

virtual bool resize ( size_t  bytes)
inlinevirtualinherited

Resizes the buffer if supported: returns false if not supported.

Reimplemented from BaseBuffer< T >.

◆ sampleRate()

unsigned long sampleRate ( )
inlineinherited

provides the actual sample rate

◆ setReadMaxWait()

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

◆ setWriteMaxWait()

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

◆ size()

template<typename T >
size_t size ( )
inlinevirtual

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

Reimplemented from NBuffer< T >.

◆ write()

bool write ( data)
inlinevirtualinherited

write add an entry to the buffer

Implements BaseBuffer< T >.

◆ writeArray()

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

◆ 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

◆ actual_read_buffer

BaseBuffer<T>* actual_read_buffer
protectedinherited

◆ actual_write_buffer

BaseBuffer<T>* actual_write_buffer
protectedinherited

◆ available_buffers

template<typename T >
QueueZephyr<BaseBuffer<T> *> available_buffers {0, 1000 , 0}
protected

◆ buffer_count

template<typename T >
int buffer_count = 0
protected

◆ buffer_size

template<typename T >
int buffer_size = 0
protected

◆ filled_buffers

template<typename T >
QueueZephyr<BaseBuffer<T> *> filled_buffers {0, 1000 , 0}
protected

◆ max_size

template<typename T >
size_t max_size = 0
protected

◆ read_max_wait

template<typename T >
size_t read_max_wait = 1000
protected

◆ sample_count

unsigned long sample_count
protectedinherited

◆ start_time

unsigned long start_time
protectedinherited

◆ write_max_wait

template<typename T >
size_t write_max_wait = 1000
protected

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