Path: blob/a-new-beginning/libavutil.xcframework/ios-arm64-simulator/libavutil.framework/Headers/audio_fifo.h
2 views
/*1* Audio FIFO2* Copyright (c) 2012 Justin Ruggles <[email protected]>3*4* This file is part of FFmpeg.5*6* FFmpeg is free software; you can redistribute it and/or7* modify it under the terms of the GNU Lesser General Public8* License as published by the Free Software Foundation; either9* version 2.1 of the License, or (at your option) any later version.10*11* FFmpeg is distributed in the hope that it will be useful,12* but WITHOUT ANY WARRANTY; without even the implied warranty of13* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU14* Lesser General Public License for more details.15*16* You should have received a copy of the GNU Lesser General Public17* License along with FFmpeg; if not, write to the Free Software18* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA19*/2021/**22* @file23* Audio FIFO Buffer24*/2526#ifndef AVUTIL_AUDIO_FIFO_H27#define AVUTIL_AUDIO_FIFO_H2829#include "attributes.h"30#include "samplefmt.h"3132/**33* @addtogroup lavu_audio34* @{35*36* @defgroup lavu_audiofifo Audio FIFO Buffer37* @{38*/3940/**41* Context for an Audio FIFO Buffer.42*43* - Operates at the sample level rather than the byte level.44* - Supports multiple channels with either planar or packed sample format.45* - Automatic reallocation when writing to a full buffer.46*/47typedef struct AVAudioFifo AVAudioFifo;4849/**50* Free an AVAudioFifo.51*52* @param af AVAudioFifo to free53*/54void av_audio_fifo_free(AVAudioFifo *af);5556/**57* Allocate an AVAudioFifo.58*59* @param sample_fmt sample format60* @param channels number of channels61* @param nb_samples initial allocation size, in samples62* @return newly allocated AVAudioFifo, or NULL on error63*/64AVAudioFifo *av_audio_fifo_alloc(enum AVSampleFormat sample_fmt, int channels,65int nb_samples);6667/**68* Reallocate an AVAudioFifo.69*70* @param af AVAudioFifo to reallocate71* @param nb_samples new allocation size, in samples72* @return 0 if OK, or negative AVERROR code on failure73*/74av_warn_unused_result75int av_audio_fifo_realloc(AVAudioFifo *af, int nb_samples);7677/**78* Write data to an AVAudioFifo.79*80* The AVAudioFifo will be reallocated automatically if the available space81* is less than nb_samples.82*83* @see enum AVSampleFormat84* The documentation for AVSampleFormat describes the data layout.85*86* @param af AVAudioFifo to write to87* @param data audio data plane pointers88* @param nb_samples number of samples to write89* @return number of samples actually written, or negative AVERROR90* code on failure. If successful, the number of samples91* actually written will always be nb_samples.92*/93int av_audio_fifo_write(AVAudioFifo *af, void **data, int nb_samples);9495/**96* Peek data from an AVAudioFifo.97*98* @see enum AVSampleFormat99* The documentation for AVSampleFormat describes the data layout.100*101* @param af AVAudioFifo to read from102* @param data audio data plane pointers103* @param nb_samples number of samples to peek104* @return number of samples actually peek, or negative AVERROR code105* on failure. The number of samples actually peek will not106* be greater than nb_samples, and will only be less than107* nb_samples if av_audio_fifo_size is less than nb_samples.108*/109int av_audio_fifo_peek(AVAudioFifo *af, void **data, int nb_samples);110111/**112* Peek data from an AVAudioFifo.113*114* @see enum AVSampleFormat115* The documentation for AVSampleFormat describes the data layout.116*117* @param af AVAudioFifo to read from118* @param data audio data plane pointers119* @param nb_samples number of samples to peek120* @param offset offset from current read position121* @return number of samples actually peek, or negative AVERROR code122* on failure. The number of samples actually peek will not123* be greater than nb_samples, and will only be less than124* nb_samples if av_audio_fifo_size is less than nb_samples.125*/126int av_audio_fifo_peek_at(AVAudioFifo *af, void **data, int nb_samples, int offset);127128/**129* Read data from an AVAudioFifo.130*131* @see enum AVSampleFormat132* The documentation for AVSampleFormat describes the data layout.133*134* @param af AVAudioFifo to read from135* @param data audio data plane pointers136* @param nb_samples number of samples to read137* @return number of samples actually read, or negative AVERROR code138* on failure. The number of samples actually read will not139* be greater than nb_samples, and will only be less than140* nb_samples if av_audio_fifo_size is less than nb_samples.141*/142int av_audio_fifo_read(AVAudioFifo *af, void **data, int nb_samples);143144/**145* Drain data from an AVAudioFifo.146*147* Removes the data without reading it.148*149* @param af AVAudioFifo to drain150* @param nb_samples number of samples to drain151* @return 0 if OK, or negative AVERROR code on failure152*/153int av_audio_fifo_drain(AVAudioFifo *af, int nb_samples);154155/**156* Reset the AVAudioFifo buffer.157*158* This empties all data in the buffer.159*160* @param af AVAudioFifo to reset161*/162void av_audio_fifo_reset(AVAudioFifo *af);163164/**165* Get the current number of samples in the AVAudioFifo available for reading.166*167* @param af the AVAudioFifo to query168* @return number of samples available for reading169*/170int av_audio_fifo_size(AVAudioFifo *af);171172/**173* Get the current number of samples in the AVAudioFifo available for writing.174*175* @param af the AVAudioFifo to query176* @return number of samples available for writing177*/178int av_audio_fifo_space(AVAudioFifo *af);179180/**181* @}182* @}183*/184185#endif /* AVUTIL_AUDIO_FIFO_H */186187188