FFmpegfs Fuse Multi Media Filesystem 2.19
Loading...
Searching...
No Matches
Public Member Functions | Private Attributes | List of all members
FFmpeg_AudioFifo Class Reference

RAII wrapper for AVAudioFifo. More...

#include <ffmpeg_audiofifo.h>

Public Member Functions

 FFmpeg_AudioFifo ()
 Construct an empty FIFO wrapper.
 
 FFmpeg_AudioFifo (AVSampleFormat sample_fmt, int channels, int nb_samples=1)
 Construct and allocate an audio FIFO.
 
 ~FFmpeg_AudioFifo ()
 Release the owned FIFO, if any.
 
 FFmpeg_AudioFifo (const FFmpeg_AudioFifo &)=delete
 
FFmpeg_AudioFifooperator= (const FFmpeg_AudioFifo &)=delete
 
 FFmpeg_AudioFifo (FFmpeg_AudioFifo &&fifo) noexcept
 Move-construct a FIFO wrapper.
 
FFmpeg_AudioFifooperator= (FFmpeg_AudioFifo &&fifo) noexcept
 Move-assign a FIFO wrapper.
 
int alloc (AVSampleFormat sample_fmt, int channels, int nb_samples=1)
 Allocate a new audio FIFO, replacing any existing one.
 
void reset ()
 Free the owned FIFO and reset the wrapper to empty.
 
bool empty () const
 Check whether the wrapper currently owns a FIFO.
 
int size () const
 Return the number of samples currently stored in the FIFO.
 
int realloc (int nb_samples)
 Resize the FIFO allocation.
 
int write (void **data, int nb_samples)
 Write audio samples into the FIFO.
 
int read (void **data, int nb_samples)
 Read audio samples from the FIFO.
 
AVAudioFifo * get ()
 Get the owned FFmpeg FIFO pointer.
 
const AVAudioFifo * get () const
 Get the owned FFmpeg FIFO pointer.
 
AVAudioFifo * release ()
 Release ownership without freeing the FIFO.
 
 operator AVAudioFifo * ()
 Convert to the underlying mutable FIFO pointer.
 
 operator const AVAudioFifo * () const
 Convert to the underlying const FIFO pointer.
 

Private Attributes

AVAudioFifo * m_fifo
 Pointer to underlying AVAudioFifo.
 

Detailed Description

RAII wrapper for AVAudioFifo.

Owns an AVAudioFifo allocated with av_audio_fifo_alloc() and releases it with av_audio_fifo_free(). The wrapper is movable but not copyable.

Definition at line 32 of file ffmpeg_audiofifo.h.

Constructor & Destructor Documentation

◆ FFmpeg_AudioFifo() [1/3]

FFmpeg_AudioFifo::FFmpeg_AudioFifo ( )

Construct an empty FIFO wrapper.

Definition at line 31 of file ffmpeg_audiofifo.cc.

◆ FFmpeg_AudioFifo() [2/3]

FFmpeg_AudioFifo::FFmpeg_AudioFifo ( AVSampleFormat  sample_fmt,
int  channels,
int  nb_samples = 1 
)

Construct and allocate an audio FIFO.

Parameters
[in]sample_fmtSample format stored in the FIFO.
[in]channelsNumber of audio channels.
[in]nb_samplesInitial allocation size in samples.

Definition at line 36 of file ffmpeg_audiofifo.cc.

References alloc().

◆ ~FFmpeg_AudioFifo()

FFmpeg_AudioFifo::~FFmpeg_AudioFifo ( )

Release the owned FIFO, if any.

Definition at line 42 of file ffmpeg_audiofifo.cc.

References reset().

◆ FFmpeg_AudioFifo() [3/3]

FFmpeg_AudioFifo::FFmpeg_AudioFifo ( FFmpeg_AudioFifo &&  fifo)
noexcept

Move-construct a FIFO wrapper.

Parameters
[in,out]fifoSource wrapper whose FIFO ownership is transferred.

Definition at line 47 of file ffmpeg_audiofifo.cc.

Member Function Documentation

◆ alloc()

int FFmpeg_AudioFifo::alloc ( AVSampleFormat  sample_fmt,
int  channels,
int  nb_samples = 1 
)

Allocate a new audio FIFO, replacing any existing one.

Parameters
[in]sample_fmtSample format stored in the FIFO.
[in]channelsNumber of audio channels.
[in]nb_samplesInitial allocation size in samples.
Returns
0 on success, or a negative FFmpeg error code.

Definition at line 64 of file ffmpeg_audiofifo.cc.

References m_fifo, and reset().

Referenced by FFmpeg_AudioFifo(), and FFmpeg_Transcoder::init_audio_fifo().

◆ empty()

