arduino-audio-tools
Loading...
Searching...
No Matches
NBufferExt< T > Class Template Referenceabstract

A NBufferExt is a subclass of NBuffer which allows to use a direct access API to the BaseBuffer. More...

#include <CodecOpusOgg.h>

Inheritance diagram for NBufferExt< T >:
NBuffer< uint8_t > NBuffer< uint8_t > BaseBuffer< uint8_t > BaseBuffer< uint8_t > BaseBuffer< uint8_t > BaseBuffer< uint8_t >

Public Member Functions

 NBufferExt (int size, int count)
 NBufferExt (int size, int count)
uint8_t * address ()
 returns the address of the start of the actual physical read buffer
int available ()
 determines the available entries for the current read buffer
int availableForWrite ()
 determines the available entries for the write buffer
virtual int bufferCountEmpty ()
 Provides the number of entries that are available to write.
virtual 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 ()
virtual float freePercent ()
 Returns the free space of the buffer in %.
SingleBuffer< T > * getBuffer (int id)
 Provides the buffer with the indicated id.
SingleBuffer< T > * getBuffer (int id)
 Provides the buffer with the indicated id.
bool isEmpty ()
bool isFull ()
 checks if the buffer is full
virtual float levelPercent ()
 Returns the level of the buffer in %.
bool peek (uint8_t &result) override
 peeks the actual entry from the buffer
virtual bool peek (uint8_t &result)=0
 peeks the actual entry from the buffer
bool read (uint8_t &result) override
 reads an entry from the buffer
virtual bool read (uint8_t &result)=0
 reads a single value
virtual int readArray (uint8_t data[], int len)
 reads multiple values
int readArray (uint8_t data[], int len) override
SingleBuffer< T > * readEnd ()
SingleBuffer< T > * readEnd ()
void reset ()
 resets all buffers
virtual bool resize (size_t bytes)
 Resize the buffer to the next multiple of buffer size.
unsigned long sampleRate ()
 provides the actual sample rate
size_t size ()
 Provides the total capacity (=buffer size * buffer count).
bool write (uint8_t data)
 write add an entry to the buffer
virtual bool write (uint8_t data)=0
 write add an entry to the buffer
virtual int writeArray (const uint8_t data[], int len)
 Fills the buffer data.
virtual int writeArrayOverwrite (const uint8_t data[], int len)
 Fills the buffer data and overwrites the oldest data if the buffer is full.
SingleBuffer< T > * writeEnd ()
SingleBuffer< T > * writeEnd ()

Protected Member Functions

virtual bool addAvailableBuffer (BaseBuffer< uint8_t > *buffer)
virtual bool addFilledBuffer (BaseBuffer< uint8_t > *buffer)
void freeMemory ()
virtual BaseBuffer< uint8_t > * getNextAvailableBuffer ()
virtual BaseBuffer< uint8_t > * getNextFilledBuffer ()
void resetCurrent ()

Protected Attributes

BaseBuffer< uint8_t > * actual_read_buffer
BaseBuffer< uint8_t > * actual_write_buffer
QueueFromVector< BaseBuffer< uint8_t > * > available_buffers
size_t buffer_count
int buffer_size
QueueFromVector< BaseBuffer< uint8_t > * > filled_buffers
unsigned long sample_count
unsigned long start_time

Detailed Description

template<typename T = uint8_t>
class audio_tools::audio_tools::NBufferExt< T >

A NBufferExt is a subclass of NBuffer which allows to use a direct access API to the BaseBuffer.

Template Parameters
Tbuffered data type

Constructor & Destructor Documentation

◆ NBufferExt() [1/2]

template<typename T = uint8_t>
NBufferExt ( int size,
int count )
inline

◆ NBufferExt() [2/2]

template<typename T = uint8_t>
NBufferExt ( int size,
int count )
inline

Member Function Documentation

◆ addAvailableBuffer()

virtual bool addAvailableBuffer ( BaseBuffer< uint8_t > * buffer)
inlineprotectedvirtualinherited

◆ addFilledBuffer()

virtual bool addFilledBuffer ( BaseBuffer< uint8_t > * buffer)
inlineprotectedvirtualinherited

◆ address()

uint8_t * address ( )
inlinevirtualinherited

returns the address of the start of the actual physical read buffer

Implements BaseBuffer< uint8_t >.

◆ available()

int available ( )
inlinevirtualinherited

determines the available entries for the current read buffer

Implements BaseBuffer< uint8_t >.

◆ availableForWrite()

int availableForWrite ( )
inlinevirtualinherited

determines the available entries for the write buffer

Implements BaseBuffer< uint8_t >.

◆ bufferCountEmpty()

virtual int bufferCountEmpty ( )
inlinevirtualinherited

Provides the number of entries that are available to write.

Reimplemented from BaseBuffer< uint8_t >.

Reimplemented in SynchronizedNBufferRTOST< uint8_t >, and SynchronizedNBufferZephyrT< uint8_t >.

◆ bufferCountFilled()

virtual int bufferCountFilled ( )
inlinevirtualinherited

