Interrupt-safe, multicore-safe biftable buffer for libmad raw data.
More...
#include <BackgroundAudioBuffers.h>
|
uint8_t * | buffer () |
| Get access to internal buffer pointer (avoiding memcpy)
|
|
size_t | available () |
| Determine number of bytes that can be read.
|
|
size_t | availableForWrite () |
| Determine how much unused space is available in the buffer.
|
|
constexpr size_t | size () |
| Get total size of the statically allocated buffer.
|
|
size_t | write (const uint8_t *data, size_t cnt) |
| Copy a block of memory into the buffer. Will not block.
|
|
size_t | write0 (size_t cnt) |
| 0-fill a portion of the buffer
|
|
void | shiftUp (size_t cnt) |
| Invalidate a portion of buffer and shift remaining data up.
|
|
void | flush () |
| Throw out any data in the buffer.
|
|
template<size_t bytes>
class RawDataBuffer< bytes >
Interrupt-safe, multicore-safe biftable buffer for libmad raw data.
- Template Parameters
-
bytes | Number of bytes to statically allocate for the raw buffer |
◆ available()
Determine number of bytes that can be read.
- Returns
- Available bytes
◆ availableForWrite()
Determine how much unused space is available in the buffer.
- Returns
- Free bytes
◆ buffer()
Get access to internal buffer pointer (avoiding memcpy)
- Returns
- Buffer pointer
◆ shiftUp()
Invalidate a portion of buffer and shift remaining data up.
Decoders need to be able to read an entier frame's worth of raw data from a contiguous memory region. They all operate by using the internal buffer pointer plus an offset, which they track, to avoid having to shift old data out every single frame (i.e. avoiding memcpy
s). When they have accumulated enough of a virtual shift in their reading, they call shiftUp
to actually do the memory copy and invalidate that old portion of the buffer.
In general decoders want to call this function ad infrequently as possible.
◆ size()
Get total size of the statically allocated buffer.
- Returns
- Number of bytes in total
◆ write()
template<size_t bytes>
size_t RawDataBuffer< bytes >::write |
( |
const uint8_t * |
data, |
|
|
size_t |
cnt |
|
) |
| |
|
inline |
Copy a block of memory into the buffer. Will not block.
- Parameters
-
[in] | data | Raw data bytes |
[in] | cnt | Number of bytes to write |
- Returns
- Number of bytes actually written
◆ write0()
0-fill a portion of the buffer
- Parameters
-
[in] | cnt | Number of 0 bytes to write |
- Returns
- Number of bytes actually written
The documentation for this class was generated from the following file: