1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use UnsafeCell;
use *;
use ;
use NonNull;
use *;
use *;
use *;
use *;
use crate::*;
/// [Apple's documentation](https://developer.apple.com/documentation/mediatoolbox/mtaudioprocessingtap?language=objc)
cf_type!;
cf_objc2_type!;
unsafe
/// Flags used when creating audio processing taps.
///
///
/// Either the PreEffects or PostEffects flag must be set, but not both.
///
///
/// Signifies that the processing tap is inserted before any effects.
///
/// Signifies that the processing tap is inserted after any effects.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/mediatoolbox/mtaudioprocessingtapcreationflags?language=objc)
pub type MTAudioProcessingTapCreationFlags = u32;
/// [Apple's documentation](https://developer.apple.com/documentation/mediatoolbox/kmtaudioprocessingtapcreationflag_preeffects?language=objc)
pub const kMTAudioProcessingTapCreationFlag_PreEffects: MTAudioProcessingTapCreationFlags = 1 << 0;
/// [Apple's documentation](https://developer.apple.com/documentation/mediatoolbox/kmtaudioprocessingtapcreationflag_posteffects?language=objc)
pub const kMTAudioProcessingTapCreationFlag_PostEffects: MTAudioProcessingTapCreationFlags = 1 << 1;
/// Flags passed to the process callback and from GetSourceAudio.
///
///
/// Signifies that the source audio is the beginning of a continuous stream,
/// i.e., following the beginning or resumption of playback.
/// Returned from GetSourceAudio.
///
/// Signifies that the source audio is past the end of stream. This happens when
/// the audio queue is being stopped asynchronously and has finished playing
/// all of its data. Returned from GetSourceAudio and should be propagated
/// on return from the process callback.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/mediatoolbox/mtaudioprocessingtapflags?language=objc)
pub type MTAudioProcessingTapFlags = u32;
/// [Apple's documentation](https://developer.apple.com/documentation/mediatoolbox/kmtaudioprocessingtapflag_startofstream?language=objc)
pub const kMTAudioProcessingTapFlag_StartOfStream: MTAudioProcessingTapFlags = 1 << 8;
/// [Apple's documentation](https://developer.apple.com/documentation/mediatoolbox/kmtaudioprocessingtapflag_endofstream?language=objc)
pub const kMTAudioProcessingTapFlag_EndOfStream: MTAudioProcessingTapFlags = 1 << 9;
/// Init callback.
///
///
/// An init callback that is invoked when MTAudioProcessingTapCreate() is called.
/// The init callback is always balanced by a finalize callback when the MTAudioProcessingTap object
/// is released.
///
///
/// Parameter `tap`: The processing tap.
///
/// Parameter `clientInfo`: The client data of the processing tap passed in callbacks struct in MTAudioProcessingTapCreate().
///
/// Parameter `tapStorageOut`: Additional client data. The intent is for clients to allocate a block of memory for use within their custom
/// MTAudioProcessingTap implementation that will be freed when the finalize callback is invoked. This argument
/// is optional.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/mediatoolbox/mtaudioprocessingtapinitcallback?language=objc)
pub type MTAudioProcessingTapInitCallback = ;
/// Finalize callback.
///
///
/// This callback is called when it is safe to free any buffers or other state associated with the tap.
/// This callback will be called exactly once when the MTAudioProcessingTap object is finalized.
/// If tapStorage was allocated in the init callback, it should be freed here.
///
///
/// Parameter `tap`: The processing tap.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/mediatoolbox/mtaudioprocessingtapfinalizecallback?language=objc)
pub type MTAudioProcessingTapFinalizeCallback =
;
/// Audio processing preparation callback.
///
///
/// A preparation callback that is invoked when the underlying audio machinery is initialized.
///
/// The preparation callback should be where output buffers that will be returned by the
/// ProcessingTapCallback are allocated (unless in-place processing is desired).
///
/// Note that the preparation callback can potentially be called multiple times over the lifetime
/// of the tap object, if the client performs an operation that requires the underlying audio machinery to
/// be torn down and rebuilt.
///
///
/// Parameter `tap`: The processing tap.
///
/// Parameter `maxFrames`: The maximum number of sample frames that can be requested of a processing
/// tap at any one time. Typically this will be approximately 50 msec of audio
/// (2048 samples
/// @
/// 44.1kHz).
///
/// Parameter `processingFormat`: The format in which the client will receive the audio data to be processed.
/// This will always be the same sample rate as the client format and usually
/// the same number of channels as the client format of the audio queue. (NOTE:
/// the number of channels may be different in some cases if the client format
/// has some channel count restrictions; for example, if the client provides 5.1
/// AAC, but the decoder can only produce stereo). The channel order, if the
/// same as the client format, will be the same as the client channel order. If
/// the channel count is changed, it will be to either 1 (mono) or 2 (stereo, in
/// which case the first channel is left, the second right).
///
/// If the data is not in a convenient format for the client to process in, then
/// the client should convert the data to and from that format. This is the most
/// efficient mechanism to use, as the audio system may choose a format that is
/// most efficient from its playback requirement.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/mediatoolbox/mtaudioprocessingtappreparecallback?language=objc)
pub type MTAudioProcessingTapPrepareCallback = ;
/// Audio processing unpreparation callback.
///
///
/// The unpreparation callback is invoked when the underlying audio machinery stops calling the process callback.
///
/// Preparation/Unpreparation callbacks are always paired.
///
/// Process callbacks will only ever be called after the prepare callback returns, and before unprepare is called.
///
///
/// Parameter `tap`: The processing tap.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/mediatoolbox/mtaudioprocessingtapunpreparecallback?language=objc)
pub type MTAudioProcessingTapUnprepareCallback =
;
/// A function called when an audio track has data to be processed by its tap.
///
///
/// A processing callback is invoked when the audio track has data that can be processed by a
/// given tap.
///
/// The processing callback will be called when there is sufficient input data to provide for
/// processing. The callback should then go and request as much source data as it needs in order
/// to produce the requested number of processed samples. When the callback requests source data,
/// it may receive less data than it requests.
///
/// The tap must provide the same number of samples that are being requested. Under normal circumstances,
/// the source data it requests should be satisfied (as the client running the audio queue is also
/// providing the queue with the audio source material). If there is insufficient source data available
/// (this is indicated by the numberFramesOut from the GetSourceAudio call), then the processing tap
/// should cope as best as it can; it can either return less data than was requested, insert silence,
/// insert noise, etc.
/// If less data is returned than requested, the remainder will be filled with silence.
///
/// A processing tap is a real-time operation, so the general Core Audio limitations for real-time
/// processing apply. For example, care should be taken not to allocate memory or call into
/// blocking system calls, as this will interfere with the real-time nature of audio playback.
///
/// Under normal operation, the source data will be continuous from the last time the callback was
/// called, and the processed samples should be continuous from the previous samples returned. If
/// there is any discontinuity between the last samples provided for processing, the audio queue will
/// set the kMTAudioProcessingTapFlag_StartOfStream bit in the flags. After a discontinuity, the
/// first sample that the processing tap outputs should correspond to the first sample that was
/// provided in the source samples (so a reset + consequent process serves to re-anchor a
/// relationship between the processing tap's source and processed samples). In this case, the
/// processing tap will typically discard any previous state (for example, if a processing tap was
/// adding a reverb to a signal, then the discontinuity flag would act the same as AudioUnitReset;
/// any previous source information in the processing tap should be discarded).
///
/// The caller is responsible for absorbing any processing delays. For example, if the
/// processing is to be done by an audio unit that reports a processing latency, then the caller
/// should remove those latency samples from the audio unit's rendering and not return them to
/// the tap.
///
/// The processing tap may operate on the provided source data in place ("in-place processing")
/// and return pointers to that buffer, rather than its own. This is similar to audio
/// unit render operations. The processing tap will be provided with a bufferList on input
/// where the mData pointers are NULL.
///
/// When the output audio is stopped asynchronously, the processing tap will see the
/// kMTAudioProcessingTapFlag_EndOfStream bit set on return from GetSourceAudio, and is responsible
/// for propagating this bit from the callback when its processing has reached this point.
///
/// A processing tap will NEVER see the same source data again, so, it should keep its own copy,
/// if it needs to keep it for further reference past the duration of this call. It also cannot
/// assume that the pointers to the source data that it retrieves will remain valid AFTER the
/// processing tap has executed.
///
/// Should the processing tap provide custom buffers in bufferListInOut, it should ensure that the
/// data pointers remain valid until the tap is executed again.
///
///
/// Parameter `tap`: The processing tap.
///
/// Parameter `numberFrames`: The requested number of sample frames that should be rendered.
///
/// Parameter `flags`: The flags passed at construction time are provided.
///
/// Parameter `bufferListInOut`: The audio buffer list which will contain processed source data.
/// On input, all fields except for the buffer pointers will be filled in,
/// and can be passed directly to GetSourceAudio() if in-place processing is
/// desired.
/// On output, the bufferList should contain the processed audio buffers.
///
/// Parameter `numberFramesOut`: The number of frames of audio data provided in the processed data. Can be 0.
///
/// Parameter `flagsOut`: The start/end of stream flags should be set when appropriate (see Discussion, above).
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/mediatoolbox/mtaudioprocessingtapprocesscallback?language=objc)
pub type MTAudioProcessingTapProcessCallback = ;
/// [Apple's documentation](https://developer.apple.com/documentation/mediatoolbox/kmtaudioprocessingtapcallbacksversion_0?language=objc)
pub const kMTAudioProcessingTapCallbacksVersion_0: c_int = 0;
/// Note that for 64-bit architectures, this struct contains misaligned function pointers.
/// To avoid link-time issues, it is recommended that clients fill MTAudioProcessingTapCallbacks' function pointer fields
/// by using assignment statements, rather than declaring them as global or static structs.
/// Field: version
/// The version number of the structure passed in as a parameter to MTAudioProcessingTapCreate().
/// Must be kMTAudioProcessingTapCallbacksVersion_0.
/// Field: clientInfo
/// Client data that will be passed to the init callback when it is invoked. Can be NULL.
/// Field: init
/// A callback to allow the client to initialize the tap processor. Can be NULL.
/// This callback is called before MTAudioProcessingTapCreate() returns.
/// Field: finalize
/// A callback to allow the client to perform any necessary cleanup. Can be NULL.
/// This callback will be called exactly once when the MTAudioProcessingTap object is finalized.
/// Field: prepare
/// A callback to allow the client to prepare the tap processor (allocate memory buffers, etc). Can be NULL.
/// Note that the callback may be called multiple times.
/// Field: unprepare
/// A callback to allow the client to perform any necessary cleanup for which that is prepared. Can be NULL.
/// Field: process
/// A callback for processing the audio.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/mediatoolbox/mtaudioprocessingtapcallbacks?language=objc)
unsafe
unsafe
extern "C-unwind"
pub unsafe extern "C-unwind"
extern "C-unwind"