Provides the number of entries that are available to read.

Reimplemented from BaseBuffer< uint8_t >.

Reimplemented in SynchronizedNBufferRTOST< uint8_t >, and SynchronizedNBufferZephyrT< uint8_t >.

◆ clear()

void clear ( )
inlineinherited

same as reset

◆ clearArray()

virtual int clearArray ( int len)
inlinevirtualinherited

Removes the next len entries.

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

◆ freeMemory()

void freeMemory ( )
inlineprotectedinherited

◆ freePercent()

virtual float freePercent ( )
inlinevirtualinherited

Returns the free space of the buffer in %.

◆ getBuffer() [1/2]

template<typename T = uint8_t>
SingleBuffer< T > * getBuffer ( int id)
inline

Provides the buffer with the indicated id.

◆ getBuffer() [2/2]

template<typename T = uint8_t>
SingleBuffer< T > * getBuffer ( int id)
inline

Provides the buffer with the indicated id.

◆ getNextAvailableBuffer()

virtual BaseBuffer< uint8_t > * getNextAvailableBuffer ( )
inlineprotectedvirtualinherited

◆ getNextFilledBuffer()

virtual BaseBuffer< uint8_t > * getNextFilledBuffer ( )
inlineprotectedvirtualinherited

◆ isEmpty()

bool isEmpty ( )
inlineinherited

◆ isFull()

bool isFull ( )
inlinevirtualinherited

checks if the buffer is full

Reimplemented from BaseBuffer< uint8_t >.

◆ levelPercent()

virtual float levelPercent ( )
inlinevirtualinherited

Returns the level of the buffer in %.

◆ peek() [1/2]

bool peek ( uint8_t & result)
inlineoverridevirtualinherited

peeks the actual entry from the buffer

Implements BaseBuffer< uint8_t >.

◆ peek() [2/2]

virtual bool peek ( uint8_t & result)
pure virtualinherited

peeks the actual entry from the buffer

◆ read() [1/2]

bool read ( uint8_t & result)
inlineoverridevirtualinherited

reads an entry from the buffer

Implements BaseBuffer< uint8_t >.

◆ read() [2/2]

virtual bool read ( uint8_t & result)
pure virtualinherited

reads a single value

◆ readArray() [1/2]

virtual int readArray ( uint8_t data[],
int len )
inlinevirtualinherited

reads multiple values

◆ readArray() [2/2]

int readArray ( uint8_t 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< uint8_t >.

◆ readEnd() [1/2]

template<typename T = uint8_t>
SingleBuffer< T > * readEnd ( )
inline

Alternative interface using address: provides access to the next read buffer

◆ readEnd() [2/2]

template<typename T = uint8_t>
SingleBuffer< T > * readEnd ( )
inline

Alternative interface using address: provides access to the next read buffer

◆ reset()

void reset ( )
inlinevirtualinherited

resets all buffers

Implements BaseBuffer< uint8_t >.

◆ resetCurrent()

void resetCurrent ( )
inlineprotectedinherited

◆ resize()

virtual bool resize ( size_t bytes)
inlinevirtualinherited

Resize the buffer to the next multiple of buffer size.

Reimplemented from BaseBuffer< uint8_t >.

◆ sampleRate()

unsigned long sampleRate ( )
inlineinherited

provides the actual sample rate

◆ size()

size_t size ( )
inlinevirtualinherited

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

Implements BaseBuffer< uint8_t >.

Reimplemented in SynchronizedNBufferRTOST< uint8_t >, and SynchronizedNBufferZephyrT< uint8_t >.

◆ write() [1/2]

bool write ( uint8_t data)
inlinevirtualinherited

write add an entry to the buffer

Implements BaseBuffer< uint8_t >.

◆ write() [2/2]

virtual bool write ( uint8_t data)
pure virtualinherited

write add an entry to the buffer

◆ writeArray()

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

Fills the buffer data.

◆ writeArrayOverwrite()

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

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

◆ writeEnd() [1/2]

template<typename T = uint8_t>
SingleBuffer< T > * writeEnd ( )
inline

Alternative interface: Provides access to the next write buffer

◆ writeEnd() [2/2]

template<typename T = uint8_t>
SingleBuffer< T > * writeEnd ( )
inline

Alternative interface: Provides access to the next write buffer

Member Data Documentation

◆ actual_read_buffer

BaseBuffer< uint8_t > * actual_read_buffer
protectedinherited

◆ actual_write_buffer

BaseBuffer< uint8_t > * actual_write_buffer
protectedinherited

◆ available_buffers

QueueFromVector< BaseBuffer< uint8_t > * > available_buffers
protectedinherited

◆ buffer_count

size_t buffer_count
protectedinherited

◆ buffer_size

int buffer_size
protectedinherited

◆ filled_buffers

QueueFromVector< BaseBuffer< uint8_t > * > filled_buffers
protectedinherited

◆ sample_count

unsigned long sample_count
protectedinherited

◆ start_time

unsigned long start_time
protectedinherited

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