AV module

AudioBuffer

FIFO buffer for queuing audio samples between encoding stages.

AudioBuffer

#include <icy/av/audiobuffer.h>

FIFO buffer for queuing audio samples between encoding stages.

Public Attributes

ReturnNameDescription
AVAudioFifo *fifoUnderlying FFmpeg audio FIFO handle.

fifo

AVAudioFifo * fifo

Underlying FFmpeg audio FIFO handle.

Public Methods

ReturnNameDescription
AudioBuffer
AudioBufferDeleted constructor.
AudioBufferDeleted constructor.
voidallocAllocate the audio FIFO buffer.
voidresetDiscard all samples currently held in the FIFO without freeing the buffer.
voidcloseFree the underlying AVAudioFifo buffer.
voidwriteWrite samples into the FIFO buffer.
boolreadRead samples from the FIFO buffer.
intavailable constReturn the number of samples per channel currently available in the FIFO.

AudioBuffer

AudioBuffer()

AudioBuffer

AudioBuffer(const AudioBuffer &) = delete

Deleted constructor.


AudioBuffer

AudioBuffer(AudioBuffer &&) = delete

Deleted constructor.


alloc

void alloc(const std::string & sampleFmt, int channels, int numSamples)

Allocate the audio FIFO buffer.

Parameters

  • sampleFmt The sample format name (e.g. "s16", "fltp").

  • channels The number of audio channels.

  • numSamples The initial buffer capacity in samples per channel.


reset

void reset()

Discard all samples currently held in the FIFO without freeing the buffer.


close

void close()

Free the underlying AVAudioFifo buffer.


write

void write(void ** samples, int numSamples)

Write samples into the FIFO buffer.

Parameters

  • samples Array of per-channel sample buffers.

  • numSamples The number of samples per channel to write.


read

bool read(void ** samples, int numSamples)

Read samples from the FIFO buffer.

Parameters

  • samples Array of per-channel sample buffers to fill.

  • numSamples The number of samples per channel to read.

Returns

True if enough samples were available.


available

const

int available() const

Return the number of samples per channel currently available in the FIFO.

Returns

The number of available samples, or zero if the buffer is not allocated.