arduino-audio-tools
|
Wrapper class that can turn any Buffer into a thread save implementation. More...
#include <SynchronizedBuffer.h>
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 | |
virtual bool | resize (int bytes) |
Resizes the buffer if supported: returns false if not supported. | |
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 Attributes | |
bool | is_sync_available = false |
BaseBuffer< T > * | p_buffer = nullptr |
MutexBase * | p_mutex = nullptr |
Wrapper class that can turn any Buffer into a thread save implementation.
T |
|
inlineoverridevirtual |
returns the address of the start of the physical read buffer
Implements BaseBuffer< T >.
|
inlineoverridevirtual |
provides the number of entries that are available to read
Implements BaseBuffer< T >.
|
inlineoverridevirtual |
provides the number of entries that are available to write
Implements BaseBuffer< T >.
|
inlinevirtualinherited |
Removes the next len entries.
Reimplemented in SingleBuffer< T >, SingleBuffer< float >, SingleBuffer< int16_t >, SingleBuffer< stsz_sample_size_t >, SingleBuffer< uint32_t >, and SingleBuffer< uint8_t >.
|
inlineoverridevirtual |
checks if the buffer is full
Reimplemented from BaseBuffer< T >.
|
inlineoverridevirtual |
peeks the actual entry from the buffer
Implements BaseBuffer< T >.
|
inlineoverridevirtual |
reads a single value
Implements BaseBuffer< T >.
|
inlinevirtual |
reads multiple values
Reimplemented from BaseBuffer< T >.
|
inlineoverridevirtual |
clears the buffer
Implements BaseBuffer< T >.
|
inlinevirtualinherited |
Resizes the buffer if supported: returns false if not supported.
Reimplemented in NBuffer< T >, NBuffer< Frame >, NBuffer< uint8_t >, RingBuffer< T >, RingBuffer< int16_t >, RingBuffer< Sample >, RingBuffer< uint16_t >, RingBuffer< uint8_t >, DynamicMultiBuffer< T, BufferType >, VariableSpeedRingBufferSimple< T >, VariableSpeedRingBuffer180< T >, VariableSpeedRingBuffer< T >, VariableSpeedRingBuffer< int16_t >, SingleBuffer< T >, SingleBuffer< float >, SingleBuffer< int16_t >, SingleBuffer< stsz_sample_size_t >, SingleBuffer< uint32_t >, SingleBuffer< uint8_t >, RingBufferFile< File, T >, and RedisBuffer< T >.
|
inlinevirtual |
Implements BaseBuffer< T >.
|
inlineoverridevirtual |
write add an entry to the buffer
Implements BaseBuffer< T >.
|
inlinevirtual |
Fills the buffer data.
Reimplemented from BaseBuffer< T >.