Buffer implementation which provides the same blocking, thread-safe semantics as BufferRTOS (ESP32/STM32) and BufferZephyr, for platforms that have no native blocking stream buffer primitive - built on a SpinLock-protected RingBuffer plus a delay(1) polling wait loop.
More...
#include <BufferBlocking.h>
|
| | BufferBlocking (size_t streamBufferSize, size_t xTriggerLevel=1, TickType_t writeMaxWait=UINT32_MAX, TickType_t readMaxWait=UINT32_MAX, Allocator &allocator=DefaultAllocator) |
| |
| 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
|
| |
| virtual int | bufferCountEmpty () |
| | Provides the number of entries that are available to write: -1 does not apply.
|
| |
| virtual int | bufferCountFilled () |
| | Provides the number of entries that are available to read: -1 does not apply.
|
| |
| void | clear () |
| | same as reset
|
| |
| virtual int | clearArray (int len) |
| | Removes the next len entries.
|
| |
| virtual void | flush () |
| |
| virtual float | freePercent () |
| | Returns the free space of the buffer in %.
|
| |
| bool | isEmpty () |
| |
| bool | isFull () override |
| | checks if the buffer is full
|
| |
| virtual float | levelPercent () |
| | Returns the level of the buffer in %.
|
| |
| | operator bool () |
| |
| 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
|
| |
| bool | resize (size_t size) |
| | Re-Allocates the memory of the ring buffer.
|
| |
| virtual bool | resize (size_t size, int count) |
| | Resize the buffer by indicating the size and count (allocated bytes = size * count)
|
| |
| void | setReadFromISR (bool active) |
| |
| void | setReadMaxWait (TickType_t ticks) |
| |
| void | setWriteFromISR (bool active) |
| |
| void | setWriteMaxWait (TickType_t ticks) |
| |
| 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.
|
| |
template<typename T>
class audio_tools::BufferBlocking< T >
Buffer implementation which provides the same blocking, thread-safe semantics as BufferRTOS (ESP32/STM32) and BufferZephyr, for platforms that have no native blocking stream buffer primitive - built on a SpinLock-protected RingBuffer plus a delay(1) polling wait loop.
- Note
- Supported on any platform providing MutexBase, delay() and millis() (e.g. Desktop, RP2040 without FreeRTOS)
- Author
- Phil Schatzmann
- Copyright
- GPLv3
- Template Parameters
-
◆ BufferBlocking()
◆ address()
returns the address of the start of the physical read buffer
Implements BaseBuffer< T >.
◆ available()
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 >.
◆ bufferCountEmpty()
| virtual int bufferCountEmpty |
( |
| ) |
|
|
inlinevirtualinherited |
◆ bufferCountFilled()
| virtual int bufferCountFilled |
( |
| ) |
|
|
inlinevirtualinherited |
◆ clear()
◆ clearArray()
| virtual int clearArray |
( |
int |
len | ) |
|
|
inlinevirtualinherited |
◆ flush()
Submit any partially-filled write buffer so the reader can access it. Only meaningful for NBuffer-style block pools; no-op for ring buffers.
Reimplemented in NBuffer< T >.
◆ freePercent()
| virtual float freePercent |
( |
| ) |
|
|
inlinevirtualinherited |
Returns the free space of the buffer in %.
◆ isEmpty()
◆ isFull()
◆ isTimeLeft()
template<typename T >
| bool isTimeLeft |
( |
uint32_t |
start, |
|
|
TickType_t |
maxWait |
|
) |
| |
|
inlineprotected |
◆ levelPercent()
| virtual float levelPercent |
( |
| ) |
|
|
inlinevirtualinherited |
Returns the level of the buffer in %.
◆ operator bool()
◆ peek()
◆ read()
◆ readArray()
template<typename T >
| int readArray |
( |
T |
data[], |
|
|
int |
len |
|
) |
| |
|
inlinevirtual |
◆ reset()
◆ resize() [1/2]
template<typename T >
| bool resize |
( |
size_t |
size | ) |
|
|
inlinevirtual |
Re-Allocates the memory of the ring buffer.
Reimplemented from BaseBuffer< T >.
◆ resize() [2/2]
| virtual bool resize |
( |
size_t |
size, |
|
|
int |
count |
|
) |
| |
|
inlinevirtualinherited |
◆ setReadFromISR()
template<typename T >
| void setReadFromISR |
( |
bool |
active | ) |
|
|
inline |
◆ setReadMaxWait()
◆ setWriteFromISR()
template<typename T >
| void setWriteFromISR |
( |
bool |
active | ) |
|
|
inline |
◆ setWriteMaxWait()
◆ size()
◆ write()
◆ writeArray()
template<typename T >
| int writeArray |
( |
const T |
data[], |
|
|
int |
len |
|
) |
| |
|
inlinevirtual |
◆ writeArrayOverwrite()
| virtual int writeArrayOverwrite |
( |
const T |
data[], |
|
|
int |
len |
|
) |
| |
|
inlinevirtualinherited |
Fills the buffer data and overwrites the oldest data if the buffer is full.
◆ buffer
◆ mutex
◆ readWait
◆ writeWait
The documentation for this class was generated from the following file: