node-av 1.1.0 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (134) hide show
  1. package/README.md +51 -38
  2. package/dist/api/bitstream-filter.d.ts +180 -123
  3. package/dist/api/bitstream-filter.js +180 -125
  4. package/dist/api/bitstream-filter.js.map +1 -1
  5. package/dist/api/decoder.d.ts +279 -132
  6. package/dist/api/decoder.js +285 -142
  7. package/dist/api/decoder.js.map +1 -1
  8. package/dist/api/encoder.d.ts +246 -162
  9. package/dist/api/encoder.js +272 -208
  10. package/dist/api/encoder.js.map +1 -1
  11. package/dist/api/filter-presets.d.ts +690 -94
  12. package/dist/api/filter-presets.js +686 -102
  13. package/dist/api/filter-presets.js.map +1 -1
  14. package/dist/api/filter.d.ts +249 -213
  15. package/dist/api/filter.js +252 -242
  16. package/dist/api/filter.js.map +1 -1
  17. package/dist/api/hardware.d.ts +224 -117
  18. package/dist/api/hardware.js +380 -214
  19. package/dist/api/hardware.js.map +1 -1
  20. package/dist/api/index.d.ts +3 -3
  21. package/dist/api/index.js +1 -1
  22. package/dist/api/index.js.map +1 -1
  23. package/dist/api/io-stream.d.ts +65 -61
  24. package/dist/api/io-stream.js +43 -46
  25. package/dist/api/io-stream.js.map +1 -1
  26. package/dist/api/media-input.d.ts +242 -140
  27. package/dist/api/media-input.js +205 -103
  28. package/dist/api/media-input.js.map +1 -1
  29. package/dist/api/media-output.d.ts +206 -128
  30. package/dist/api/media-output.js +210 -128
  31. package/dist/api/media-output.js.map +1 -1
  32. package/dist/api/pipeline.d.ts +168 -38
  33. package/dist/api/pipeline.js +238 -14
  34. package/dist/api/pipeline.js.map +1 -1
  35. package/dist/api/types.d.ts +21 -187
  36. package/dist/api/utils.d.ts +1 -2
  37. package/dist/api/utils.js +9 -0
  38. package/dist/api/utils.js.map +1 -1
  39. package/dist/lib/audio-fifo.d.ts +127 -170
  40. package/dist/lib/audio-fifo.js +130 -173
  41. package/dist/lib/audio-fifo.js.map +1 -1
  42. package/dist/lib/binding.js +5 -0
  43. package/dist/lib/binding.js.map +1 -1
  44. package/dist/lib/bitstream-filter-context.d.ts +139 -184
  45. package/dist/lib/bitstream-filter-context.js +139 -188
  46. package/dist/lib/bitstream-filter-context.js.map +1 -1
  47. package/dist/lib/bitstream-filter.d.ts +68 -54
  48. package/dist/lib/bitstream-filter.js +68 -54
  49. package/dist/lib/bitstream-filter.js.map +1 -1
  50. package/dist/lib/codec-context.d.ts +316 -380
  51. package/dist/lib/codec-context.js +316 -381
  52. package/dist/lib/codec-context.js.map +1 -1
  53. package/dist/lib/codec-parameters.d.ts +160 -170
  54. package/dist/lib/codec-parameters.js +162 -172
  55. package/dist/lib/codec-parameters.js.map +1 -1
  56. package/dist/lib/codec-parser.d.ts +91 -104
  57. package/dist/lib/codec-parser.js +92 -103
  58. package/dist/lib/codec-parser.js.map +1 -1
  59. package/dist/lib/codec.d.ts +264 -281
  60. package/dist/lib/codec.js +268 -285
  61. package/dist/lib/codec.js.map +1 -1
  62. package/dist/lib/dictionary.d.ts +149 -203
  63. package/dist/lib/dictionary.js +158 -212
  64. package/dist/lib/dictionary.js.map +1 -1
  65. package/dist/lib/error.d.ts +96 -130
  66. package/dist/lib/error.js +98 -128
  67. package/dist/lib/error.js.map +1 -1
  68. package/dist/lib/filter-context.d.ts +284 -218
  69. package/dist/lib/filter-context.js +290 -227
  70. package/dist/lib/filter-context.js.map +1 -1
  71. package/dist/lib/filter-graph.d.ts +251 -292
  72. package/dist/lib/filter-graph.js +253 -294
  73. package/dist/lib/filter-graph.js.map +1 -1
  74. package/dist/lib/filter-inout.d.ts +87 -95
  75. package/dist/lib/filter-inout.js +87 -95
  76. package/dist/lib/filter-inout.js.map +1 -1
  77. package/dist/lib/filter.d.ts +93 -111
  78. package/dist/lib/filter.js +93 -111
  79. package/dist/lib/filter.js.map +1 -1
  80. package/dist/lib/format-context.d.ts +320 -428
  81. package/dist/lib/format-context.js +313 -385
  82. package/dist/lib/format-context.js.map +1 -1
  83. package/dist/lib/frame.d.ts +262 -405
  84. package/dist/lib/frame.js +263 -408
  85. package/dist/lib/frame.js.map +1 -1
  86. package/dist/lib/hardware-device-context.d.ts +149 -203
  87. package/dist/lib/hardware-device-context.js +149 -203
  88. package/dist/lib/hardware-device-context.js.map +1 -1
  89. package/dist/lib/hardware-frames-context.d.ts +170 -180
  90. package/dist/lib/hardware-frames-context.js +171 -181
  91. package/dist/lib/hardware-frames-context.js.map +1 -1
  92. package/dist/lib/index.d.ts +2 -1
  93. package/dist/lib/index.js +2 -2
  94. package/dist/lib/index.js.map +1 -1
  95. package/dist/lib/input-format.d.ts +89 -117
  96. package/dist/lib/input-format.js +89 -117
  97. package/dist/lib/input-format.js.map +1 -1
  98. package/dist/lib/io-context.d.ts +209 -241
  99. package/dist/lib/io-context.js +220 -252
  100. package/dist/lib/io-context.js.map +1 -1
  101. package/dist/lib/log.d.ts +85 -119
  102. package/dist/lib/log.js +85 -122
  103. package/dist/lib/log.js.map +1 -1
  104. package/dist/lib/native-types.d.ts +117 -106
  105. package/dist/lib/native-types.js +0 -7
  106. package/dist/lib/native-types.js.map +1 -1
  107. package/dist/lib/option.d.ts +284 -241
  108. package/dist/lib/option.js +309 -249
  109. package/dist/lib/option.js.map +1 -1
  110. package/dist/lib/output-format.d.ts +77 -101
  111. package/dist/lib/output-format.js +77 -101
  112. package/dist/lib/output-format.js.map +1 -1
  113. package/dist/lib/packet.d.ts +172 -240
  114. package/dist/lib/packet.js +172 -241
  115. package/dist/lib/packet.js.map +1 -1
  116. package/dist/lib/rational.d.ts +0 -2
  117. package/dist/lib/rational.js +0 -2
  118. package/dist/lib/rational.js.map +1 -1
  119. package/dist/lib/software-resample-context.d.ts +241 -325
  120. package/dist/lib/software-resample-context.js +242 -326
  121. package/dist/lib/software-resample-context.js.map +1 -1
  122. package/dist/lib/software-scale-context.d.ts +129 -173
  123. package/dist/lib/software-scale-context.js +131 -175
  124. package/dist/lib/software-scale-context.js.map +1 -1
  125. package/dist/lib/stream.d.ts +87 -197
  126. package/dist/lib/stream.js +87 -197
  127. package/dist/lib/stream.js.map +1 -1
  128. package/dist/lib/utilities.d.ts +372 -181
  129. package/dist/lib/utilities.js +373 -182
  130. package/dist/lib/utilities.js.map +1 -1
  131. package/install/check.js +0 -1
  132. package/package.json +21 -12
  133. package/release_notes.md +43 -59
  134. package/CHANGELOG.md +0 -8
