AVAudioFifo 主要保存采样的数据样本,定义如下,
struct AVAudioFifo {
AVFifoBuffer **buf; /**< single buffer for interleaved, per-channel buffers for planar */
int nb_buffers; /**< number of buffers */
int nb_samples; /**< number of samples currently in the FIFO */
int allocated_samples; /**< current allocated size, in samples */
int channels; /**< number of channels */
enum AVSampleFormat sample_fmt; /**< sample format */
int sample_size; /**< size, in bytes, of one sample in a buffer */
};
主要的函数:
int av_audio_fifo_size(AVAudioFifo *af); 获取当前af可读的样本数,返回样本数
int av_audio_fifo_read(AVAudioFifo *af, void **data, int nb_samples); 读取af中的可读样本,读取nb_samples个样本,保存在data中,返回实际读取的样本数,实际读取的样本数小于等于nb_samples
int av_audio_fifo_write(AVAudioFifo *af, void **data, int nb_samples); 将data数据写入af中,写入nb_samples个样本,返回实际写入的个数
int swr_convert(struct SwrContext *s, uint8_t **out, int out_count, const uint8_t **in , int in_count);这个函数用于重采样或者音频格式转换,out_count是每个通道可用的空间量,out是存储转换输出的数据