annotate lib/libavutil/audio_fifo.h @ 2544:c674d547cc7c

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