@@ -1,11 +1,11 @@
1
1
  import type { AVSampleFormat } from '../constants/constants.js';
2
2
  import type { NativeAudioFifo, NativeWrapper } from './native-types.js';
3
3
  /**
4
- * Audio FIFO buffer for sample management.
4
+ * Audio FIFO (First-In-First-Out) buffer for managing audio samples.
5
5
  *
6
- * Provides a first-in-first-out buffer for audio samples.
7
- * Supports both planar and interleaved audio formats.
8
- * Automatically handles reallocation when needed.
6
+ * Provides a thread-safe buffer for audio sample data, supporting both planar and interleaved formats.
7
+ * Automatically handles buffer reallocation when needed. Essential for audio resampling,
8
+ * format conversion, and buffering operations.
9
9
  *
10
10
  * Direct mapping to FFmpeg's AVAudioFifo.
11
11
  *
@@ -14,236 +14,191 @@ import type { NativeAudioFifo, NativeWrapper } from './native-types.js';
14
14
  * import { AudioFifo, FFmpegError } from 'node-av';
15
15
  * import { AV_SAMPLE_FMT_FLTP } from 'node-av/constants';
16
16
  *
17
- * // Create audio FIFO for stereo float samples
17
+ * // Create FIFO for stereo float planar audio
18
18
  * const fifo = new AudioFifo();
19
19
  * fifo.alloc(AV_SAMPLE_FMT_FLTP, 2, 4096);
20
20
  *
21
- * // Write samples to FIFO
22
- * const samplesWritten = await fifo.write(inputBuffers, frameSize);
23
- * FFmpegError.throwIfError(samplesWritten, 'write');
21
+ * // Write samples
22
+ * const leftChannel = Buffer.alloc(1024 * 4); // 1024 float samples
23
+ * const rightChannel = Buffer.alloc(1024 * 4);
24
+ * const written = await fifo.write([leftChannel, rightChannel], 1024);
25
+ * FFmpegError.throwIfError(written, 'write');
24
26
  *
25
- * // Read samples from FIFO
26
- * const samplesRead = await fifo.read(outputBuffers, frameSize);
27
- * FFmpegError.throwIfError(samplesRead, 'read');
28
- *
29
- * // Check available samples
30
- * console.log(`Samples in FIFO: ${fifo.size}`);
27
+ * // Read samples when enough available
28
+ * if (fifo.size >= 512) {
29
+ * const outLeft = Buffer.alloc(512 * 4);
30
+ * const outRight = Buffer.alloc(512 * 4);
31
+ * const read = await fifo.read([outLeft, outRight], 512);
32
+ * FFmpegError.throwIfError(read, 'read');
33
+ * }
31
34
  *
32
35
  * // Cleanup
33
36
  * fifo.free();
34
37
  * ```
38
+ *
39
+ * @see [AudioFifo](https://ffmpeg.org/doxygen/trunk/structAVAudioFifo.html) - FFmpeg Doxygen
35
40
  */
