BackgroundAudio 1.3.3
Loading...
Searching...
No Matches
Public Member Functions | List of all members
RawDataBuffer< bytes > Class Template Reference

Interrupt-safe, multicore-safe biftable buffer for libmad raw data. More...

#include <BackgroundAudioBuffers.h>

Public Member Functions

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.
 

Detailed Description

template<size_t bytes>
class RawDataBuffer< bytes >

Interrupt-safe, multicore-safe biftable buffer for libmad raw data.

Template Parameters
bytesNumber of bytes to statically allocate for the raw buffer

Member Function Documentation

◆ available()

template<size_t bytes>
size_t RawDataBuffer< bytes >::available ( )
inline

Determine number of bytes that can be read.

Returns
Available bytes

◆ availableForWrite()

template<size_t bytes>
size_t RawDataBuffer< bytes >::availableForWrite ( )
inline

Determine how much unused space is available in the buffer.

Returns
Free bytes

◆ buffer()

template<size_t bytes>
uint8_t * RawDataBuffer< bytes >::buffer ( )
inline

Get access to internal buffer pointer (avoiding memcpy)

Returns
Buffer pointer

◆ shiftUp()

template<size_t bytes>
void RawDataBuffer< bytes >::shiftUp ( size_t  cnt)
inline

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

template<size_t bytes>
constexpr size_t RawDataBuffer< bytes >::size ( )
inlineconstexpr

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]dataRaw data bytes
[in]cntNumber of bytes to write
Returns
Number of bytes actually written

◆ write0()

template<size_t bytes>
size_t RawDataBuffer< bytes >::write0 ( size_t  cnt)
inline

0-fill a portion of the buffer

Parameters
[in]cntNumber of 0 bytes to write
Returns
Number of bytes actually written

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