]> git.sesse.net Git - ffmpeg/blob - libavutil/audio_fifo.h
configure: address a copy-paste typo
[ffmpeg] / libavutil / audio_fifo.h
1 /*
2  * Audio FIFO
3  * Copyright (c) 2012 Justin Ruggles <justin.ruggles@gmail.com>
4  *
5  * This file is part of Libav.
6  *
7  * Libav is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * Libav is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with Libav; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20  */
21
22 /**
23  * @file
24  * Audio FIFO Buffer
25  */
26
27 #ifndef AVUTIL_AUDIO_FIFO_H
28 #define AVUTIL_AUDIO_FIFO_H
29
30 #include "avutil.h"
31 #include "fifo.h"
32 #include "samplefmt.h"
33
34 /**
35  * @addtogroup lavu_audio
36  * @{
37  *
38  * @defgroup lavu_audiofifo Audio FIFO Buffer
39  * @{
40  */
41
42 /**
43  * Context for an Audio FIFO Buffer.
44  *
45  * - Operates at the sample level rather than the byte level.
46  * - Supports multiple channels with either planar or packed sample format.
47  * - Automatic reallocation when writing to a full buffer.
48  */
49 typedef struct AVAudioFifo AVAudioFifo;
50
51 /**
52  * Free an AVAudioFifo.
53  *
54  * @param af  AVAudioFifo to free
55  */
56 void av_audio_fifo_free(AVAudioFifo *af);
57
58 /**
59  * Allocate an AVAudioFifo.
60  *
61  * @param sample_fmt  sample format
62  * @param channels    number of channels
63  * @param nb_samples  initial allocation size, in samples
64  * @return            newly allocated AVAudioFifo, or NULL on error
65  */
66 AVAudioFifo *av_audio_fifo_alloc(enum AVSampleFormat sample_fmt, int channels,
67                                  int nb_samples);
68
69 /**
70  * Reallocate an AVAudioFifo.
71  *
72  * @param af          AVAudioFifo to reallocate
73  * @param nb_samples  new allocation size, in samples
74  * @return            0 if OK, or negative AVERROR code on failure
75  */
76 int av_audio_fifo_realloc(AVAudioFifo *af, int nb_samples);
77
78 /**
79  * Write data to an AVAudioFifo.
80  *
81  * The AVAudioFifo will be reallocated automatically if the available space
82  * is less than nb_samples.
83  *
84  * @see enum AVSampleFormat
85  * The documentation for AVSampleFormat describes the data layout.
86  *
87  * @param af          AVAudioFifo to write to
88  * @param data        audio data plane pointers
89  * @param nb_samples  number of samples to write
90  * @return            number of samples actually written, or negative AVERROR
91  *                    code on failure.
92  */
93 int av_audio_fifo_write(AVAudioFifo *af, void **data, int nb_samples);
94
95 /**
96  * Read data from an AVAudioFifo.
97  *
98  * @see enum AVSampleFormat
99  * The documentation for AVSampleFormat describes the data layout.
100  *
101  * @param af          AVAudioFifo to read from
102  * @param data        audio data plane pointers
103  * @param nb_samples  number of samples to read
104  * @return            number of samples actually read, or negative AVERROR code
105  *                    on failure.
106  */
107 int av_audio_fifo_read(AVAudioFifo *af, void **data, int nb_samples);
108
109 /**
110  * Drain data from an AVAudioFifo.
111  *
112  * Removes the data without reading it.
113  *
114  * @param af          AVAudioFifo to drain
115  * @param nb_samples  number of samples to drain
116  * @return            0 if OK, or negative AVERROR code on failure
117  */
118 int av_audio_fifo_drain(AVAudioFifo *af, int nb_samples);
119
120 /**
121  * Reset the AVAudioFifo buffer.
122  *
123  * This empties all data in the buffer.
124  *
125  * @param af  AVAudioFifo to reset
126  */
127 void av_audio_fifo_reset(AVAudioFifo *af);
128
129 /**
130  * Get the current number of samples in the AVAudioFifo available for reading.
131  *
132  * @param af  the AVAudioFifo to query
133  * @return    number of samples available for reading
134  */
135 int av_audio_fifo_size(AVAudioFifo *af);
136
137 /**
138  * Get the current number of samples in the AVAudioFifo available for writing.
139  *
140  * @param af  the AVAudioFifo to query
141  * @return    number of samples available for writing
142  */
143 int av_audio_fifo_space(AVAudioFifo *af);
144
145 /**
146  * @}
147  * @}
148  */
149
150 #endif /* AVUTIL_AUDIO_FIFO_H */