36
41
  export declare class AudioFifo implements Disposable, NativeWrapper<NativeAudioFifo> {
37
42
  private native;
38
- /**
39
- * Create a new audio FIFO buffer.
40
- *
41
- * The FIFO is uninitialized - you must call alloc() before use.
42
- * No FFmpeg resources are allocated until alloc() is called.
43
- *
44
- * Direct wrapper around AVAudioFifo.
45
- *
46
- * @example
47
- * ```typescript
48
- * import { AudioFifo } from 'node-av';
49
- * import { AV_SAMPLE_FMT_S16 } from 'node-av/constants';
50
- *
51
- * const fifo = new AudioFifo();
52
- * fifo.alloc(AV_SAMPLE_FMT_S16, 2, 1024);
53
- * // FIFO is now ready for use
54
- * ```
55
- */
56
43
  constructor();
57
44
  /**
58
- * Get the current number of samples in the AVAudioFifo.
59
- *
60
- * Returns the number of samples currently buffered in the FIFO.
61
- *
62
- * Direct mapping to av_audio_fifo_size()
63
- *
64
- * @returns Number of samples currently in the FIFO
65
- *
66
- * @example
67
- * ```typescript
68
- * import { FFmpegError } from 'node-av';
69
- *
70
- * if (fifo.size >= frameSize) {
71
- * // Enough samples available for a full frame
72
- * const ret = await fifo.read(outputBuffer, frameSize);
73
- * FFmpegError.throwIfError(ret, 'read');
74
- * }
75
- * ```
45
+ * Number of samples currently in the FIFO.
76
46
  *
77
- * @readonly
47
+ * Direct mapping to av_audio_fifo_size().
78
48
  */
79
49
  get size(): number;
80
50
  /**
81
- * Get the available space in the AVAudioFifo.
51
+ * Number of samples that can be written without reallocation.
82
52
  *
83
- * Returns the number of samples that can be written without reallocation.
84
- *
85
- * Direct mapping to av_audio_fifo_space()
86
- *
87
- * @returns Number of samples that can be written to the FIFO
88
- *
89
- * @example
90
- * ```typescript
91
- * import { FFmpegError } from 'node-av';
92
- *
93
- * if (fifo.space >= frameSize) {
94
- * // Enough space for a full frame
95
- * const ret = await fifo.write(inputBuffer, frameSize);
96
- * FFmpegError.throwIfError(ret, 'write');
97
- * }
98
- * ```
99
- *
100
- * @readonly
53
+ * Direct mapping to av_audio_fifo_space().
101
54
  */
102
55
  get space(): number;
103
56
  /**
104
- * Allocate an AVAudioFifo.
57
+ * Allocate an AVAudioFifo buffer.
105
58
  *
106
- * Allocates a FIFO buffer for the specified audio format and size.
59
+ * Creates a FIFO buffer for the specified audio format and size.
107
60
  * The FIFO will automatically grow if more data is written than allocated.
108
61
  *
109
- * Direct mapping to av_audio_fifo_alloc()
62
+ * Direct mapping to av_audio_fifo_alloc().
110
63
  *
111
64
  * @param sampleFmt - Sample format (e.g., AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_FLTP)
112
- * @param channels - Number of channels
113
- * @param nbSamples - Initial allocation size, in samples
65
+ * @param channels - Number of audio channels
66
+ * @param nbSamples - Initial buffer size in samples
114
67
  *
115
- * @throws {Error} Memory allocation failure (ENOMEM)
68
+ * @throws {Error} If allocation fails (ENOMEM)
116
69
  *
117
70
  * @example
118
71
  * ```typescript
119
72
  * import { AudioFifo } from 'node-av';
120
- * import { AV_SAMPLE_FMT_FLTP } from 'node-av/constants';
73
+ * import { AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_FLTP } from 'node-av/constants';
74
+ *
75
+ * // For interleaved 16-bit stereo
76
+ * const fifo1 = new AudioFifo();
77
+ * fifo1.alloc(AV_SAMPLE_FMT_S16, 2, 4096);
121
78
  *
122
- * const fifo = new AudioFifo();
123
- * fifo.alloc(AV_SAMPLE_FMT_FLTP, 2, 4096);
124
- * // FIFO can now hold up to 4096 stereo float samples
79
+ * // For planar float 5.1 audio
80
+ * const fifo2 = new AudioFifo();
81
+ * fifo2.alloc(AV_SAMPLE_FMT_FLTP, 6, 8192);
125
82
  * ```
126
83
  *
127
84
  * @see {@link realloc} To resize the FIFO
85
+ * @see {@link free} To release the FIFO
128
86
  */
129
87
  alloc(sampleFmt: AVSampleFormat, channels: number, nbSamples: number): void;
130
88
  /**
131
- * Free an AVAudioFifo.
89
+ * Free the FIFO buffer and all associated resources.
132
90
  *
133
- * Frees the FIFO buffer and all associated resources.
134
- * The FIFO object becomes invalid after this call.
91
+ * After calling this, the FIFO is invalid and must be reallocated before use.
135
92
  *
136
- * Direct mapping to av_audio_fifo_free()
93
+ * Direct mapping to av_audio_fifo_free().
137
94
  *
138
95
  * @example
139
96
  * ```typescript
140
97
  * fifo.free();
141
- * // FIFO is now invalid and should not be used
98
+ * // FIFO is now invalid, must call alloc() before using again
142
99
  * ```
100
+ *
101
+ * @see {@link Symbol.dispose} For automatic cleanup
102
+ * @see {@link alloc} To allocate
143
103
  */
144
104
  free(): void;
145
105
  /**
146
- * Write data to an AVAudioFifo.
106
+ * Write audio samples to the FIFO.
147
107
  *
148
- * Writes audio samples to the FIFO buffer.
149
- * Automatically reallocates the FIFO if more space is needed.
108
+ * Writes samples to the FIFO buffer. Automatically reallocates if more space is needed.
109
+ * For planar formats, provide an array of buffers (one per channel).
110
+ * For interleaved formats, provide a single buffer.
150
111
  *
151
- * Direct mapping to av_audio_fifo_write()
112
+ * Direct mapping to av_audio_fifo_write().
152
113
  *
153
- * @param data - Audio buffer(s) to write from.
154
- * For planar formats: array of buffers (one per channel).
155
- * For interleaved formats: single buffer.
114
+ * @param data - Audio data buffer(s). Array for planar, single Buffer for interleaved
156
115
  * @param nbSamples - Number of samples to write
157
116
  *
158
- * @returns Number of samples actually written, or negative AVERROR on error:
159
- * - >=0: Number of samples written
160
- * - AVERROR(EINVAL): Invalid parameters
161
- * - AVERROR(ENOMEM): Memory allocation failure
117
+ * @returns Number of samples written, or negative AVERROR:
118
+ * - AVERROR_EINVAL: Invalid parameters
119
+ * - AVERROR_ENOMEM: Memory allocation failure
162
120
  *
163
121
  * @example
164
122
  * ```typescript
165
123
  * import { FFmpegError } from 'node-av';
166
124
  *
167
- * // Planar format (separate buffers per channel)
168
- * const leftChannel = Buffer.alloc(frameSize * 4); // float32
169
- * const rightChannel = Buffer.alloc(frameSize * 4);
170
- * const written = await fifo.write([leftChannel, rightChannel], frameSize);
125
+ * // Planar format (e.g., FLTP) - separate buffers per channel
126
+ * const leftData = Buffer.alloc(1024 * 4); // 1024 float samples
127
+ * const rightData = Buffer.alloc(1024 * 4);
128
+ * const written = await fifo.write([leftData, rightData], 1024);
171
129
  * FFmpegError.throwIfError(written, 'write');
130
+ * console.log(`Wrote ${written} samples`);
172
131
  *
173
- * // Interleaved format (single buffer)
174
- * const interleavedBuffer = Buffer.alloc(frameSize * 2 * 2); // stereo s16
175
- * const written2 = await fifo.write(interleavedBuffer, frameSize);
132
+ * // Interleaved format (e.g., S16) - single buffer
133
+ * const interleavedData = Buffer.alloc(1024 * 2 * 2); // 1024 stereo S16 samples
134
+ * const written2 = await fifo.write(interleavedData, 1024);
176
135
  * FFmpegError.throwIfError(written2, 'write');
177
136
  * ```
178
137
  *
179
- * @see {@link read} To read samples from FIFO
138
+ * @see {@link read} To retrieve samples from FIFO
139
+ * @see {@link space} To check available space
180
140
  */
181
141
  write(data: Buffer | Buffer[], nbSamples: number): Promise<number>;
182
142
  /**
183
- * Read data from an AVAudioFifo.
143
+ * Read and remove samples from the FIFO.
184
144
  *
185
- * Reads and removes samples from the FIFO buffer.
186
- * Reads up to nb_samples or the available amount, whichever is less.
145
+ * Reads up to the specified number of samples from the FIFO.
146
+ * The samples are removed from the FIFO after reading.
147
+ * Buffers must be pre-allocated with sufficient size.
187
148
  *
188
- * Direct mapping to av_audio_fifo_read()
149
+ * Direct mapping to av_audio_fifo_read().
189
150
  *
190
- * @param data - Audio buffer(s) to read into.
191
- * For planar formats: array of buffers (one per channel).
192
- * For interleaved formats: single buffer.
193
- * Buffers must be pre-allocated with sufficient size.
194
- * @param nbSamples - Number of samples to read
151
+ * @param data - Pre-allocated buffer(s) to read into. Array for planar, single Buffer for interleaved
152
+ * @param nbSamples - Maximum number of samples to read
195
153
  *
196
- * @returns Number of samples actually read, or negative AVERROR on error:
197
- * - >=0: Number of samples read
198
- * - AVERROR(EINVAL): Invalid parameters
154
+ * @returns Number of samples read, or negative AVERROR:
155
+ * - AVERROR_EINVAL: Invalid parameters
199
156
  *
200
157
  * @example
201
158
  * ```typescript
202
159
  * import { FFmpegError } from 'node-av';
203
160
  *
204
- * // Planar format (separate buffers per channel)
205
- * const leftChannel = Buffer.alloc(frameSize * 4); // float32
206
- * const rightChannel = Buffer.alloc(frameSize * 4);
207
- * const read = await fifo.read([leftChannel, rightChannel], frameSize);
208
- * FFmpegError.throwIfError(read, 'read');
209
- *
210
- * // Interleaved format (single buffer)
211
- * const interleavedBuffer = Buffer.alloc(frameSize * 2 * 2); // stereo s16
212
- * const read2 = await fifo.read(interleavedBuffer, frameSize);
213
- * FFmpegError.throwIfError(read2, 'read');
161
+ * // Check available samples
162
+ * const available = fifo.size;
163
+ * if (available >= 1024) {
164
+ * // Planar format
165
+ * const leftOut = Buffer.alloc(1024 * 4);
166
+ * const rightOut = Buffer.alloc(1024 * 4);
167
+ * const read = await fifo.read([leftOut, rightOut], 1024);
168
+ * FFmpegError.throwIfError(read, 'read');
169
+ * console.log(`Read ${read} samples`);
170
+ * }
214
171
  * ```
215
172
  *
216
173
  * @see {@link peek} To read without removing
217
- * @see {@link write} To write samples to FIFO
174
+ * @see {@link size} To check available samples
218
175
  */
219
176
  read(data: Buffer | Buffer[], nbSamples: number): Promise<number>;
220
177
  /**
221
- * Peek data from an AVAudioFifo.
178
+ * Read samples from the FIFO without removing them.
222
179
  *
223
- * Reads samples from the FIFO without removing them.
224
- * Useful for inspecting upcoming data.
180
+ * Similar to read() but leaves the samples in the FIFO.
181
+ * Useful for inspecting upcoming data without consuming it.
225
182
  *
226
- * Direct mapping to av_audio_fifo_peek()
183
+ * Direct mapping to av_audio_fifo_peek().
227
184
  *
228
- * @param data - Audio buffer(s) to peek into.
229
- * For planar formats: array of buffers (one per channel).
230
- * For interleaved formats: single buffer.
231
- * Buffers must be pre-allocated.
232
- * @param nbSamples - Number of samples to peek
185
+ * @param data - Pre-allocated buffer(s) to peek into. Array for planar, single Buffer for interleaved
186
+ * @param nbSamples - Maximum number of samples to peek
233
187
  *
234
- * @returns Number of samples actually peeked, or negative AVERROR on error:
235
- * - >=0: Number of samples peeked
236
- * - AVERROR(EINVAL): Invalid parameters
188
+ * @returns Number of samples peeked, or negative AVERROR:
189
+ * - AVERROR_EINVAL: Invalid parameters
237
190
  *
238
191
  * @example
239
192
  * ```typescript
240
193
  * import { FFmpegError } from 'node-av';
241
194
  *
242
195
  * // Peek at next samples without removing them
243
- * const peekBuffer = Buffer.alloc(frameSize * 4);
244
- * const peeked = await fifo.peek(peekBuffer, frameSize);
196
+ * const peekBuffer = Buffer.alloc(256 * 4);
197
+ * const peeked = await fifo.peek(peekBuffer, 256);
245
198
  * FFmpegError.throwIfError(peeked, 'peek');
246
- * // Samples are still in FIFO after peek
199
+ *
200
+ * // Samples are still in FIFO
201
+ * console.log(`FIFO still has ${fifo.size} samples`);
247
202
  * ```
248
203
  *
249
204
  * @see {@link read} To read and remove samples
@@ -255,64 +210,71 @@ export declare class AudioFifo implements Disposable, NativeWrapper<NativeAudioF
255
210
  * Discards the specified number of samples from the FIFO.
256
211
  * Useful for skipping unwanted audio data.
257
212
  *
258
- * Direct mapping to av_audio_fifo_drain()
213
+ * Direct mapping to av_audio_fifo_drain().
259
214
  *
260
- * @param nbSamples - Number of samples to drain
215
+ * @param nbSamples - Number of samples to discard
261
216
  *
262
217
  * @example
263
218
  * ```typescript
264
- * // Skip next 100 samples
219
+ * // Skip 100 samples
265
220
  * fifo.drain(100);
221
+ * console.log(`FIFO now has ${fifo.size} samples`);
266
222
  * ```
223
+ *
224
+ * @see {@link reset} To remove all samples
267
225
  */
268
226
  drain(nbSamples: number): void;
269
227
  /**
270
- * Reset the AVAudioFifo buffer.
228
+ * Remove all samples from the FIFO.
271
229
  *
272
- * Empties all data in the FIFO without deallocating the buffer.
273
- * The FIFO remains allocated and ready for use.
230
+ * Empties the FIFO buffer without deallocating it.
231
+ * The FIFO remains allocated and ready for new data.
274
232
  *
275
- * Direct mapping to av_audio_fifo_reset()
233
+ * Direct mapping to av_audio_fifo_reset().
276
234
  *
277
235
  * @example
278
236
  * ```typescript
279
237
  * fifo.reset();
280
- * // FIFO is now empty but still allocated
238
+ * console.log(fifo.size); // 0
239
+ * console.log(fifo.space); // Original allocation size
281
240
  * ```
241
+ *
242
+ * @see {@link drain} To remove specific number of samples
282
243
  */
283
244
  reset(): void;
284
245
  /**
285
- * Reallocate an AVAudioFifo to a new size.
246
+ * Resize the FIFO buffer.
286
247
  *
287
- * Changes the size of the FIFO buffer.
288
- * Can be used to grow or shrink the buffer.
248
+ * Changes the allocated size of the FIFO. Can grow or shrink the buffer.
249
+ * Existing samples are preserved up to the new size.
289
250
  *
290
- * Direct mapping to av_audio_fifo_realloc()
251
+ * Direct mapping to av_audio_fifo_realloc().
291
252
  *
292
- * @param nbSamples - New allocation size, in samples
253
+ * @param nbSamples - New allocation size in samples
293
254
  *
294
255
  * @returns 0 on success, negative AVERROR on error:
295
- * - 0: Success
296
- * - AVERROR(EINVAL): Invalid parameters
297
- * - AVERROR(ENOMEM): Memory allocation failure
256
+ * - AVERROR_EINVAL: Invalid size
257
+ * - AVERROR_ENOMEM: Memory allocation failure
298
258
  *
299
259
  * @example
300
260
  * ```typescript
301
261
  * import { FFmpegError } from 'node-av';
302
262
  *
303
- * // Increase FIFO capacity
304
- * const ret = fifo.realloc(8192);
263
+ * // Grow FIFO to handle larger buffers
264
+ * const ret = fifo.realloc(16384);
305
265
  * FFmpegError.throwIfError(ret, 'realloc');
266
+ * console.log(`New space: ${fifo.space} samples`);
306
267
  * ```
307
268
  *
308
269
  * @see {@link alloc} For initial allocation
309
270
  */
310
271
  realloc(nbSamples: number): number;
311
272
  /**
312
- * Get the native FFmpeg AVAudioFifo pointer.
273
+ * Get the underlying native AudioFifo object.
274
+ *
275
+ * @returns The native AudioFifo binding object
313
276
  *
314
- * @internal For use by other wrapper classes
315
- * @returns The underlying native AudioFifo object
277
+ * @internal
316
278
  */
317
279
  getNative(): NativeAudioFifo;
318
280
  /**
@@ -323,17 +285,12 @@ export declare class AudioFifo implements Disposable, NativeWrapper<NativeAudioF
323
285
  *
324
286
  * @example
325
287
  * ```typescript
326
- * import { AudioFifo } from 'node-av';
327
- * import { AV_SAMPLE_FMT_S16 } from 'node-av/constants';
328
- *
329
288
  * {
330
289
  * using fifo = new AudioFifo();
331
- * fifo.alloc(AV_SAMPLE_FMT_S16, 2, 1024);
332
- * // ... use FIFO
290
+ * fifo.alloc(AV_SAMPLE_FMT_FLTP, 2, 4096);
291
+ * // Use fifo...
333
292
  * } // Automatically freed when leaving scope
334
293
  * ```
335
- *
336
- * @see {@link free} For manual cleanup
337
294
  */
338
295
  [Symbol.dispose](): void;
339
296
  }