Loading...
Searching...
No Matches
Audio FIFO Buffer
libavutil » Audio related

## Typedefs

typedef struct AVAudioFifo | AVAudioFifo
| Context for an Audio FIFO Buffer.

## Functions

void | av_audio_fifo_free (AVAudioFifo *af)
| Free an AVAudioFifo.
AVAudioFifo * | av_audio_fifo_alloc (enum AVSampleFormat sample_fmt, int channels, int nb_samples)
| Allocate an AVAudioFifo.
av_warn_unused_result int | av_audio_fifo_realloc (AVAudioFifo *af, int nb_samples)
| Reallocate an AVAudioFifo.
int | av_audio_fifo_write (AVAudioFifo *af, void *const *data, int nb_samples)
| Write data to an AVAudioFifo.
int | av_audio_fifo_peek (const AVAudioFifo *af, void *const *data, int nb_samples)
| Peek data from an AVAudioFifo.
int | av_audio_fifo_peek_at (const AVAudioFifo *af, void *const *data, int nb_samples, int offset)
| Peek data from an AVAudioFifo.
int | av_audio_fifo_read (AVAudioFifo *af, void *const *data, int nb_samples)
| Read data from an AVAudioFifo.
int | av_audio_fifo_drain (AVAudioFifo *af, int nb_samples)
| Drain data from an AVAudioFifo.
void | av_audio_fifo_reset (AVAudioFifo *af)
| Reset the AVAudioFifo buffer.
int | av_audio_fifo_size (AVAudioFifo *af)
| Get the current number of samples in the AVAudioFifo available for reading.
int | av_audio_fifo_space (AVAudioFifo *af)
| Get the current number of samples in the AVAudioFifo available for writing.

## Detailed Description

## Typedef Documentation

## AVAudioFifo

typedef struct AVAudioFifo AVAudioFifo

Context for an Audio FIFO Buffer.

- Operates at the sample level rather than the byte level.
- Supports multiple channels with either planar or packed sample format.
- Automatic reallocation when writing to a full buffer.

Examples
  transcode_aac.c.

Definition at line 48 of file audio_fifo.h.

## Function Documentation

## av_audio_fifo_free()

void av_audio_fifo_free | ( | AVAudioFifo * | af | ) |

Free an AVAudioFifo.

Parameters

  af | AVAudioFifo to free

Examples
  transcode_aac.c.

Referenced by main().

## av_audio_fifo_alloc()

AVAudioFifo * av_audio_fifo_alloc | ( | enum AVSampleFormat | sample_fmt,
|  | int | channels,
|  | int | nb_samples )

Allocate an AVAudioFifo.

Parameters

  sample_fmt | sample format
  channels | number of channels
  nb_samples | initial allocation size, in samples

Returns
  newly allocated AVAudioFifo, or NULL on error

Examples
  transcode_aac.c.

Referenced by init_fifo().

## av_audio_fifo_realloc()

av_warn_unused_result int av_audio_fifo_realloc | ( | AVAudioFifo * | af,
|  | int | nb_samples )

Reallocate an AVAudioFifo.

Parameters

  af | AVAudioFifo to reallocate
  nb_samples | new allocation size, in samples

Returns
  0 if OK, or negative AVERROR code on failure

Examples
  transcode_aac.c.

Referenced by add_samples_to_fifo().

## av_audio_fifo_write()

int av_audio_fifo_write | ( | AVAudioFifo * | af,
|  | void *const * | data,
|  | int | nb_samples )

Write data to an AVAudioFifo.

The AVAudioFifo will be reallocated automatically if the available space is less than nb_samples.

See also
  enum AVSampleFormat The documentation for AVSampleFormat describes the data layout.

Parameters

  af | AVAudioFifo to write to
  data | audio data plane pointers
  nb_samples | number of samples to write

Returns
  number of samples actually written, or negative AVERROR code on failure. If successful, the number of samples actually written will always be nb_samples.

Examples
  transcode_aac.c.

Referenced by add_samples_to_fifo().

## av_audio_fifo_peek()

int av_audio_fifo_peek | ( | const AVAudioFifo * | af,
|  | void *const * | data,
|  | int | nb_samples )

Peek data from an AVAudioFifo.

See also
  enum AVSampleFormat The documentation for AVSampleFormat describes the data layout.

Parameters

  af | AVAudioFifo to read from
  data | audio data plane pointers
  nb_samples | number of samples to peek

Returns
  number of samples actually peek, or negative AVERROR code on failure. The number of samples actually peek will not be greater than nb_samples, and will only be less than nb_samples if av_audio_fifo_size is less than nb_samples.

## av_audio_fifo_peek_at()

int av_audio_fifo_peek_at | ( | const AVAudioFifo * | af,
|  | void *const * | data,
|  | int | nb_samples,
|  | int | offset )

Peek data from an AVAudioFifo.

See also
  enum AVSampleFormat The documentation for AVSampleFormat describes the data layout.

Parameters

  af | AVAudioFifo to read from
  data | audio data plane pointers
  nb_samples | number of samples to peek
  offset | offset from current read position

Returns
  number of samples actually peek, or negative AVERROR code on failure. The number of samples actually peek will not be greater than nb_samples, and will only be less than nb_samples if av_audio_fifo_size is less than nb_samples.

## av_audio_fifo_read()

int av_audio_fifo_read | ( | AVAudioFifo * | af,
|  | void *const * | data,
|  | int | nb_samples )

Read data from an AVAudioFifo.

See also
  enum AVSampleFormat The documentation for AVSampleFormat describes the data layout.

Parameters

  af | AVAudioFifo to read from
  data | audio data plane pointers
  nb_samples | number of samples to read

Returns
  number of samples actually read, or negative AVERROR code on failure. The number of samples actually read will not be greater than nb_samples, and will only be less than nb_samples if av_audio_fifo_size is less than nb_samples.

Examples
  transcode_aac.c.

Referenced by load_encode_and_write().

## av_audio_fifo_drain()

int av_audio_fifo_drain | ( | AVAudioFifo * | af,
|  | int | nb_samples )

Drain data from an AVAudioFifo.

Removes the data without reading it.

Parameters

  af | AVAudioFifo to drain
  nb_samples | number of samples to drain

Returns
  0 if OK, or negative AVERROR code on failure

## av_audio_fifo_reset()

void av_audio_fifo_reset | ( | AVAudioFifo * | af | ) |

Reset the AVAudioFifo buffer.

This empties all data in the buffer.

Parameters

  af | AVAudioFifo to reset

## av_audio_fifo_size()

int av_audio_fifo_size | ( | AVAudioFifo * | af | ) |

Get the current number of samples in the AVAudioFifo available for reading.

Parameters

  af | the AVAudioFifo to query

Returns
  number of samples available for reading

Examples
  transcode_aac.c.

Referenced by add_samples_to_fifo(), load_encode_and_write(), and main().

## av_audio_fifo_space()

int av_audio_fifo_space | ( | AVAudioFifo * | af | ) |

Get the current number of samples in the AVAudioFifo available for writing.

Parameters

  af | the AVAudioFifo to query

Returns
  number of samples available for writing