bool FFmpeg_AudioFifo::empty ( ) const

Check whether the wrapper currently owns a FIFO.

Returns
true if no FIFO is owned, false otherwise.

Definition at line 86 of file ffmpeg_audiofifo.cc.

References m_fifo.

Referenced by FFmpeg_Transcoder::purge_audio_fifo().

◆ get() [1/2]

AVAudioFifo * FFmpeg_AudioFifo::get ( )

Get the owned FFmpeg FIFO pointer.

Returns
Mutable AVAudioFifo pointer, or nullptr if empty.

Definition at line 127 of file ffmpeg_audiofifo.cc.

References m_fifo.

◆ get() [2/2]

const AVAudioFifo * FFmpeg_AudioFifo::get ( ) const

Get the owned FFmpeg FIFO pointer.

Returns
Const AVAudioFifo pointer, or nullptr if empty.

Definition at line 132 of file ffmpeg_audiofifo.cc.

References m_fifo.

◆ operator AVAudioFifo *()

FFmpeg_AudioFifo::operator AVAudioFifo * ( )

Convert to the underlying mutable FIFO pointer.

Definition at line 144 of file ffmpeg_audiofifo.cc.

◆ operator const AVAudioFifo *()

FFmpeg_AudioFifo::operator const AVAudioFifo * ( ) const

Convert to the underlying const FIFO pointer.

Definition at line 149 of file ffmpeg_audiofifo.cc.

◆ operator=()

FFmpeg_AudioFifo & FFmpeg_AudioFifo::operator= ( FFmpeg_AudioFifo &&  fifo)
noexcept

Move-assign a FIFO wrapper.

Parameters
[in,out]fifoSource wrapper whose FIFO ownership is transferred.
Returns
Reference to this wrapper.

Definition at line 53 of file ffmpeg_audiofifo.cc.

◆ read()

int FFmpeg_AudioFifo::read ( void **  data,
int  nb_samples 
)

Read audio samples from the FIFO.

Parameters
[out]dataPer-channel destination buffers as expected by FFmpeg.
[in]nb_samplesNumber of samples to read.
Returns
Number of samples read, or a negative FFmpeg error code.

Definition at line 118 of file ffmpeg_audiofifo.cc.

References m_fifo.

Referenced by FFmpeg_Transcoder::create_audio_frame().

◆ realloc()

int FFmpeg_AudioFifo::realloc ( int  nb_samples)

Resize the FIFO allocation.

Parameters
[in]nb_samplesNew allocation size in samples.
Returns
0 on success, or a negative FFmpeg error code.

Definition at line 100 of file ffmpeg_audiofifo.cc.

References m_fifo.

Referenced by FFmpeg_Transcoder::add_samples_to_fifo().

◆ release()

AVAudioFifo * FFmpeg_AudioFifo::release ( )

Release ownership without freeing the FIFO.

Returns
Previously owned AVAudioFifo pointer, or nullptr if empty.

Definition at line 137 of file ffmpeg_audiofifo.cc.

References m_fifo.

◆ reset()

void FFmpeg_AudioFifo::reset ( )

Free the owned FIFO and reset the wrapper to empty.

Definition at line 77 of file ffmpeg_audiofifo.cc.

References m_fifo.

Referenced by alloc(), FFmpeg_Transcoder::purge_audio_fifo(), and ~FFmpeg_AudioFifo().

◆ size()

int FFmpeg_AudioFifo::size ( ) const

Return the number of samples currently stored in the FIFO.

Returns
Number of queued samples, or 0 if the wrapper is empty.

Definition at line 91 of file ffmpeg_audiofifo.cc.

References m_fifo.

Referenced by FFmpeg_Transcoder::add_samples_to_fifo(), FFmpeg_Transcoder::copy_audio_to_frame_buffer(), FFmpeg_Transcoder::create_audio_frame(), and FFmpeg_Transcoder::purge_audio_fifo().

◆ write()

int FFmpeg_AudioFifo::write ( void **  data,
int  nb_samples 
)

Write audio samples into the FIFO.

Parameters
[in]dataPer-channel sample buffers as expected by FFmpeg.
[in]nb_samplesNumber of samples to write.
Returns
Number of samples written, or a negative FFmpeg error code.

Definition at line 109 of file ffmpeg_audiofifo.cc.

References m_fifo.

Referenced by FFmpeg_Transcoder::add_samples_to_fifo().

Member Data Documentation

◆ m_fifo

AVAudioFifo* FFmpeg_AudioFifo::m_fifo
private

Pointer to underlying AVAudioFifo.

Definition at line 147 of file ffmpeg_audiofifo.h.

Referenced by alloc(), empty(), get(), get(), read(), realloc(), release(), reset(), size(), and write().


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