objc2_audio_toolbox/generated/AudioQueue.rs
1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::cell::UnsafeCell;
4use core::ffi::*;
5use core::marker::{PhantomData, PhantomPinned};
6use core::ptr::NonNull;
7#[cfg(feature = "dispatch2")]
8use dispatch2::*;
9use objc2::__framework_prelude::*;
10#[cfg(feature = "objc2-core-audio-types")]
11use objc2_core_audio_types::*;
12#[cfg(feature = "objc2-core-foundation")]
13use objc2_core_foundation::*;
14
15use crate::*;
16
17/// A value that uniquely identifies an audio queue property.
18///
19/// See also [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/audioqueuepropertyid?language=objc)
20pub type AudioQueuePropertyID = u32;
21
22/// A value that uniquely identifies an audio queue parameter.
23///
24/// See also [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/audioqueueparameterid?language=objc)
25pub type AudioQueueParameterID = u32;
26
27/// A value for an audio queue parameter.
28///
29/// See also [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/audioqueueparametervalue?language=objc)
30pub type AudioQueueParameterValue = f32;
31
32/// [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/opaqueaudioqueue?language=objc)
33#[repr(C)]
34#[derive(Debug)]
35pub struct OpaqueAudioQueue {
36 inner: [u8; 0],
37 _p: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
38}
39
40unsafe impl RefEncode for OpaqueAudioQueue {
41 const ENCODING_REF: Encoding = Encoding::Pointer(&Encoding::Struct("OpaqueAudioQueue", &[]));
42}
43
44/// An opaque data type that represents an audio queue.
45///
46/// See also [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/audioqueueref?language=objc)
47pub type AudioQueueRef = *mut OpaqueAudioQueue;
48
49/// [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/opaqueaudioqueuetimeline?language=objc)
50#[repr(C)]
51#[derive(Debug)]
52pub struct OpaqueAudioQueueTimeline {
53 inner: [u8; 0],
54 _p: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
55}
56
57unsafe impl RefEncode for OpaqueAudioQueueTimeline {
58 const ENCODING_REF: Encoding =
59 Encoding::Pointer(&Encoding::Struct("OpaqueAudioQueueTimeline", &[]));
60}
61
62/// An opaque data type that represents an audio queue timeline.
63///
64/// You can use this object to observe any overloads in the audio device associated with the
65/// audio queue. A timeline object receives notifications of discontinuities in the audio
66/// hardware's sample timeline--for instance, a period of silence when sound was expected.
67/// Causes of discontinuities include changes in the device state or processing overloads.
68/// See Technical Q
69/// &
70/// A: QA 1467 for a discussion of Core Audio overload warnings. These
71/// warnings indicate you are taking too long to process audio data and the system has cut
72/// you off. You query a timeline object by passing it as a parameter to
73/// AudioQueueGetCurrentTime, which means a discontinuity has occurred.
74///
75/// See also [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/audioqueuetimelineref?language=objc)
76pub type AudioQueueTimelineRef = *mut OpaqueAudioQueueTimeline;
77
78/// [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/kaudioqueueerr_invalidbuffer?language=objc)
79pub const kAudioQueueErr_InvalidBuffer: OSStatus = -66687;
80/// [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/kaudioqueueerr_bufferempty?language=objc)
81pub const kAudioQueueErr_BufferEmpty: OSStatus = -66686;
82/// [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/kaudioqueueerr_disposalpending?language=objc)
83pub const kAudioQueueErr_DisposalPending: OSStatus = -66685;
84/// [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/kaudioqueueerr_invalidproperty?language=objc)
85pub const kAudioQueueErr_InvalidProperty: OSStatus = -66684;
86/// [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/kaudioqueueerr_invalidpropertysize?language=objc)
87pub const kAudioQueueErr_InvalidPropertySize: OSStatus = -66683;
88/// [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/kaudioqueueerr_invalidparameter?language=objc)
89pub const kAudioQueueErr_InvalidParameter: OSStatus = -66682;
90/// [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/kaudioqueueerr_cannotstart?language=objc)
91pub const kAudioQueueErr_CannotStart: OSStatus = -66681;
92/// [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/kaudioqueueerr_invaliddevice?language=objc)
93pub const kAudioQueueErr_InvalidDevice: OSStatus = -66680;
94/// [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/kaudioqueueerr_bufferinqueue?language=objc)
95pub const kAudioQueueErr_BufferInQueue: OSStatus = -66679;
96/// [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/kaudioqueueerr_invalidrunstate?language=objc)
97pub const kAudioQueueErr_InvalidRunState: OSStatus = -66678;
98/// [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/kaudioqueueerr_invalidqueuetype?language=objc)
99pub const kAudioQueueErr_InvalidQueueType: OSStatus = -66677;
100/// [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/kaudioqueueerr_permissions?language=objc)
101pub const kAudioQueueErr_Permissions: OSStatus = -66676;
102/// [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/kaudioqueueerr_invalidpropertyvalue?language=objc)
103pub const kAudioQueueErr_InvalidPropertyValue: OSStatus = -66675;
104/// [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/kaudioqueueerr_primetimedout?language=objc)
105pub const kAudioQueueErr_PrimeTimedOut: OSStatus = -66674;
106/// [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/kaudioqueueerr_codecnotfound?language=objc)
107pub const kAudioQueueErr_CodecNotFound: OSStatus = -66673;
108/// [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/kaudioqueueerr_invalidcodecaccess?language=objc)
109pub const kAudioQueueErr_InvalidCodecAccess: OSStatus = -66672;
110/// [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/kaudioqueueerr_queueinvalidated?language=objc)
111pub const kAudioQueueErr_QueueInvalidated: OSStatus = -66671;
112/// [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/kaudioqueueerr_toomanytaps?language=objc)
113pub const kAudioQueueErr_TooManyTaps: OSStatus = -66670;
114/// [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/kaudioqueueerr_invalidtapcontext?language=objc)
115pub const kAudioQueueErr_InvalidTapContext: OSStatus = -66669;
116/// [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/kaudioqueueerr_recordunderrun?language=objc)
117pub const kAudioQueueErr_RecordUnderrun: OSStatus = -66668;
118/// [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/kaudioqueueerr_invalidtaptype?language=objc)
119pub const kAudioQueueErr_InvalidTapType: OSStatus = -66667;
120/// [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/kaudioqueueerr_bufferenqueuedtwice?language=objc)
121pub const kAudioQueueErr_BufferEnqueuedTwice: OSStatus = -66666;
122/// [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/kaudioqueueerr_cannotstartyet?language=objc)
123pub const kAudioQueueErr_CannotStartYet: OSStatus = -66665;
124/// [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/kaudioqueueerr_enqueueduringreset?language=objc)
125pub const kAudioQueueErr_EnqueueDuringReset: OSStatus = -66632;
126/// [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/kaudioqueueerr_invalidofflinemode?language=objc)
127pub const kAudioQueueErr_InvalidOfflineMode: OSStatus = -66626;
128
129/// value is UInt32
130///
131/// See also [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/kaudioqueueproperty_isrunning?language=objc)
132pub const kAudioQueueProperty_IsRunning: AudioQueuePropertyID = 0x6171726e;
133/// [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/kaudioqueuedeviceproperty_samplerate?language=objc)
134pub const kAudioQueueDeviceProperty_SampleRate: AudioQueuePropertyID = 0x61717372;
135/// [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/kaudioqueuedeviceproperty_numberchannels?language=objc)
136pub const kAudioQueueDeviceProperty_NumberChannels: AudioQueuePropertyID = 0x61716463;
137/// [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/kaudioqueueproperty_currentdevice?language=objc)
138pub const kAudioQueueProperty_CurrentDevice: AudioQueuePropertyID = 0x61716364;
139/// [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/kaudioqueueproperty_magiccookie?language=objc)
140pub const kAudioQueueProperty_MagicCookie: AudioQueuePropertyID = 0x61716d63;
141/// [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/kaudioqueueproperty_maximumoutputpacketsize?language=objc)
142pub const kAudioQueueProperty_MaximumOutputPacketSize: AudioQueuePropertyID = 0x786f7073;
143/// [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/kaudioqueueproperty_streamdescription?language=objc)
144pub const kAudioQueueProperty_StreamDescription: AudioQueuePropertyID = 0x61716674;
145/// [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/kaudioqueueproperty_channellayout?language=objc)
146pub const kAudioQueueProperty_ChannelLayout: AudioQueuePropertyID = 0x6171636c;
147/// [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/kaudioqueueproperty_enablelevelmetering?language=objc)
148pub const kAudioQueueProperty_EnableLevelMetering: AudioQueuePropertyID = 0x61716d65;
149/// [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/kaudioqueueproperty_currentlevelmeter?language=objc)
150pub const kAudioQueueProperty_CurrentLevelMeter: AudioQueuePropertyID = 0x61716d76;
151/// [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/kaudioqueueproperty_currentlevelmeterdb?language=objc)
152pub const kAudioQueueProperty_CurrentLevelMeterDB: AudioQueuePropertyID = 0x61716d64;
153/// [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/kaudioqueueproperty_decodebuffersizeframes?language=objc)
154pub const kAudioQueueProperty_DecodeBufferSizeFrames: AudioQueuePropertyID = 0x64636266;
155/// [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/kaudioqueueproperty_convertererror?language=objc)
156pub const kAudioQueueProperty_ConverterError: AudioQueuePropertyID = 0x71637665;
157/// [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/kaudioqueueproperty_enabletimepitch?language=objc)
158pub const kAudioQueueProperty_EnableTimePitch: AudioQueuePropertyID = 0x715f7470;
159/// [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/kaudioqueueproperty_timepitchalgorithm?language=objc)
160pub const kAudioQueueProperty_TimePitchAlgorithm: AudioQueuePropertyID = 0x71747061;
161/// [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/kaudioqueueproperty_timepitchbypass?language=objc)
162pub const kAudioQueueProperty_TimePitchBypass: AudioQueuePropertyID = 0x71747062;
163/// [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/kaudioqueueproperty_intendedspatialexperience?language=objc)
164pub const kAudioQueueProperty_IntendedSpatialExperience: AudioQueuePropertyID = 0x6973656f;
165
166/// [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/kaudioqueuetimepitchalgorithm_spectral?language=objc)
167pub const kAudioQueueTimePitchAlgorithm_Spectral: u32 = 0x73706563;
168/// [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/kaudioqueuetimepitchalgorithm_timedomain?language=objc)
169pub const kAudioQueueTimePitchAlgorithm_TimeDomain: u32 = 0x7469646f;
170/// [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/kaudioqueuetimepitchalgorithm_varispeed?language=objc)
171pub const kAudioQueueTimePitchAlgorithm_Varispeed: u32 = 0x76737064;
172
173/// [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/kaudioqueueproperty_channelassignments?language=objc)
174pub const kAudioQueueProperty_ChannelAssignments: AudioQueuePropertyID = 0x61716361;
175
176/// [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/kaudioqueueparam_volume?language=objc)
177pub const kAudioQueueParam_Volume: AudioQueueParameterID = 1;
178/// [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/kaudioqueueparam_playrate?language=objc)
179pub const kAudioQueueParam_PlayRate: AudioQueueParameterID = 2;
180/// [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/kaudioqueueparam_pitch?language=objc)
181pub const kAudioQueueParam_Pitch: AudioQueueParameterID = 3;
182/// [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/kaudioqueueparam_volumeramptime?language=objc)
183pub const kAudioQueueParam_VolumeRampTime: AudioQueueParameterID = 4;
184/// [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/kaudioqueueparam_pan?language=objc)
185pub const kAudioQueueParam_Pan: AudioQueueParameterID = 13;
186
187/// Flags used in conjunction with processing taps
188///
189/// In the flags passed to AudioQueueProcessingTapNew, either the PreEffects
190/// or PostEffects flag must be set, but not both.
191///
192///
193/// Signifies that the processing tap is inserted before any effects.
194/// Passed to AudioQueueProcessingTapNew and to the callback.
195///
196/// Signifies that the processing tap is inserted after any effects.
197/// Passed to AudioQueueProcessingTapNew and to the callback.
198///
199/// Signifies that the processing tap is a siphon; it does not call
200/// GetSourceAudio. The callback instead receives the source audio
201/// and may not modify it. Passed to AudioQueueProcessingTapNew and to the callback.
202///
203/// Signifies that the source audio is the beginning of a continuous stream,
204/// i.e. following the beginning or resumption of playback or recording.
205/// Returned from GetSourceAudio.
206///
207/// Signifies that the source audio is past the end of stream. This happens when
208/// the audio queue is being stopped asynchronously and has finished playing
209/// all of its data. Returned from GetSourceAudio and should be propagated
210/// on return from the callback.
211///
212/// See also [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/audioqueueprocessingtapflags?language=objc)
213// NS_OPTIONS
214#[repr(transparent)]
215#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
216pub struct AudioQueueProcessingTapFlags(pub u32);
217bitflags::bitflags! {
218 impl AudioQueueProcessingTapFlags: u32 {
219 #[doc(alias = "kAudioQueueProcessingTap_PreEffects")]
220 const PreEffects = 1<<0;
221 #[doc(alias = "kAudioQueueProcessingTap_PostEffects")]
222 const PostEffects = 1<<1;
223 #[doc(alias = "kAudioQueueProcessingTap_Siphon")]
224 const Siphon = 1<<2;
225 #[doc(alias = "kAudioQueueProcessingTap_StartOfStream")]
226 const StartOfStream = 1<<8;
227 #[doc(alias = "kAudioQueueProcessingTap_EndOfStream")]
228 const EndOfStream = 1<<9;
229 }
230}
231
232unsafe impl Encode for AudioQueueProcessingTapFlags {
233 const ENCODING: Encoding = u32::ENCODING;
234}
235
236unsafe impl RefEncode for AudioQueueProcessingTapFlags {
237 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
238}
239
240/// Defines a buffer of audio data to be managed by an audio queue.
241///
242/// Each audio queue has an associated set of audio queue buffers. You can request that a
243/// queue allocate buffers using the AudioQueueAllocateBuffer function and dispose of them
244/// using the AudioQueueFreeBuffer function.
245///
246/// You may also use AudioQueueAllocateBufferWithPacketDescriptions to allocate buffers
247/// with space for AudioPacketDescriptions, as used in VBR formats. The
248/// mPacketDescriptionCapacity, mmPacketDescriptions, and mPacketDescriptionCount
249/// fields may only be used with buffers allocated with this function.
250///
251///
252/// The size of the buffer, in bytes. This size is set when the buffer is allocated and
253/// cannot be changed.
254///
255/// A pointer to the audio data in the buffer. Although you can write data to this buffer,
256/// you cannot make it point to another address.
257///
258/// The number of bytes of valid audio data in the buffer. You set this value when providing
259/// data for playback; the audio queue sets this value when recording data from a recording
260/// queue.
261///
262/// A value you may specify to identify the buffer when it is passed back in recording or
263/// playback callback functions.
264///
265/// The maximum number of packet descriptions that can be stored in mPacketDescriptions.
266///
267/// An array of AudioStreamPacketDescriptions associated with the buffer.
268///
269/// The number of valid packet descriptions in the buffer. You set this value when providing
270/// buffers for playback; the audio queue sets this value when returning buffers from
271/// a recording queue.
272///
273/// See also [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/audioqueuebuffer?language=objc)
274#[cfg(feature = "objc2-core-audio-types")]
275#[repr(C)]
276#[derive(Clone, Copy, Debug, PartialEq)]
277pub struct AudioQueueBuffer {
278 pub mAudioDataBytesCapacity: u32,
279 pub mAudioData: NonNull<c_void>,
280 pub mAudioDataByteSize: u32,
281 pub mUserData: *mut c_void,
282 pub mPacketDescriptionCapacity: u32,
283 pub mPacketDescriptions: *const AudioStreamPacketDescription,
284 pub mPacketDescriptionCount: u32,
285}
286
287#[cfg(feature = "objc2-core-audio-types")]
288unsafe impl Encode for AudioQueueBuffer {
289 const ENCODING: Encoding = Encoding::Struct(
290 "AudioQueueBuffer",
291 &[
292 <u32>::ENCODING,
293 <NonNull<c_void>>::ENCODING,
294 <u32>::ENCODING,
295 <*mut c_void>::ENCODING,
296 <u32>::ENCODING,
297 <*const AudioStreamPacketDescription>::ENCODING,
298 <u32>::ENCODING,
299 ],
300 );
301}
302
303#[cfg(feature = "objc2-core-audio-types")]
304unsafe impl RefEncode for AudioQueueBuffer {
305 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
306}
307
308/// An pointer to an AudioQueueBuffer.
309///
310/// See also [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/audioqueuebufferref?language=objc)
311#[cfg(feature = "objc2-core-audio-types")]
312pub type AudioQueueBufferRef = *mut AudioQueueBuffer;
313
314/// Specifies a value for an audio queue parameter.
315///
316/// Two ways are available to supply an audio queue with parameters:
317///
318/// - Provide one or more parameters by calling the AudioQueueEnqueueBufferWithParameters
319/// function. In this case, the parameters are applied to the specified buffer when it is
320/// played.
321///
322/// - Assign a parameter value immediately to an audio queue by calling the
323/// AudioQueueSetParameter function.
324///
325/// Note that the AudioQueueGetParameter function always returns the actual value of the
326/// parameter.
327///
328/// In macOS v10.5, audio queues have one parameter available: kAudioQueueParam_Volume,
329/// which controls the queue's playback volume.
330///
331///
332/// The parameter.
333///
334/// The value of the specified parameter.
335///
336/// See also [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/audioqueueparameterevent?language=objc)
337#[repr(C)]
338#[derive(Clone, Copy, Debug, PartialEq)]
339pub struct AudioQueueParameterEvent {
340 pub mID: AudioQueueParameterID,
341 pub mValue: AudioQueueParameterValue,
342}
343
344unsafe impl Encode for AudioQueueParameterEvent {
345 const ENCODING: Encoding = Encoding::Struct(
346 "AudioQueueParameterEvent",
347 &[
348 <AudioQueueParameterID>::ENCODING,
349 <AudioQueueParameterValue>::ENCODING,
350 ],
351 );
352}
353
354unsafe impl RefEncode for AudioQueueParameterEvent {
355 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
356}
357
358/// Specifies the current level metering information for one channel of an audio queue.
359///
360/// The audio channel's average RMS power.
361///
362/// The audio channel's peak RMS power
363///
364/// See also [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/audioqueuelevelmeterstate?language=objc)
365#[repr(C)]
366#[derive(Clone, Copy, Debug, PartialEq)]
367pub struct AudioQueueLevelMeterState {
368 pub mAveragePower: f32,
369 pub mPeakPower: f32,
370}
371
372unsafe impl Encode for AudioQueueLevelMeterState {
373 const ENCODING: Encoding = Encoding::Struct(
374 "AudioQueueLevelMeterState",
375 &[<f32>::ENCODING, <f32>::ENCODING],
376 );
377}
378
379unsafe impl RefEncode for AudioQueueLevelMeterState {
380 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
381}
382
383/// [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/opaqueaudioqueueprocessingtap?language=objc)
384#[repr(C)]
385#[derive(Debug)]
386pub struct OpaqueAudioQueueProcessingTap {
387 inner: [u8; 0],
388 _p: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
389}
390
391unsafe impl RefEncode for OpaqueAudioQueueProcessingTap {
392 const ENCODING_REF: Encoding =
393 Encoding::Pointer(&Encoding::Struct("OpaqueAudioQueueProcessingTap", &[]));
394}
395
396/// An object for intercepting and processing audio within an audio queue.
397///
398/// See also [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/audioqueueprocessingtapref?language=objc)
399pub type AudioQueueProcessingTapRef = *mut OpaqueAudioQueueProcessingTap;
400
401/// Specifies an audio device channel to which the queue will play or from which
402/// it will record.
403///
404/// On iOS, this is a port UID obtained from AVAudioSession. On macOS, this is the UID
405/// obtained from an AudioDeviceID.
406///
407/// The 1-based index of the channel.
408///
409/// See also [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/audioqueuechannelassignment?language=objc)
410#[cfg(feature = "objc2-core-foundation")]
411#[repr(C)]
412#[derive(Clone, Copy, Debug, PartialEq)]
413pub struct AudioQueueChannelAssignment {
414 pub mDeviceUID: NonNull<CFString>,
415 pub mChannelNumber: u32,
416}
417
418#[cfg(feature = "objc2-core-foundation")]
419unsafe impl Encode for AudioQueueChannelAssignment {
420 const ENCODING: Encoding = Encoding::Struct(
421 "AudioQueueChannelAssignment",
422 &[<NonNull<CFString>>::ENCODING, <u32>::ENCODING],
423 );
424}
425
426#[cfg(feature = "objc2-core-foundation")]
427unsafe impl RefEncode for AudioQueueChannelAssignment {
428 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
429}
430
431/// Defines a pointer to a block that is called when a playback audio
432/// queue has finished taking data from a buffer.
433///
434/// A playback buffer callback is invoked when the audio queue has finished with the data to
435/// be played and the buffer is available to your application for reuse. Your application
436/// might want to immediately refill and re-enqueue the completed buffer at this time.
437///
438///
439/// Parameter `inAQ`: The audio queue that invoked the callback.
440///
441/// Parameter `inBuffer`: The audio queue buffer made available by the audio queue.
442///
443/// See also [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/audioqueueoutputcallbackblock?language=objc)
444#[cfg(all(feature = "block2", feature = "objc2-core-audio-types"))]
445pub type AudioQueueOutputCallbackBlock =
446 *mut block2::DynBlock<dyn Fn(AudioQueueRef, AudioQueueBufferRef)>;
447
448/// Defines a pointer to a block that is called when a recording audio
449/// queue has finished filling a buffer.
450///
451/// You specify a recording buffer callback when calling AudioQueueNewInput. Your callback
452/// is invoked each time the recording audio queue has filled a buffer with input data.
453/// Typically, your callback should write the audio queue buffer's data to a file or other
454/// buffer, and then re-queue the audio queue buffer to receive more data.
455///
456///
457/// Parameter `inAQ`: The audio queue that invoked the callback.
458///
459/// Parameter `inBuffer`: An audio queue buffer, newly filled by the audio queue, containing the new audio data
460/// your callback needs to write.
461///
462/// Parameter `inStartTime`: A pointer to an audio time stamp structure corresponding to the first sample contained
463/// in the buffer. This contains the sample time of the first sample in the buffer.
464///
465/// Parameter `inNumberPacketDescriptions`: The number of audio packets contained in the data provided to the callback
466///
467/// Parameter `inPacketDescs`: For compressed formats which require packet descriptions, the packet descriptions
468/// produced by the encoder for the incoming buffer.
469///
470/// See also [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/audioqueueinputcallbackblock?language=objc)
471#[cfg(all(feature = "block2", feature = "objc2-core-audio-types"))]
472pub type AudioQueueInputCallbackBlock = *mut block2::DynBlock<
473 dyn Fn(
474 AudioQueueRef,
475 AudioQueueBufferRef,
476 NonNull<AudioTimeStamp>,
477 u32,
478 *const AudioStreamPacketDescription,
479 ),
480>;
481
482/// Defines a pointer to a callback function that is called when a playback audio
483/// queue has finished taking data from a buffer.
484///
485/// A playback buffer callback is invoked when the audio queue has finished with the data to
486/// be played and the buffer is available to your application for reuse. Your application
487/// might want to immediately refill and re-enqueue the completed buffer at this time.
488///
489///
490/// Parameter `inUserData`: The value specified by the inUserData parameter of the AudioQueueNewOutput function.
491///
492/// Parameter `inAQ`: The audio queue that invoked the callback.
493///
494/// Parameter `inBuffer`: The audio queue buffer made available by the audio queue.
495///
496/// See also [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/audioqueueoutputcallback?language=objc)
497#[cfg(feature = "objc2-core-audio-types")]
498pub type AudioQueueOutputCallback =
499 Option<unsafe extern "C-unwind" fn(*mut c_void, AudioQueueRef, AudioQueueBufferRef)>;
500
501/// Defines a pointer to a callback function that is called when a recording audio
502/// queue has finished filling a buffer.
503///
504/// You specify a recording buffer callback when calling AudioQueueNewInput. Your callback
505/// is invoked each time the recording audio queue has filled a buffer with input data.
506/// Typically, your callback should write the audio queue buffer's data to a file or other
507/// buffer, and then re-queue the audio queue buffer to receive more data.
508///
509///
510/// Parameter `inUserData`: The value you've specified in the inUserData parameter of the AudioQueueNewInput
511/// function.
512///
513/// Parameter `inAQ`: The audio queue that invoked the callback.
514///
515/// Parameter `inBuffer`: An audio queue buffer, newly filled by the audio queue, containing the new audio data
516/// your callback needs to write.
517///
518/// Parameter `inStartTime`: A pointer to an audio time stamp structure corresponding to the first sample contained
519/// in the buffer. This contains the sample time of the first sample in the buffer.
520///
521/// Parameter `inNumberPacketDescriptions`: The number of audio packets contained in the data provided to the callback
522///
523/// Parameter `inPacketDescs`: For compressed formats which require packet descriptions, the packet descriptions
524/// produced by the encoder for the incoming buffer.
525///
526/// See also [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/audioqueueinputcallback?language=objc)
527#[cfg(feature = "objc2-core-audio-types")]
528pub type AudioQueueInputCallback = Option<
529 unsafe extern "C-unwind" fn(
530 *mut c_void,
531 AudioQueueRef,
532 AudioQueueBufferRef,
533 NonNull<AudioTimeStamp>,
534 u32,
535 *const AudioStreamPacketDescription,
536 ),
537>;
538
539/// Defines a pointer to a callback function that is called when a specified
540/// property changes value.
541///
542/// You assign a property listener callback when calling AudioQueueAddPropertyListener.
543///
544///
545/// Parameter `inUserData`: A pointer to the data specified by the inUserData parameter of the
546/// AudioQueueAddPropertyListener function.
547///
548/// Parameter `inAQ`: The audio queue that invoked the callback.
549///
550/// Parameter `inID`: The ID of the property that invoked the callback.
551///
552/// See also [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/audioqueuepropertylistenerproc?language=objc)
553pub type AudioQueuePropertyListenerProc =
554 Option<unsafe extern "C-unwind" fn(*mut c_void, AudioQueueRef, AudioQueuePropertyID)>;
555
556/// A function called when an audio queue has data to be processed by its tap
557///
558/// A processing callback is invoked when the audio queue has data that can be processed by a given
559/// tap.
560///
561/// The audio queue will call the processing callback when it has sufficient data to provide for
562/// processing.
563///
564/// In the case of a siphoning tap, the callback function can inspect the audio data in ioData, but
565/// should not otherwise modify it. The callback should not call
566/// AudioQueueProcessingTapGetSourceAudio.
567///
568/// A non-siphoning callback should call AudioQueueProcessingTapGetSourceAudio to request from the
569/// queue as much source data as it needs in order to produce the requested number of output
570/// samples. When the callback requests source data it may receive less data than it requests.
571///
572/// In the case of a tap on an audio output queue, the tap must emit the exact number of sample
573/// frames that the queue requests. In normal circumstances, the tap's requests for source data will
574/// be satisfied (as the client running the audio queue is also providing the queue with the audio
575/// source material). If there is insufficient source data available (this is indicated by the
576/// outNumberFrames from the GetSource call), then the processing tap should deal as best as it can;
577/// it can either return less data than was requested or insert silence, noise, etc. itself. If it
578/// returns less data than requested, the hosting audio queue will fill in the remainder with
579/// silence.
580///
581/// In the case of a tap on an audio input queue, the tap may provide back less audio data than is
582/// being requested. Typically this will occur because the tap will ask for source data that is not
583/// available at this time (the audio input hasn't arrived yet), so the tap should cache the source
584/// data that it needs and return as many processed samples as it can. If the processing tap falls
585/// behind and is not providing data quickly enough silence will be generated in the data provided
586/// to the client (and there is no signal about this either).
587///
588/// A processing tap executes in a semi-real-time context, so the general limitations for real-time
589/// processing apply. Avoid using API's which may block. In particular, it is not safe to call the
590/// audio queue on which the tap was installed, with the exceptions of
591/// AudioQueueProcessingTapGetSourceAudio and AudioQueueProcessingTapGetQueueTime.
592///
593/// In normal operation the source data will be continuous from the last time the callback was
594/// called and the processed samples should be continuous from the previous samples returned. If
595/// there is any discontinuity between the last samples provided for processing the audio queue will
596/// set the bit for kAudioQueueProcessing_StartOfStream in the inFlags. After a discontinuity the
597/// first sample that the processing tap outputs should correspond to the first sample that was
598/// provided in the source samples (so a reset and then consequent process serves to re-anchor a
599/// relationship between the processing tap's source and processed samples). In this case the
600/// processing tap will typically discard any previous state (for instance, if a processing tap was
601/// adding a reverb to a signal, then the discontinuity flag would act the same as AudioUnitReset;
602/// any previous source information in the processing tap should be discarded).
603///
604/// The caller is responsible for absorbing any processing delays. For example, if the processing is
605/// to be done by an audio unit that reports a processing latency, then the caller should remove
606/// those latency samples from the audio unit's rendering and not return them to the audio queue.
607///
608/// The processing tap is able to operate on the provided source data in place (that is, it can do
609/// "in place processing") and return pointers to that buffer rather than its own. This works in a
610/// similar way as AudioUnit render operations.
611///
612/// When an output audio queue is being stopped asynchronously, the processing tap will see the
613/// kAudioQueueProcessingTap_EndOfStream bit set on return from GetSourceAudio, and is responsible
614/// for propagating this bit from the callback when its processing has reached this point.
615///
616/// A processing tap will NEVER see the same source data again, so, it should keep its own copy if
617/// it needs to keep it for further reference past the duration of this call. It also cannot assume
618/// that the pointers to the source data that it retrieves will remain valid AFTER the processing
619/// tap has executed.
620///
621/// The processing tap should ensure that the data pointers it provides in outProcessedData remain
622/// valid until the tap is executed again.
623///
624/// A processing tap is destroyed implicitly when its audio queue is disposed. It may also be
625/// removed explicitly, via AudioQueueProcessingTapDispose.
626///
627///
628/// Parameter `inClientData`: the client data pointer passed to AudioQueueProcessingTapNew
629///
630/// Parameter `inAQTap`: The tap for this callback.
631///
632/// Parameter `inNumberFrames`: The requested number of sample frames to be rendered.
633///
634/// Parameter `ioFlags`: On entry, the flags passed at construction time are provided. On exit,
635/// the start/end of stream flags should be set when appropriate.
636///
637/// Parameter `ioTimeStamp`: On an input audio queue, the timestamp must be returned from this function.
638/// On an output audio queue, the callback is provided a continuous timestamp.
639///
640/// Parameter `outNumberFrames`: The number of frames of audio data provided in the processed data. Can be 0.
641///
642/// Parameter `ioData`: For non-siphoning taps, on entry, the buffer pointers are null and the lengths
643/// are zero. On exit, they should contain the tap's output.
644///
645/// Siphoning taps receive valid buffers which they must not alter.
646///
647/// See also [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/audioqueueprocessingtapcallback?language=objc)
648#[cfg(feature = "objc2-core-audio-types")]
649pub type AudioQueueProcessingTapCallback = Option<
650 unsafe extern "C-unwind" fn(
651 NonNull<c_void>,
652 AudioQueueProcessingTapRef,
653 u32,
654 NonNull<AudioTimeStamp>,
655 NonNull<AudioQueueProcessingTapFlags>,
656 NonNull<u32>,
657 NonNull<AudioBufferList>,
658 ),
659>;
660
661extern "C-unwind" {
662 /// Creates a new audio queue for playing audio data.
663 ///
664 /// To create an playback audio queue, you allocate buffers, then queue buffers (using
665 /// AudioQueueEnqueueBuffer). The callback receives buffers and typically queues them again.
666 /// To schedule a buffer for playback, providing parameter and start time information, call
667 /// AudioQueueEnqueueBufferWithParameters.
668 ///
669 ///
670 /// Parameter `inFormat`: A pointer to a structure describing the format of the audio data to be played. For
671 /// linear PCM, only interleaved formats are supported. Compressed formats are supported.
672 ///
673 /// Parameter `inCallbackProc`: A pointer to a callback function to be called when the audio queue has finished playing
674 /// a buffer.
675 ///
676 /// Parameter `inUserData`: A value or pointer to data that you specify to be passed to the callback function.
677 ///
678 /// Parameter `inCallbackRunLoop`: The event loop on which inCallbackProc is to be called. If you specify NULL, the
679 /// callback is called on one of the audio queue's internal threads.
680 ///
681 /// Parameter `inCallbackRunLoopMode`: The run loop mode in which to call the callback. Typically, you pass
682 /// kCFRunLoopCommonModes. (NULL also specifies kCFRunLoopCommonModes). Other
683 /// possibilities are implementation specific. You can choose to create your own thread with
684 /// your own run loops. For more information on run loops, see Run Loops or CFRunLoop
685 /// Reference.
686 ///
687 /// Parameter `inFlags`: Reserved for future use. Pass 0.
688 ///
689 /// Parameter `outAQ`: On return, this variable contains a pointer to the newly created playback audio queue
690 /// object.
691 ///
692 /// Returns: An OSStatus result code.
693 ///
694 /// # Safety
695 ///
696 /// - `in_format` must be a valid pointer.
697 /// - `in_callback_proc` must be implemented correctly.
698 /// - `in_user_data` must be a valid pointer or null.
699 /// - `in_callback_run_loop` possibly has additional threading requirements.
700 /// - `out_aq` must be a valid pointer.
701 #[cfg(all(feature = "objc2-core-audio-types", feature = "objc2-core-foundation"))]
702 pub fn AudioQueueNewOutput(
703 in_format: NonNull<AudioStreamBasicDescription>,
704 in_callback_proc: AudioQueueOutputCallback,
705 in_user_data: *mut c_void,
706 in_callback_run_loop: Option<&CFRunLoop>,
707 in_callback_run_loop_mode: Option<&CFString>,
708 in_flags: u32,
709 out_aq: NonNull<AudioQueueRef>,
710 ) -> OSStatus;
711}
712
713extern "C-unwind" {
714 /// Creates a new audio queue for recording audio data.
715 ///
716 /// Outline of how to use the queue for input:
717 ///
718 /// - create input queue
719 /// - allocate buffers
720 /// - enqueue buffers (AudioQueueEnqueueBuffer, not with parameters, no packet descriptions)
721 /// - the callback receives buffers and re-enqueues them
722 ///
723 ///
724 /// Parameter `inFormat`: A pointer to a structure describing the format of the audio data to be recorded. For
725 /// linear PCM, only interleaved formats are supported. Compressed formats are supported.
726 ///
727 /// Parameter `inCallbackProc`: A pointer to a callback function to be called when the audio queue has finished filling
728 /// a buffer.
729 ///
730 /// Parameter `inUserData`: A value or pointer to data that you specify to be passed to the callback function.
731 ///
732 /// Parameter `inCallbackRunLoop`: The event loop on which inCallbackProc is to be called. If you specify NULL, the
733 /// callback is called on one of the audio queue's internal threads.
734 ///
735 /// Parameter `inCallbackRunLoopMode`: The run loop mode in which to call the callback. Typically, you pass
736 /// kCFRunLoopCommonModes. (NULL also specifies kCFRunLoopCommonModes). Other
737 /// possibilities are implementation specific. You can choose to create your own thread with
738 /// your own run loops. For more information on run loops, see Run Loops or CFRunLoop
739 /// Reference.
740 ///
741 /// Parameter `inFlags`: Reserved for future use. Pass 0.
742 ///
743 /// Parameter `outAQ`: On return, this variable contains a pointer to the newly created recording audio queue
744 /// object.
745 ///
746 /// Returns: An OSStatus result code.
747 ///
748 /// # Safety
749 ///
750 /// - `in_format` must be a valid pointer.
751 /// - `in_callback_proc` must be implemented correctly.
752 /// - `in_user_data` must be a valid pointer or null.
753 /// - `in_callback_run_loop` possibly has additional threading requirements.
754 /// - `out_aq` must be a valid pointer.
755 #[cfg(all(feature = "objc2-core-audio-types", feature = "objc2-core-foundation"))]
756 pub fn AudioQueueNewInput(
757 in_format: NonNull<AudioStreamBasicDescription>,
758 in_callback_proc: AudioQueueInputCallback,
759 in_user_data: *mut c_void,
760 in_callback_run_loop: Option<&CFRunLoop>,
761 in_callback_run_loop_mode: Option<&CFString>,
762 in_flags: u32,
763 out_aq: NonNull<AudioQueueRef>,
764 ) -> OSStatus;
765}
766
767extern "C-unwind" {
768 /// Creates a new audio queue for playing audio data.
769 ///
770 /// To create an playback audio queue, you allocate buffers, then queue buffers (using
771 /// AudioQueueEnqueueBuffer). The callback receives buffers and typically queues them again.
772 /// To schedule a buffer for playback, providing parameter and start time information, call
773 /// AudioQueueEnqueueBufferWithParameters.
774 ///
775 ///
776 /// Parameter `outAQ`: On return, this variable contains a pointer to the newly created playback audio queue
777 /// object.
778 ///
779 /// Parameter `inFormat`: A pointer to a structure describing the format of the audio data to be played. For
780 /// linear PCM, only interleaved formats are supported. Compressed formats are supported.
781 ///
782 /// Parameter `inFlags`: Reserved for future use. Pass 0.
783 ///
784 /// Parameter `inCallbackDispatchQueue`: The dispatch queue from which inCallbackBlock is to be called.
785 ///
786 /// Parameter `inCallbackBlock`: A pointer to a callback block to be called when the audio queue has finished playing
787 /// a buffer.
788 ///
789 /// Returns: An OSStatus result code.
790 ///
791 /// # Safety
792 ///
793 /// - `out_aq` must be a valid pointer.
794 /// - `in_format` must be a valid pointer.
795 /// - `in_callback_dispatch_queue` possibly has additional threading requirements.
796 /// - `in_callback_block` must be a valid pointer.
797 #[cfg(all(
798 feature = "block2",
799 feature = "dispatch2",
800 feature = "objc2-core-audio-types"
801 ))]
802 pub fn AudioQueueNewOutputWithDispatchQueue(
803 out_aq: NonNull<AudioQueueRef>,
804 in_format: NonNull<AudioStreamBasicDescription>,
805 in_flags: u32,
806 in_callback_dispatch_queue: &DispatchQueue,
807 in_callback_block: AudioQueueOutputCallbackBlock,
808 ) -> OSStatus;
809}
810
811extern "C-unwind" {
812 /// Creates a new audio queue for recording audio data.
813 ///
814 /// Outline of how to use the queue for input:
815 ///
816 /// - create input queue
817 /// - allocate buffers
818 /// - enqueue buffers (AudioQueueEnqueueBuffer, not with parameters, no packet descriptions)
819 /// - the callback receives buffers and re-enqueues them
820 ///
821 ///
822 /// Parameter `outAQ`: On return, this variable contains a pointer to the newly created recording audio queue
823 /// object.
824 ///
825 /// Parameter `inFormat`: A pointer to a structure describing the format of the audio data to be recorded. For
826 /// linear PCM, only interleaved formats are supported. Compressed formats are supported.
827 ///
828 /// Parameter `inFlags`: Reserved for future use. Pass 0.
829 ///
830 /// Parameter `inCallbackDispatchQueue`: The dispatch queue from which inCallbackBlock is to be called.
831 ///
832 /// Parameter `inCallbackBlock`: A pointer to a callback block to be called when the audio queue has finished filling
833 /// a buffer.
834 ///
835 /// Returns: An OSStatus result code.
836 ///
837 /// # Safety
838 ///
839 /// - `out_aq` must be a valid pointer.
840 /// - `in_format` must be a valid pointer.
841 /// - `in_callback_dispatch_queue` possibly has additional threading requirements.
842 /// - `in_callback_block` must be a valid pointer.
843 #[cfg(all(
844 feature = "block2",
845 feature = "dispatch2",
846 feature = "objc2-core-audio-types"
847 ))]
848 pub fn AudioQueueNewInputWithDispatchQueue(
849 out_aq: NonNull<AudioQueueRef>,
850 in_format: NonNull<AudioStreamBasicDescription>,
851 in_flags: u32,
852 in_callback_dispatch_queue: &DispatchQueue,
853 in_callback_block: AudioQueueInputCallbackBlock,
854 ) -> OSStatus;
855}
856
857/// Disposes an existing audio queue.
858///
859/// Disposing of the audio queue also disposes of all its resources, including its buffers.
860///
861///
862/// Parameter `inAQ`: The audio queue you want to dispose of
863///
864/// Parameter `inImmediate`: If you pass true, the audio queue is disposed of immediately (that is, synchronously).
865/// If you pass false, disposal does not take place until all enqueued buffers are
866/// processed. Whether you call AudioQueueDispose synchronously or asynchronously, you can
867/// no longer interact with the queue, and the queue no longer invokes any callbacks to your
868/// application after the function returns.
869///
870/// Note that if AudioQueueDispose is called from a buffer completion callback or property
871/// listener, you may receive further callbacks afterwards.
872///
873/// Returns: An OSStatus result code.
874///
875/// # Safety
876///
877/// `in_aq` must be a valid pointer.
878#[inline]
879pub unsafe extern "C-unwind" fn AudioQueueDispose(
880 in_aq: AudioQueueRef,
881 in_immediate: bool,
882) -> OSStatus {
883 extern "C-unwind" {
884 fn AudioQueueDispose(in_aq: AudioQueueRef, in_immediate: Boolean) -> OSStatus;
885 }
886 unsafe { AudioQueueDispose(in_aq, in_immediate as _) }
887}
888
889extern "C-unwind" {
890 /// Asks an audio queue to allocate a buffer.
891 ///
892 /// Once allocated, the pointer to the buffer and the buffer's size are fixed and cannot be
893 /// changed. The mAudioDataByteSize field in the audio queue buffer structure,
894 /// AudioQueueBuffer, is initially set to 0.
895 ///
896 ///
897 /// Parameter `inAQ`: The audio queue you want to allocate a buffer.
898 ///
899 /// Parameter `inBufferByteSize`: The desired size of the new buffer, in bytes. An appropriate buffer size depends on the
900 /// processing you will perform on the data as well as on the audio data format.
901 ///
902 /// Parameter `outBuffer`: On return, points to the newly created audio buffer. The mAudioDataByteSize field in the
903 /// audio queue buffer structure, AudioQueueBuffer, is initially set to 0.
904 ///
905 /// Returns: An OSStatus result code.
906 ///
907 /// # Safety
908 ///
909 /// - `in_aq` must be a valid pointer.
910 /// - `out_buffer` must be a valid pointer.
911 #[cfg(feature = "objc2-core-audio-types")]
912 pub fn AudioQueueAllocateBuffer(
913 in_aq: AudioQueueRef,
914 in_buffer_byte_size: u32,
915 out_buffer: NonNull<AudioQueueBufferRef>,
916 ) -> OSStatus;
917}
918
919extern "C-unwind" {
920 /// Asks an audio queue to allocate a buffer with space for packet descriptions.
921 ///
922 /// Once allocated, the pointer to the buffer and the buffer's size are fixed and cannot be
923 /// changed. The mAudioDataByteSize field in the audio queue buffer structure,
924 /// AudioQueueBuffer, is initially set to 0.
925 ///
926 ///
927 /// Parameter `inAQ`: The audio queue you want to allocate a buffer.
928 ///
929 /// Parameter `inBufferByteSize`: The desired size of the new buffer, in bytes. An appropriate buffer size depends on the
930 /// processing you will perform on the data as well as on the audio data format.
931 ///
932 /// Parameter `inNumberPacketDescriptions`: The desired capacity of the packet description array in the new buffer.
933 ///
934 /// Parameter `outBuffer`: On return, points to the newly created audio buffer. The mAudioDataByteSize field in the
935 /// audio queue buffer structure, AudioQueueBuffer, is initially set to 0.
936 ///
937 /// Returns: An OSStatus result code.
938 ///
939 /// # Safety
940 ///
941 /// - `in_aq` must be a valid pointer.
942 /// - `out_buffer` must be a valid pointer.
943 #[cfg(feature = "objc2-core-audio-types")]
944 pub fn AudioQueueAllocateBufferWithPacketDescriptions(
945 in_aq: AudioQueueRef,
946 in_buffer_byte_size: u32,
947 in_number_packet_descriptions: u32,
948 out_buffer: NonNull<AudioQueueBufferRef>,
949 ) -> OSStatus;
950}
951
952extern "C-unwind" {
953 /// Disposes of an audio queue buffer.
954 ///
955 /// This function disposes of the buffer allocated by AudioQueueAllocateBuffer. Disposing of
956 /// an audio queue also automatically disposes of any associated buffers and timeline
957 /// objects. Call this function only if you want to dispose of a particular buffer while
958 /// continuing to use an audio queue. You can dispose of buffers only when the associated
959 /// queue is stopped (that is, not processing audio data).
960 ///
961 ///
962 /// Parameter `inAQ`: The queue from which the buffer was allocated.
963 ///
964 /// Parameter `inBuffer`: The buffer to be disposed.
965 ///
966 /// Returns: An OSStatus result code.
967 ///
968 /// # Safety
969 ///
970 /// - `in_aq` must be a valid pointer.
971 /// - `in_buffer` must be a valid pointer.
972 #[cfg(feature = "objc2-core-audio-types")]
973 pub fn AudioQueueFreeBuffer(in_aq: AudioQueueRef, in_buffer: AudioQueueBufferRef) -> OSStatus;
974}
975
976extern "C-unwind" {
977 /// Assigns a buffer to an audio queue for recording or playback.
978 ///
979 /// If the buffer was allocated with AudioQueueAllocateBufferWithPacketDescriptions,
980 /// the client should provide packet descriptions in the buffer's mPacketDescriptions
981 /// and mPacketDescriptionCount fields rather than in inPacketDescs and
982 /// inNumPacketDescs, which should be NULL and 0, respectively, in this case.
983 ///
984 /// For an input queue, pass 0 and NULL for inNumPacketDescs and inPacketDescs,
985 /// respectively. Your callback will receive packet descriptions owned by the audio queue.
986 ///
987 ///
988 /// Parameter `inAQ`: The audio queue you are assigning the buffer to.
989 ///
990 /// Parameter `inBuffer`: The buffer to queue (that is, to be recorded into or played from).
991 ///
992 /// Parameter `inNumPacketDescs`: The number of packet descriptions pointed to by the inPacketDescs pointer. Applicable
993 /// only for output queues and required only for variable-bit-rate (VBR) audio formats. Pass
994 /// 0 for input queues (no packet descriptions are required).
995 ///
996 /// Parameter `inPacketDescs`: An array of packet descriptions. Applicable only for output queues and required only for
997 /// variable-bit-rate (VBR) audio formats. Pass NULL for input queues (no packet
998 /// descriptions are required).
999 ///
1000 /// Returns: An OSStatus result code.
1001 ///
1002 /// # Safety
1003 ///
1004 /// - `in_aq` must be a valid pointer.
1005 /// - `in_buffer` must be a valid pointer.
1006 /// - `in_packet_descs` must be a valid pointer or null.
1007 #[cfg(feature = "objc2-core-audio-types")]
1008 pub fn AudioQueueEnqueueBuffer(
1009 in_aq: AudioQueueRef,
1010 in_buffer: AudioQueueBufferRef,
1011 in_num_packet_descs: u32,
1012 in_packet_descs: *const AudioStreamPacketDescription,
1013 ) -> OSStatus;
1014}
1015
1016extern "C-unwind" {
1017 /// Assigns a buffer to an audio queue for playback, providing parameters
1018 /// and start time information.
1019 ///
1020 /// You can exert some control of the buffer queue by using this function. You can assign
1021 /// audio queue settings that are in effect carried by an audio queue buffer as you enqueue
1022 /// it. Hence, these changes only take effect when an audio queue buffer begins playing.
1023 ///
1024 /// This function queues a buffer for playback only, not for recording. Audio queues for
1025 /// recording have no parameters, do not support variable-bit-rate (VBR) formats (which
1026 /// might require trimming), and have a different way to handle timing. When queued for
1027 /// playback, the buffer must contain the audio data to be played back. See
1028 /// AudioQueueEnqueueBuffer for details on queuing a buffer for recording.
1029 ///
1030 /// If the buffer was allocated with AudioQueueAllocateBufferWithPacketDescriptions,
1031 /// the client should provide packet descriptions in the buffer's mPacketDescriptions
1032 /// and mPacketDescriptionCount fields rather than in inPacketDescs and
1033 /// inNumPacketDescs, which should be NULL and 0, respectively, in this case.
1034 ///
1035 ///
1036 /// Parameter `inAQ`: The audio queue associated with the buffer.
1037 ///
1038 /// Parameter `inBuffer`: The buffer to be played from.
1039 ///
1040 /// Parameter `inNumPacketDescs`: The number of packet descriptions pointed to by the inPacketDescs parameter. Required
1041 /// only for variable-bit-rate (VBR) audio formats. Pass 0 if no packet descriptions are
1042 /// required.
1043 ///
1044 /// Parameter `inPacketDescs`: A pointer to an array of audio stream packet descriptions. Required only for VBR audio
1045 /// formats. Pass NULL if no packet descriptions are required.
1046 ///
1047 /// Parameter `inTrimFramesAtStart`: The number of priming frames to skip at the start of the buffer.
1048 ///
1049 /// Parameter `inTrimFramesAtEnd`: The number of frames to skip at the end of the buffer.
1050 ///
1051 /// Parameter `inNumParamValues`: The number of parameter values pointed to by the inParamValues parameter.
1052 ///
1053 /// Parameter `inParamValues`: An array of parameter values. (In macOS v10.5, there is only one parameter,
1054 /// kAudioQueueParam_Volume.) These values are set before buffer playback and cannot be
1055 /// changed while the buffer is playing. How accurately changes in parameters can be
1056 /// scheduled depends on the size of the buffer. If there are no parameters to set
1057 /// (inNumParamValues = 0), pass NULL.
1058 ///
1059 /// Parameter `inStartTime`: A pointer to a structure containing the desired start time for playing the buffer. If
1060 /// you specify the time using the mSampleTime field of the AudioTimeStamp structure, the
1061 /// sample time is relative to the time the queue started. If you pass NULL for the start
1062 /// time, the buffer starts immediately after the previously queued buffer, or as soon as
1063 /// possible if no buffers are queued ahead of it. Buffers are played in the order they are
1064 /// queued. If multiple buffers are queued, their times must be in ascending order or NULL;
1065 /// otherwise, an error occurs. The start time indicates when the actual audio data in the
1066 /// buffer is to be played (that is, the trim frames are not counted).
1067 ///
1068 /// Note: When specifying a start time for a buffer, if the buffer is not the first enqueued
1069 /// since AudioQueueStop or AudioQueueReset, it is normally necessary to call AudioQueueFlush
1070 /// before AudioQueueEnqueueBufferWithParameters.
1071 ///
1072 /// Parameter `outActualStartTime`: On return, points to an AudioTimeStamp structure indicating when the buffer will
1073 /// actually play.
1074 ///
1075 /// Returns: An OSStatus result code.
1076 ///
1077 /// # Safety
1078 ///
1079 /// - `in_aq` must be a valid pointer.
1080 /// - `in_buffer` must be a valid pointer.
1081 /// - `in_packet_descs` must be a valid pointer or null.
1082 /// - `in_param_values` must be a valid pointer or null.
1083 /// - `in_start_time` must be a valid pointer or null.
1084 /// - `out_actual_start_time` must be a valid pointer or null.
1085 #[cfg(feature = "objc2-core-audio-types")]
1086 pub fn AudioQueueEnqueueBufferWithParameters(
1087 in_aq: AudioQueueRef,
1088 in_buffer: AudioQueueBufferRef,
1089 in_num_packet_descs: u32,
1090 in_packet_descs: *const AudioStreamPacketDescription,
1091 in_trim_frames_at_start: u32,
1092 in_trim_frames_at_end: u32,
1093 in_num_param_values: u32,
1094 in_param_values: *const AudioQueueParameterEvent,
1095 in_start_time: *const AudioTimeStamp,
1096 out_actual_start_time: *mut AudioTimeStamp,
1097 ) -> OSStatus;
1098}
1099
1100extern "C-unwind" {
1101 /// Begins playing or recording audio.
1102 ///
1103 /// If the audio hardware is not already running, this function starts it.
1104 ///
1105 ///
1106 /// Parameter `inAQ`: The audio queue to start.
1107 ///
1108 /// Parameter `inStartTime`: A pointer to the time at which the audio queue should start. If you specify the time
1109 /// using the mSampleTime field of the AudioTimeStamp structure, the sample time is
1110 /// referenced to the sample frame timeline of the associated audio device. May be NULL.
1111 ///
1112 /// Returns: An OSStatus result code.
1113 ///
1114 /// # Safety
1115 ///
1116 /// - `in_aq` must be a valid pointer.
1117 /// - `in_start_time` must be a valid pointer or null.
1118 #[cfg(feature = "objc2-core-audio-types")]
1119 pub fn AudioQueueStart(in_aq: AudioQueueRef, in_start_time: *const AudioTimeStamp) -> OSStatus;
1120}
1121
1122extern "C-unwind" {
1123 /// Begins decoding buffers in preparation for playback.
1124 ///
1125 /// This function begins decoding buffers in preparation for playback. It returns when at
1126 /// least the number of audio sample frames are decoded and ready to play or when all
1127 /// enqueued buffers have been completely decoded. To ensure that a buffer has been decoded
1128 /// and is completely ready for playback, before playback:
1129 ///
1130 /// 1. Call AudioQueueEnqueueBuffer.
1131 /// 2. Call AudioQueuePrime, which waits if you pass 0 to have a default number of
1132 /// frames decoded.
1133 /// 3. Call AudioQueueStart.
1134 ///
1135 /// Calls to AudioQueuePrime following AudioQueueStart/AudioQueuePrime, and before
1136 /// AudioQueueReset/AudioQueueStop, will have no useful effect. In this situation,
1137 /// outNumberOfFramesPrepared will not have a useful return value.
1138 ///
1139 ///
1140 /// Parameter `inAQ`: The audio queue to be primed.
1141 ///
1142 /// Parameter `inNumberOfFramesToPrepare`: The number of frames to decode before returning. Pass 0 to decode all enqueued buffers.
1143 ///
1144 /// Parameter `outNumberOfFramesPrepared`: If not NULL, on return, a pointer to the number of frames actually decoded and prepared
1145 /// for playback.
1146 ///
1147 /// Returns: An OSStatus result code.
1148 ///
1149 /// # Safety
1150 ///
1151 /// - `in_aq` must be a valid pointer.
1152 /// - `out_number_of_frames_prepared` must be a valid pointer or null.
1153 pub fn AudioQueuePrime(
1154 in_aq: AudioQueueRef,
1155 in_number_of_frames_to_prepare: u32,
1156 out_number_of_frames_prepared: *mut u32,
1157 ) -> OSStatus;
1158}
1159
1160/// Stops playing or recording audio.
1161///
1162/// This function resets the audio queue and stops the audio hardware associated with the
1163/// queue if it is not in use by other audio services. Synchronous stops occur immediately,
1164/// regardless of previously buffered audio data. Asynchronous stops occur after all queued
1165/// buffers have been played or recorded.
1166///
1167///
1168/// Parameter `inAQ`: The audio queue to stop.
1169///
1170/// Parameter `inImmediate`: If you pass true, the stop request occurs immediately (that is, synchronously), and the
1171/// function returns when the audio queue has stopped. Buffer callbacks are invoked during
1172/// the stopping. If you pass false, the function returns immediately, but the queue does
1173/// not stop until all its queued buffers are played or filled (that is, the stop occurs
1174/// asynchronously). Buffer callbacks are invoked as necessary until the queue actually
1175/// stops. Also, a playback audio queue callback calls this function when there is no more
1176/// audio to play.
1177///
1178/// Note that when stopping immediately, all pending buffer callbacks are normally invoked
1179/// during the process of stopping. But if the calling thread is responding to a buffer
1180/// callback, then it is possible for additional buffer callbacks to occur after
1181/// AudioQueueStop returns.
1182///
1183/// Returns: An OSStatus result code.
1184///
1185/// # Safety
1186///
1187/// `in_aq` must be a valid pointer.
1188#[inline]
1189pub unsafe extern "C-unwind" fn AudioQueueStop(
1190 in_aq: AudioQueueRef,
1191 in_immediate: bool,
1192) -> OSStatus {
1193 extern "C-unwind" {
1194 fn AudioQueueStop(in_aq: AudioQueueRef, in_immediate: Boolean) -> OSStatus;
1195 }
1196 unsafe { AudioQueueStop(in_aq, in_immediate as _) }
1197}
1198
1199extern "C-unwind" {
1200 /// Pauses audio playback or recording.
1201 ///
1202 /// Pausing the queue does not affect buffers or reset the audio queue. To resume playback
1203 /// or recording using the audio queue, call AudioQueueStart.
1204 ///
1205 ///
1206 /// Parameter `inAQ`: The queue to be paused.
1207 ///
1208 /// Returns: An OSStatus result code.
1209 ///
1210 /// # Safety
1211 ///
1212 /// `in_aq` must be a valid pointer.
1213 pub fn AudioQueuePause(in_aq: AudioQueueRef) -> OSStatus;
1214}
1215
1216extern "C-unwind" {
1217 /// Resets the audio queue's decoder state.
1218 ///
1219 /// After all queued buffers have been played, the function cleans up all decoder state
1220 /// information. You must call this function following a sequence of buffers of encoded
1221 /// audio; otherwise, some of the audio might not play in the next set of queued buffers.
1222 /// The only time it is not necessary to call AudioQueueFlush is following AudioQueueStop
1223 /// with inImmediate=false. (This action internally calls AudioQueueFlush.)
1224 ///
1225 /// Also, you might wish to call this function before calling AudioQueueStop depending on
1226 /// whether you want to stop immediately regardless of what has played or whether you want
1227 /// to ensure that all buffered data and all data that is in the middle of processing gets
1228 /// recorded or played before stopping.
1229 ///
1230 ///
1231 /// Parameter `inAQ`: The audio queue to be flushed.
1232 ///
1233 ///
1234 /// Returns: An OSStatus result code.
1235 ///
1236 /// # Safety
1237 ///
1238 /// `in_aq` must be a valid pointer.
1239 pub fn AudioQueueFlush(in_aq: AudioQueueRef) -> OSStatus;
1240}
1241
1242extern "C-unwind" {
1243 /// Resets an audio queue.
1244 ///
1245 /// This function immediately resets an audio queue, flushes any queued buffer, removes all
1246 /// buffers from previously scheduled use, and resets any decoder and digital signal
1247 /// processing (DSP) state information. It also invokes callbacks for any flushed buffers.
1248 /// If you queue any buffers after calling this function, processing does not occur until
1249 /// the decoder and DSP state information is reset. Hence, a discontinuity (that is, a
1250 /// "glitch") might occur.
1251 ///
1252 /// Note that when resetting, all pending buffer callbacks are normally invoked
1253 /// during the process of resetting. But if the calling thread is responding to a buffer
1254 /// callback, then it is possible for additional buffer callbacks to occur after
1255 /// AudioQueueReset returns.
1256 ///
1257 ///
1258 /// Parameter `inAQ`: The audio queue to reset.
1259 ///
1260 ///
1261 /// Returns: An OSStatus result code.
1262 ///
1263 /// # Safety
1264 ///
1265 /// `in_aq` must be a valid pointer.
1266 pub fn AudioQueueReset(in_aq: AudioQueueRef) -> OSStatus;
1267}
1268
1269extern "C-unwind" {
1270 /// Obtains an audio queue parameter value.
1271 ///
1272 /// You can access the current parameter values for an audio queue at any time with this
1273 /// function.
1274 ///
1275 ///
1276 /// Parameter `inAQ`: The audio queue whose parameter value you want to obtain.
1277 ///
1278 /// Parameter `inParamID`: The ID of the parameter you want to obtain. In macOS v10.5, audio queues have one
1279 /// parameter available: kAudioQueueParam_Volume, which controls the queue's playback
1280 /// volume.
1281 ///
1282 /// Parameter `outValue`: On return, points to the current value of the specified parameter.
1283 ///
1284 /// Returns: An OSStatus result code.
1285 ///
1286 /// # Safety
1287 ///
1288 /// - `in_aq` must be a valid pointer.
1289 /// - `out_value` must be a valid pointer.
1290 pub fn AudioQueueGetParameter(
1291 in_aq: AudioQueueRef,
1292 in_param_id: AudioQueueParameterID,
1293 out_value: NonNull<AudioQueueParameterValue>,
1294 ) -> OSStatus;
1295}
1296
1297extern "C-unwind" {
1298 /// Sets an audio queue parameter value.
1299 ///
1300 /// Parameter `inAQ`: The audio queue whose parameter value you want to set.
1301 ///
1302 /// Parameter `inParamID`: The ID of the parameter you want to set.
1303 ///
1304 /// Parameter `inValue`: The parameter value to set.
1305 ///
1306 /// Returns: An OSStatus result code.
1307 ///
1308 /// # Safety
1309 ///
1310 /// `in_aq` must be a valid pointer.
1311 pub fn AudioQueueSetParameter(
1312 in_aq: AudioQueueRef,
1313 in_param_id: AudioQueueParameterID,
1314 in_value: AudioQueueParameterValue,
1315 ) -> OSStatus;
1316}
1317
1318extern "C-unwind" {
1319 /// Obtains an audio queue property value.
1320 ///
1321 /// Parameter `inAQ`: The audio queue whose property value you want to obtain.
1322 ///
1323 /// Parameter `inID`: The ID of the property you want to obtain. See "Audio Queue Property IDs."
1324 ///
1325 /// Parameter `outData`: On return, points to the desired property value.
1326 ///
1327 /// Parameter `ioDataSize`: A pointer to the size of the property data. On input, points to the maximum bytes of
1328 /// space the caller expects to receive. On return, points to the actual data size.
1329 ///
1330 /// Returns: An OSStatus result code.
1331 ///
1332 /// # Safety
1333 ///
1334 /// - `in_aq` must be a valid pointer.
1335 /// - `out_data` must be a valid pointer.
1336 /// - `io_data_size` must be a valid pointer.
1337 pub fn AudioQueueGetProperty(
1338 in_aq: AudioQueueRef,
1339 in_id: AudioQueuePropertyID,
1340 out_data: NonNull<c_void>,
1341 io_data_size: NonNull<u32>,
1342 ) -> OSStatus;
1343}
1344
1345extern "C-unwind" {
1346 /// Sets an audio queue property value.
1347 ///
1348 /// Parameter `inAQ`: The audio queue whose property value you want to set.
1349 ///
1350 /// Parameter `inID`: The ID of the property you want to set. See "Audio Queue Property IDs" for the various
1351 /// audio queue properties.
1352 ///
1353 /// Parameter `inData`: A pointer to the property value to set.
1354 ///
1355 /// Parameter `inDataSize`: The size of the property data.
1356 ///
1357 /// Returns: An OSStatus result code.
1358 ///
1359 /// # Safety
1360 ///
1361 /// - `in_aq` must be a valid pointer.
1362 /// - `in_data` must be a valid pointer.
1363 pub fn AudioQueueSetProperty(
1364 in_aq: AudioQueueRef,
1365 in_id: AudioQueuePropertyID,
1366 in_data: NonNull<c_void>,
1367 in_data_size: u32,
1368 ) -> OSStatus;
1369}
1370
1371extern "C-unwind" {
1372 /// Obtains the size of an audio queue property.
1373 ///
1374 /// Parameter `inAQ`: The audio queue containing the property value whose size you want to obtain.
1375 ///
1376 /// Parameter `inID`: The ID of the property value whose size you want to obtain. See "Audio Queue Property
1377 /// IDs" for possible values.
1378 ///
1379 /// Parameter `outDataSize`: On return, points to the size of the specified property value.
1380 ///
1381 /// Returns: An OSStatus result code.
1382 ///
1383 /// # Safety
1384 ///
1385 /// - `in_aq` must be a valid pointer.
1386 /// - `out_data_size` must be a valid pointer.
1387 pub fn AudioQueueGetPropertySize(
1388 in_aq: AudioQueueRef,
1389 in_id: AudioQueuePropertyID,
1390 out_data_size: NonNull<u32>,
1391 ) -> OSStatus;
1392}
1393
1394extern "C-unwind" {
1395 /// Adds a listener callback for a property.
1396 ///
1397 /// This callback is used to act upon a change in an audio queue property such as
1398 /// kAudioQueueProperty_IsRunning. For instance, if your application has a user interface
1399 /// with a Play/Stop button, and kAudioQueueProperty_IsRunning changes, you need to update
1400 /// your button.
1401 ///
1402 ///
1403 /// Parameter `inAQ`: The audio queue that owns the property you want to assign the listener callback to.
1404 ///
1405 /// Parameter `inID`: The ID of the property to which you want to assign a listener callback. See "Audio Queue Property IDs".
1406 ///
1407 /// Parameter `inProc`: The listener callback to be called when the property value changes.
1408 ///
1409 /// Parameter `inUserData`: A value to be passed to the listener callback when it is called.
1410 ///
1411 /// Returns: An OSStatus result code.
1412 ///
1413 /// # Safety
1414 ///
1415 /// - `in_aq` must be a valid pointer.
1416 /// - `in_proc` must be implemented correctly.
1417 /// - `in_user_data` must be a valid pointer or null.
1418 pub fn AudioQueueAddPropertyListener(
1419 in_aq: AudioQueueRef,
1420 in_id: AudioQueuePropertyID,
1421 in_proc: AudioQueuePropertyListenerProc,
1422 in_user_data: *mut c_void,
1423 ) -> OSStatus;
1424}
1425
1426extern "C-unwind" {
1427 /// Removes a listener callback for a property.
1428 ///
1429 /// Parameter `inAQ`: The audio queue that owns the property from which you want to remove a listener.
1430 ///
1431 /// Parameter `inID`: The ID of the property from which you want to remove a listener.
1432 ///
1433 /// Parameter `inProc`: The listener being removed.
1434 ///
1435 /// Parameter `inUserData`: The same inUserData value that was previously passed to AudioQueueAddPropertyListener.
1436 ///
1437 /// Returns: An OSStatus result code.
1438 ///
1439 /// # Safety
1440 ///
1441 /// - `in_aq` must be a valid pointer.
1442 /// - `in_proc` must be implemented correctly.
1443 /// - `in_user_data` must be a valid pointer or null.
1444 pub fn AudioQueueRemovePropertyListener(
1445 in_aq: AudioQueueRef,
1446 in_id: AudioQueuePropertyID,
1447 in_proc: AudioQueuePropertyListenerProc,
1448 in_user_data: *mut c_void,
1449 ) -> OSStatus;
1450}
1451
1452extern "C-unwind" {
1453 /// Creates a timeline object.
1454 ///
1455 /// You need to instantiate a timeline object if you want to know about any timeline
1456 /// discontinuities. See AudioQueueGetCurrentTime for more details.
1457 ///
1458 ///
1459 /// Parameter `inAQ`: The audio queue to associate with the new timeline object.
1460 ///
1461 /// Parameter `outTimeline`: On return, points to the newly created timeline object.
1462 ///
1463 /// Returns: An OSStatus result code.
1464 ///
1465 /// # Safety
1466 ///
1467 /// - `in_aq` must be a valid pointer.
1468 /// - `out_timeline` must be a valid pointer.
1469 pub fn AudioQueueCreateTimeline(
1470 in_aq: AudioQueueRef,
1471 out_timeline: NonNull<AudioQueueTimelineRef>,
1472 ) -> OSStatus;
1473}
1474
1475extern "C-unwind" {
1476 /// Disposes of a timeline object.
1477 ///
1478 /// Disposing of an audio queue automatically disposes of any associated timeline objects.
1479 /// Call this function only if you want to dispose of a timeline object and not the audio
1480 /// queue associated with it.
1481 ///
1482 ///
1483 /// Parameter `inAQ`: The audio queue associated with the timeline object you want to dispose of.
1484 ///
1485 /// Parameter `inTimeline`: The timeline object to dispose of.
1486 ///
1487 /// Returns: An OSStatus result code.
1488 ///
1489 /// # Safety
1490 ///
1491 /// - `in_aq` must be a valid pointer.
1492 /// - `in_timeline` must be a valid pointer.
1493 pub fn AudioQueueDisposeTimeline(
1494 in_aq: AudioQueueRef,
1495 in_timeline: AudioQueueTimelineRef,
1496 ) -> OSStatus;
1497}
1498
1499extern "C-unwind" {
1500 /// Obtains the current audio queue time.
1501 ///
1502 /// You must specify a timeline object if you want to be notified about any timeline
1503 /// discontinuities in the outTimelineDiscontinuity parameter. If you don't care about
1504 /// discontinuities, pass NULL in the inTimeLine and outTimelineDiscontinuity parameters.
1505 ///
1506 ///
1507 /// Parameter `inAQ`: The audio queue whose current time you want to obtain.
1508 ///
1509 /// Parameter `inTimeline`: The audio queue timeline object to which any timeline discontinuities are reported. May
1510 /// be NULL.
1511 ///
1512 /// Parameter `outTimeStamp`: On return, points to an audio timestamp structure containing the current audio queue
1513 /// time. The mSampleTime field is in terms of the audio queue's sample rate, and relative
1514 /// to the time at which the queue has started or will start.
1515 ///
1516 /// Parameter `outTimelineDiscontinuity`: Can be NULL. On return, only set to true or false if the inTimeLine parameter is not
1517 /// NULL. Set to true if a discontinuity has occurred in the sample timeline of the audio
1518 /// queue. For instance, the device's sample rate changed and a gap occurred in playback or
1519 /// recording, or the audio queue was unable to prepare and playback in time because it was
1520 /// late.
1521 ///
1522 /// Returns: An OSStatus result code.
1523 ///
1524 /// # Safety
1525 ///
1526 /// - `in_aq` must be a valid pointer.
1527 /// - `in_timeline` must be a valid pointer or null.
1528 /// - `out_time_stamp` must be a valid pointer or null.
1529 /// - `out_timeline_discontinuity` must be a valid pointer or null.
1530 #[cfg(feature = "objc2-core-audio-types")]
1531 pub fn AudioQueueGetCurrentTime(
1532 in_aq: AudioQueueRef,
1533 in_timeline: AudioQueueTimelineRef,
1534 out_time_stamp: *mut AudioTimeStamp,
1535 out_timeline_discontinuity: *mut Boolean,
1536 ) -> OSStatus;
1537}
1538
1539extern "C-unwind" {
1540 /// Obtains the current time of the audio device associated with an audio queue.
1541 ///
1542 /// If the audio device associated with the audio queue is not running, the only valid field
1543 /// in the audio timestamp structure is mHostTime. This result differentiates the action of
1544 /// this function from that of the AudioDeviceGetCurrentTime function, (declared in
1545 /// AudioHardware.h) which returns an error if the audio device is not running.
1546 ///
1547 ///
1548 /// Parameter `inAQ`: The audio queue whose audio device is to be queried.
1549 ///
1550 /// Parameter `outTimeStamp`: A pointer to a structure that, on return, contains the current time of the audio device
1551 /// associated with the audio queue.
1552 ///
1553 /// Returns: An OSStatus result code.
1554 ///
1555 /// # Safety
1556 ///
1557 /// - `in_aq` must be a valid pointer.
1558 /// - `out_time_stamp` must be a valid pointer.
1559 #[cfg(feature = "objc2-core-audio-types")]
1560 pub fn AudioQueueDeviceGetCurrentTime(
1561 in_aq: AudioQueueRef,
1562 out_time_stamp: NonNull<AudioTimeStamp>,
1563 ) -> OSStatus;
1564}
1565
1566extern "C-unwind" {
1567 /// Converts the time in the time base of the associated audio device from one
1568 /// representation to another.
1569 ///
1570 /// This function converts from one time representation to another (for example, from sample
1571 /// time to host time or vice versa):
1572 ///
1573 /// - Sample time is the absolute sample frame time. Sample numbers are the count of the samples
1574 /// on the audio device.
1575 /// - Host time is the time base of the host machine such as the time of the bus clock on the CPU.
1576 ///
1577 /// The mSampleTime field in the AudioTimestamp structure (described in Core Audio Data
1578 /// Types Reference) is always in device time, not in audio queue time. Audio queue time is
1579 /// relative to the audio queue's start time. The associated audio device has to be running
1580 /// for the AudioQueueDeviceTranslateTime function to provide a result.
1581 ///
1582 ///
1583 /// Parameter `inAQ`: The queue whose audio device is to perform the requested time translation.
1584 ///
1585 /// Parameter `inTime`: A pointer to a structure containing the time to be translated.
1586 ///
1587 /// Parameter `outTime`: On entry, mFlags indicate the desired translations. On exit, mFlags indicates which
1588 /// of the requested translated fields were successfully populated.
1589 ///
1590 /// Returns: An OSStatus result code.
1591 ///
1592 /// # Safety
1593 ///
1594 /// - `in_aq` must be a valid pointer.
1595 /// - `in_time` must be a valid pointer.
1596 /// - `out_time` must be a valid pointer.
1597 #[cfg(feature = "objc2-core-audio-types")]
1598 pub fn AudioQueueDeviceTranslateTime(
1599 in_aq: AudioQueueRef,
1600 in_time: NonNull<AudioTimeStamp>,
1601 out_time: NonNull<AudioTimeStamp>,
1602 ) -> OSStatus;
1603}
1604
1605extern "C-unwind" {
1606 /// Obtains an audio device's start time that is closest to a requested start time.
1607 ///
1608 /// Parameter `inAQ`: The audio queue whose device's nearest start time you want to obtain.
1609 ///
1610 /// Parameter `ioRequestedStartTime`: On entry, points to the requested start time. On return, points to the actual start time.
1611 ///
1612 /// Parameter `inFlags`: Reserved for future use. Pass 0.
1613 ///
1614 /// Returns: An OSStatus result code.
1615 ///
1616 /// # Safety
1617 ///
1618 /// - `in_aq` must be a valid pointer.
1619 /// - `io_requested_start_time` must be a valid pointer.
1620 #[cfg(feature = "objc2-core-audio-types")]
1621 pub fn AudioQueueDeviceGetNearestStartTime(
1622 in_aq: AudioQueueRef,
1623 io_requested_start_time: NonNull<AudioTimeStamp>,
1624 in_flags: u32,
1625 ) -> OSStatus;
1626}
1627
1628extern "C-unwind" {
1629 /// Specify an audio format to which the queue will perform subsequent offline rendering,
1630 /// or disable offline rendering.
1631 ///
1632 /// An output queue's audio playback can be redirected for capture to an audio file,
1633 /// to support an export function, for example. AudioQueueSetOfflineRenderFormat switches
1634 /// a queue between normal and offline rendering modes.
1635 ///
1636 ///
1637 /// Parameter `inAQ`: The output queue whose offline rendering mode is to be changed.
1638 ///
1639 /// Parameter `inFormat`: The desired format for offline rendering. Pass NULL to disable offline rendering and return the
1640 /// queue to normal output to an audio device. This format must be linear PCM and (if not mono)
1641 /// interleaved.
1642 ///
1643 /// Parameter `inLayout`: The desired channel layout for offline rendering; also NULL when disabling offline rendering.
1644 ///
1645 /// Returns: An OSStatus result code.
1646 ///
1647 /// # Safety
1648 ///
1649 /// - `in_aq` must be a valid pointer.
1650 /// - `in_format` must be a valid pointer or null.
1651 /// - `in_layout` must be a valid pointer or null.
1652 #[cfg(feature = "objc2-core-audio-types")]
1653 pub fn AudioQueueSetOfflineRenderFormat(
1654 in_aq: AudioQueueRef,
1655 in_format: *const AudioStreamBasicDescription,
1656 in_layout: *const AudioChannelLayout,
1657 ) -> OSStatus;
1658}
1659
1660extern "C-unwind" {
1661 /// Obtain a buffer of audio output from a queue in offline rendering mode.
1662 ///
1663 /// Parameter `inAQ`: The output queue from which to obtain output.
1664 ///
1665 /// Parameter `inTimestamp`: The point in time corresponding to the beginning of the output buffer. Only mSampleTime
1666 /// is used. mFlags must include kAudioTimeStampSampleTimeValid.
1667 ///
1668 /// Parameter `ioBuffer`: The buffer into which the queue will render.
1669 ///
1670 /// Parameter `inNumberFrames`: The number of frames of audio to render. Note that fewer frames than requested may be returned.
1671 /// This can happen if insufficient data was enqueued.
1672 ///
1673 /// Returns: An OSStatus result code.
1674 ///
1675 /// # Safety
1676 ///
1677 /// - `in_aq` must be a valid pointer.
1678 /// - `in_timestamp` must be a valid pointer.
1679 /// - `io_buffer` must be a valid pointer.
1680 #[cfg(feature = "objc2-core-audio-types")]
1681 pub fn AudioQueueOfflineRender(
1682 in_aq: AudioQueueRef,
1683 in_timestamp: NonNull<AudioTimeStamp>,
1684 io_buffer: AudioQueueBufferRef,
1685 in_number_frames: u32,
1686 ) -> OSStatus;
1687}
1688
1689extern "C-unwind" {
1690 /// Create a new processing tap
1691 ///
1692 /// This function creates a processing tap on a given audio queue. A
1693 /// processing tap can only be established (or removed) on an audio queue that is
1694 /// stopped (paused is not sufficient). The processing tap will then be used to
1695 /// process either decoded data in the case of an output queue, or input data
1696 /// (before it is encoded) in the case of an input queue.
1697 ///
1698 /// The processing is performed on audio either before or after any effects or other
1699 /// processing (varispeed, etc) is applied by the audio queue, depending on inFlags.
1700 ///
1701 ///
1702 /// Parameter `inAQ`: The audio queue from which to create the processing tap
1703 ///
1704 /// Parameter `inCallback`: A callback which the queue will call to process the audio
1705 ///
1706 /// Parameter `inClientData`: Client data provided to the callback
1707 ///
1708 /// Parameter `inFlags`: Flags that are used to control aspects of the processing tap.
1709 /// Valid flags are:
1710 /// - kAudioQueueProcessingTap_PreEffects: processing is done before any
1711 /// further effects are applied by the audio queue to the audio
1712 /// - kAudioQueueProcessingTap_PostEffects: processing is done after all
1713 /// processing is done, including that of other taps.
1714 /// - kAudioQueueProcessingTap_Siphon
1715 ///
1716 /// Parameter `outMaxFrames`: The maximum number of sample frames that can be requested of a processing
1717 /// tap at any one time. Typically this will be approximately 50 msec of audio
1718 /// (2048 samples
1719 /// @
1720 /// 44.1kHz)
1721 ///
1722 /// Parameter `outProcessingFormat`: The format in which the client will receive the audio data to be processed.
1723 /// This will always be the same sample rate as the client format and usually
1724 /// the same number of channels as the client format of the audio queue. (NOTE:
1725 /// the number of channels may be different in some cases if the client format
1726 /// has some channel count restrictions, for instance the client provides 5.1
1727 /// AAC, but the decoder can only produce stereo). The channel order, if the
1728 /// same as the client format, will be the same as the client channel order. If
1729 /// the channel count is changed, it will be to either 1 (mono) or 2 (stereo, in
1730 /// which case the first channel is left, the second right).
1731 ///
1732 /// If the data is not in a convenient format for the client to process in, then
1733 /// the client should convert the data to and from that format. This is the most
1734 /// efficient mechanism to use (as the audio queue can chose a format that is
1735 /// most efficient from its playback (or recording) requirement.
1736 ///
1737 /// Parameter `outAQTap`: The processing tap object.
1738 ///
1739 ///
1740 /// Returns: An OSStatus result code.
1741 ///
1742 /// # Safety
1743 ///
1744 /// - `in_aq` must be a valid pointer.
1745 /// - `in_callback` must be implemented correctly.
1746 /// - `in_client_data` must be a valid pointer or null.
1747 /// - `out_max_frames` must be a valid pointer.
1748 /// - `out_processing_format` must be a valid pointer.
1749 /// - `out_aq_tap` must be a valid pointer.
1750 #[cfg(feature = "objc2-core-audio-types")]
1751 pub fn AudioQueueProcessingTapNew(
1752 in_aq: AudioQueueRef,
1753 in_callback: AudioQueueProcessingTapCallback,
1754 in_client_data: *mut c_void,
1755 in_flags: AudioQueueProcessingTapFlags,
1756 out_max_frames: NonNull<u32>,
1757 out_processing_format: NonNull<AudioStreamBasicDescription>,
1758 out_aq_tap: NonNull<AudioQueueProcessingTapRef>,
1759 ) -> OSStatus;
1760}
1761
1762extern "C-unwind" {
1763 /// Dispose a processing tap object
1764 ///
1765 /// As with AudioQueueProcessingTapNew(), this call can only be made on an
1766 /// audio queue that is stopped (paused is not sufficient)
1767 ///
1768 ///
1769 /// Parameter `inAQTap`: The processing tap to dispose.
1770 ///
1771 ///
1772 /// Returns: An OSStatus result code.
1773 ///
1774 /// # Safety
1775 ///
1776 /// `in_aq_tap` must be a valid pointer.
1777 pub fn AudioQueueProcessingTapDispose(in_aq_tap: AudioQueueProcessingTapRef) -> OSStatus;
1778}
1779
1780extern "C-unwind" {
1781 /// Used by a processing tap to retrieve source audio.
1782 ///
1783 /// This function may only be called from the processing tap's callback.
1784 ///
1785 ///
1786 /// Parameter `inAQTap`: the processing tap
1787 ///
1788 /// Parameter `inNumberFrames`: the number of frames the processing tap requires for its processing
1789 ///
1790 /// Parameter `ioTimeStamp`: On an input audio queue, the timestamp is returned from this function.
1791 /// On an output audio queue, the caller must provide a continuous timestamp.
1792 ///
1793 /// Parameter `outFlags`: flags to describe state about the input requested, e.g.
1794 /// discontinuity/complete
1795 ///
1796 /// Parameter `outNumberFrames`: the number of source frames that have been provided by the parent audio
1797 /// queue. This can be less than the number of requested frames specified in
1798 /// inNumberFrames
1799 ///
1800 /// Parameter `ioData`: the audio buffer list which will contain the source data. The audio queue owns
1801 /// the buffer pointers if NULL pointers were provided (recommended). In this case
1802 /// the source buffers are only valid for the duration of the processing tap
1803 /// callback. If the buffer pointers are non-NULL, then they must be big enough to
1804 /// hold inNumberFrames, and the audio queue will copy its source data into those
1805 /// buffers.
1806 ///
1807 ///
1808 /// Returns: An OSStatus result code.
1809 ///
1810 /// # Safety
1811 ///
1812 /// - `in_aq_tap` must be a valid pointer.
1813 /// - `io_time_stamp` must be a valid pointer.
1814 /// - `out_flags` must be a valid pointer.
1815 /// - `out_number_frames` must be a valid pointer.
1816 /// - `io_data` must be a valid pointer.
1817 #[cfg(feature = "objc2-core-audio-types")]
1818 pub fn AudioQueueProcessingTapGetSourceAudio(
1819 in_aq_tap: AudioQueueProcessingTapRef,
1820 in_number_frames: u32,
1821 io_time_stamp: NonNull<AudioTimeStamp>,
1822 out_flags: NonNull<AudioQueueProcessingTapFlags>,
1823 out_number_frames: NonNull<u32>,
1824 io_data: NonNull<AudioBufferList>,
1825 ) -> OSStatus;
1826}
1827
1828extern "C-unwind" {
1829 /// Used by a processing tap to retrieve the queue's current time.
1830 ///
1831 /// This function may only be called from the processing tap's callback, and only
1832 /// for audio output queues. It must be called after calling
1833 /// AudioQueueProcessingTapGetSourceAudio().
1834 ///
1835 ///
1836 /// Parameter `inAQTap`: the processing tap
1837 ///
1838 /// Parameter `outQueueSampleTime`: the current sample time of the audio queue. This will appear to be stationary
1839 /// if the queue is paused.
1840 ///
1841 /// Parameter `outQueueFrameCount`: the number of sample frames of queue time corresponding to the current chunk of
1842 /// audio being processed by the tap. This will differ from the frame count passed
1843 /// to the tap if the queue's playback rate is currently other than 1.0, due to the
1844 /// use of time compression/expansion. The frame count can also be 0 if the queue is
1845 /// paused.
1846 ///
1847 ///
1848 /// Returns: An OSStatus result code.
1849 ///
1850 /// # Safety
1851 ///
1852 /// - `in_aq_tap` must be a valid pointer.
1853 /// - `out_queue_sample_time` must be a valid pointer.
1854 /// - `out_queue_frame_count` must be a valid pointer.
1855 pub fn AudioQueueProcessingTapGetQueueTime(
1856 in_aq_tap: AudioQueueProcessingTapRef,
1857 out_queue_sample_time: NonNull<f64>,
1858 out_queue_frame_count: NonNull<u32>,
1859 ) -> OSStatus;
1860}