objc2_audio_toolbox/generated/ExtendedAudioFile.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;
7use objc2::__framework_prelude::*;
8#[cfg(feature = "objc2-core-audio-types")]
9use objc2_core_audio_types::*;
10#[cfg(feature = "objc2-core-foundation")]
11use objc2_core_foundation::*;
12
13use crate::*;
14
15/// [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/opaqueextaudiofile?language=objc)
16#[repr(C)]
17#[derive(Debug)]
18pub struct OpaqueExtAudioFile {
19 inner: [u8; 0],
20 _p: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
21}
22
23unsafe impl RefEncode for OpaqueExtAudioFile {
24 const ENCODING_REF: Encoding = Encoding::Pointer(&Encoding::Struct("OpaqueExtAudioFile", &[]));
25}
26
27/// An extended audio file object.
28///
29/// See also [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/extaudiofileref?language=objc)
30pub type ExtAudioFileRef = *mut OpaqueExtAudioFile;
31
32/// [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/extaudiofilepackettableinfooverride?language=objc)
33pub type ExtAudioFilePacketTableInfoOverride = i32;
34
35/// [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/kextaudiofilepackettableinfooverride_usefilevalue?language=objc)
36pub const kExtAudioFilePacketTableInfoOverride_UseFileValue: ExtAudioFilePacketTableInfoOverride =
37 -1;
38/// [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/kextaudiofilepackettableinfooverride_usefilevalueifvalid?language=objc)
39pub const kExtAudioFilePacketTableInfoOverride_UseFileValueIfValid:
40 ExtAudioFilePacketTableInfoOverride = -2;
41
42/// [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/extaudiofilepropertyid?language=objc)
43pub type ExtAudioFilePropertyID = u32;
44
45/// [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/kextaudiofileproperty_filedataformat?language=objc)
46pub const kExtAudioFileProperty_FileDataFormat: ExtAudioFilePropertyID = 0x66666d74;
47/// [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/kextaudiofileproperty_filechannellayout?language=objc)
48pub const kExtAudioFileProperty_FileChannelLayout: ExtAudioFilePropertyID = 0x66636c6f;
49/// [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/kextaudiofileproperty_clientdataformat?language=objc)
50pub const kExtAudioFileProperty_ClientDataFormat: ExtAudioFilePropertyID = 0x63666d74;
51/// [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/kextaudiofileproperty_clientchannellayout?language=objc)
52pub const kExtAudioFileProperty_ClientChannelLayout: ExtAudioFilePropertyID = 0x63636c6f;
53/// [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/kextaudiofileproperty_codecmanufacturer?language=objc)
54pub const kExtAudioFileProperty_CodecManufacturer: ExtAudioFilePropertyID = 0x636d616e;
55/// [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/kextaudiofileproperty_audioconverter?language=objc)
56pub const kExtAudioFileProperty_AudioConverter: ExtAudioFilePropertyID = 0x61636e76;
57/// [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/kextaudiofileproperty_audiofile?language=objc)
58pub const kExtAudioFileProperty_AudioFile: ExtAudioFilePropertyID = 0x6166696c;
59/// [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/kextaudiofileproperty_filemaxpacketsize?language=objc)
60pub const kExtAudioFileProperty_FileMaxPacketSize: ExtAudioFilePropertyID = 0x666d7073;
61/// [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/kextaudiofileproperty_clientmaxpacketsize?language=objc)
62pub const kExtAudioFileProperty_ClientMaxPacketSize: ExtAudioFilePropertyID = 0x636d7073;
63/// [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/kextaudiofileproperty_filelengthframes?language=objc)
64pub const kExtAudioFileProperty_FileLengthFrames: ExtAudioFilePropertyID = 0x2366726d;
65/// [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/kextaudiofileproperty_converterconfig?language=objc)
66pub const kExtAudioFileProperty_ConverterConfig: ExtAudioFilePropertyID = 0x61636366;
67/// [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/kextaudiofileproperty_iobuffersizebytes?language=objc)
68pub const kExtAudioFileProperty_IOBufferSizeBytes: ExtAudioFilePropertyID = 0x696f6273;
69/// [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/kextaudiofileproperty_iobuffer?language=objc)
70pub const kExtAudioFileProperty_IOBuffer: ExtAudioFilePropertyID = 0x696f6266;
71/// [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/kextaudiofileproperty_packettable?language=objc)
72pub const kExtAudioFileProperty_PacketTable: ExtAudioFilePropertyID = 0x78707469;
73
74/// [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/kextaudiofileerror_invalidproperty?language=objc)
75pub const kExtAudioFileError_InvalidProperty: OSStatus = -66561;
76/// [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/kextaudiofileerror_invalidpropertysize?language=objc)
77pub const kExtAudioFileError_InvalidPropertySize: OSStatus = -66562;
78/// [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/kextaudiofileerror_nonpcmclientformat?language=objc)
79pub const kExtAudioFileError_NonPCMClientFormat: OSStatus = -66563;
80/// [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/kextaudiofileerror_invalidchannelmap?language=objc)
81pub const kExtAudioFileError_InvalidChannelMap: OSStatus = -66564;
82/// [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/kextaudiofileerror_invalidoperationorder?language=objc)
83pub const kExtAudioFileError_InvalidOperationOrder: OSStatus = -66565;
84/// [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/kextaudiofileerror_invaliddataformat?language=objc)
85pub const kExtAudioFileError_InvalidDataFormat: OSStatus = -66566;
86/// [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/kextaudiofileerror_maxpacketsizeunknown?language=objc)
87pub const kExtAudioFileError_MaxPacketSizeUnknown: OSStatus = -66567;
88/// [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/kextaudiofileerror_invalidseek?language=objc)
89pub const kExtAudioFileError_InvalidSeek: OSStatus = -66568;
90/// [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/kextaudiofileerror_asyncwritetoolarge?language=objc)
91pub const kExtAudioFileError_AsyncWriteTooLarge: OSStatus = -66569;
92/// [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/kextaudiofileerror_asyncwritebufferoverflow?language=objc)
93pub const kExtAudioFileError_AsyncWriteBufferOverflow: OSStatus = -66570;
94
95extern "C-unwind" {
96 /// Opens an audio file specified by a CFURLRef.
97 ///
98 /// Parameter `inURL`: The audio file to read.
99 ///
100 /// Parameter `outExtAudioFile`: On exit, a newly-allocated ExtAudioFileRef.
101 ///
102 /// Returns: An OSStatus error code.
103 ///
104 ///
105 /// Allocates a new ExtAudioFileRef, for reading an existing audio file.
106 ///
107 /// # Safety
108 ///
109 /// `out_ext_audio_file` must be a valid pointer.
110 #[cfg(feature = "objc2-core-foundation")]
111 pub fn ExtAudioFileOpenURL(
112 in_url: &CFURL,
113 out_ext_audio_file: NonNull<ExtAudioFileRef>,
114 ) -> OSStatus;
115}
116
117/// Wrap an AudioFileID in an ExtAudioFileRef.
118///
119/// Parameter `inFileID`: The AudioFileID to wrap.
120///
121/// Parameter `inForWriting`: True if the AudioFileID is a new file opened for writing.
122///
123/// Parameter `outExtAudioFile`: On exit, a newly-allocated ExtAudioFileRef.
124///
125/// Returns: An OSStatus error code.
126///
127///
128/// Allocates a new ExtAudioFileRef which wraps an existing AudioFileID. The
129/// client is responsible for keeping the AudioFileID open until the
130/// ExtAudioFileRef is disposed. Disposing the ExtAudioFileRef will not close
131/// the AudioFileID when this Wrap API call is used, so the client is also
132/// responsible for closing the AudioFileID when finished with it.
133///
134/// # Safety
135///
136/// - `in_file_id` must be a valid pointer.
137/// - `out_ext_audio_file` must be a valid pointer.
138#[cfg(feature = "AudioFile")]
139#[inline]
140pub unsafe extern "C-unwind" fn ExtAudioFileWrapAudioFileID(
141 in_file_id: AudioFileID,
142 in_for_writing: bool,
143 out_ext_audio_file: NonNull<ExtAudioFileRef>,
144) -> OSStatus {
145 extern "C-unwind" {
146 fn ExtAudioFileWrapAudioFileID(
147 in_file_id: AudioFileID,
148 in_for_writing: Boolean,
149 out_ext_audio_file: NonNull<ExtAudioFileRef>,
150 ) -> OSStatus;
151 }
152 unsafe { ExtAudioFileWrapAudioFileID(in_file_id, in_for_writing as _, out_ext_audio_file) }
153}
154
155extern "C-unwind" {
156 /// Create a new audio file.
157 ///
158 /// Parameter `inURL`: The URL of the new audio file.
159 ///
160 /// Parameter `inFileType`: The type of file to create. This is a constant from AudioToolbox/AudioFile.h, e.g.
161 /// kAudioFileAIFFType. Note that this is not an HFSTypeCode.
162 ///
163 /// Parameter `inStreamDesc`: The format of the audio data to be written to the file.
164 ///
165 /// Parameter `inChannelLayout`: The channel layout of the audio data. If non-null, this must be consistent
166 /// with the number of channels specified by inStreamDesc.
167 ///
168 /// Parameter `inFlags`: The same flags as are used with AudioFileCreateWithURL
169 /// Can use these to control whether an existing file is overwritten (or not).
170 ///
171 /// Parameter `outExtAudioFile`: On exit, a newly-allocated ExtAudioFileRef.
172 ///
173 /// Returns: An OSStatus error code.
174 ///
175 ///
176 /// Creates a new audio file.
177 ///
178 /// If the file to be created is in an encoded format, it is permissible for the
179 /// sample rate in inStreamDesc to be 0, since in all cases, the file's encoding
180 /// AudioConverter may produce audio at a different sample rate than the source. The
181 /// file will be created with the audio format actually produced by the encoder.
182 ///
183 /// # Safety
184 ///
185 /// - `in_stream_desc` must be a valid pointer.
186 /// - `in_channel_layout` must be a valid pointer or null.
187 /// - `out_ext_audio_file` must be a valid pointer.
188 #[cfg(all(
189 feature = "AudioFile",
190 feature = "objc2-core-audio-types",
191 feature = "objc2-core-foundation"
192 ))]
193 pub fn ExtAudioFileCreateWithURL(
194 in_url: &CFURL,
195 in_file_type: AudioFileTypeID,
196 in_stream_desc: NonNull<AudioStreamBasicDescription>,
197 in_channel_layout: *const AudioChannelLayout,
198 in_flags: u32,
199 out_ext_audio_file: NonNull<ExtAudioFileRef>,
200 ) -> OSStatus;
201}
202
203extern "C-unwind" {
204 /// Close the file and dispose the object.
205 ///
206 /// Parameter `inExtAudioFile`: The extended audio file object.
207 ///
208 /// Returns: An OSStatus error code.
209 ///
210 ///
211 /// Closes the file and deletes the object.
212 ///
213 /// # Safety
214 ///
215 /// `in_ext_audio_file` must be a valid pointer.
216 pub fn ExtAudioFileDispose(in_ext_audio_file: ExtAudioFileRef) -> OSStatus;
217}
218
219extern "C-unwind" {
220 /// Perform a synchronous sequential read.
221 ///
222 ///
223 /// Parameter `inExtAudioFile`: The extended audio file object.
224 ///
225 /// Parameter `ioNumberFrames`: On entry, ioNumberFrames is the number of frames to be read from the file.
226 /// On exit, it is the number of frames actually read. A number of factors may
227 /// cause a fewer number of frames to be read, including the supplied buffers
228 /// not being large enough, and internal optimizations. If 0 frames are
229 /// returned, however, this indicates that end-of-file was reached.
230 ///
231 /// Parameter `ioData`: Buffer(s) into which the audio data is read.
232 ///
233 /// Returns: An OSStatus error code.
234 ///
235 ///
236 /// If the file has a client data format, then the audio data from the file is
237 /// translated from the file data format to the client format, via the
238 /// ExtAudioFile's internal AudioConverter.
239 ///
240 /// (Note that the use of sequential reads/writes means that an ExtAudioFile must
241 /// not be read on multiple threads; clients wishing to do this should use the
242 /// lower-level AudioFile API set).
243 ///
244 /// # Safety
245 ///
246 /// - `in_ext_audio_file` must be a valid pointer.
247 /// - `io_number_frames` must be a valid pointer.
248 /// - `io_data` must be a valid pointer.
249 #[cfg(feature = "objc2-core-audio-types")]
250 pub fn ExtAudioFileRead(
251 in_ext_audio_file: ExtAudioFileRef,
252 io_number_frames: NonNull<u32>,
253 io_data: NonNull<AudioBufferList>,
254 ) -> OSStatus;
255}
256
257extern "C-unwind" {
258 /// Perform a synchronous sequential write.
259 ///
260 ///
261 /// Parameter `inExtAudioFile`: The extended audio file object.
262 ///
263 /// Parameter `inNumberFrames`: The number of frames to write.
264 ///
265 /// Parameter `ioData`: The buffer(s) from which audio data is written to the file.
266 ///
267 /// Returns: An OSStatus error code.
268 ///
269 ///
270 /// If the file has a client data format, then the audio data in ioData is
271 /// translated from the client format to the file data format, via the
272 /// ExtAudioFile's internal AudioConverter.
273 ///
274 /// # Safety
275 ///
276 /// - `in_ext_audio_file` must be a valid pointer.
277 /// - `io_data` must be a valid pointer.
278 #[cfg(feature = "objc2-core-audio-types")]
279 pub fn ExtAudioFileWrite(
280 in_ext_audio_file: ExtAudioFileRef,
281 in_number_frames: u32,
282 io_data: NonNull<AudioBufferList>,
283 ) -> OSStatus;
284}
285
286extern "C-unwind" {
287 /// Perform an asynchronous sequential write.
288 ///
289 ///
290 /// Parameter `inExtAudioFile`: The extended audio file object.
291 ///
292 /// Parameter `inNumberFrames`: The number of frames to write.
293 ///
294 /// Parameter `ioData`: The buffer(s) from which audio data is written to the file.
295 ///
296 /// Returns: An OSStatus error code.
297 ///
298 ///
299 /// Writes the provided buffer list to an internal ring buffer and notifies an
300 /// internal thread to perform the write at a later time. The first time this is
301 /// called, allocations may be performed. You can call this with 0 frames and null
302 /// buffer in a non-time-critical context to initialize the asynchronous mechanism.
303 /// Once initialized, subsequent calls are very efficient and do not take locks;
304 /// thus this may be used to write to a file from a realtime thread.
305 ///
306 /// The client must not mix synchronous and asynchronous writes to the same file.
307 ///
308 /// Pending writes are not guaranteed to be flushed to disk until
309 /// ExtAudioFileDispose is called.
310 ///
311 /// N.B. Errors may occur after this call has returned. Such errors may be returned
312 /// from subsequent calls to this function.
313 ///
314 /// # Safety
315 ///
316 /// - `in_ext_audio_file` must be a valid pointer.
317 /// - `io_data` must be a valid pointer or null.
318 #[cfg(feature = "objc2-core-audio-types")]
319 pub fn ExtAudioFileWriteAsync(
320 in_ext_audio_file: ExtAudioFileRef,
321 in_number_frames: u32,
322 io_data: *const AudioBufferList,
323 ) -> OSStatus;
324}
325
326extern "C-unwind" {
327 /// Seek to a specific frame position.
328 ///
329 ///
330 /// Parameter `inExtAudioFile`: The extended audio file object.
331 ///
332 /// Parameter `inFrameOffset`: The desired seek position, in sample frames, relative to the beginning of
333 /// the file. This is specified in the sample rate and frame count of the file's format
334 /// (not the client format)
335 ///
336 /// Returns: An OSStatus error code.
337 ///
338 ///
339 /// Sets the file's read position to the specified sample frame number. The next call
340 /// to ExtAudioFileRead will return samples from precisely this location, even if it
341 /// is located in the middle of a packet.
342 ///
343 /// This function's behavior with files open for writing is currently undefined.
344 ///
345 /// # Safety
346 ///
347 /// `in_ext_audio_file` must be a valid pointer.
348 pub fn ExtAudioFileSeek(in_ext_audio_file: ExtAudioFileRef, in_frame_offset: i64) -> OSStatus;
349}
350
351extern "C-unwind" {
352 /// Return the file's read/write position.
353 ///
354 ///
355 /// Parameter `inExtAudioFile`: The extended audio file object.
356 ///
357 /// Parameter `outFrameOffset`: On exit, the file's current read/write position in sample frames. This is specified in the
358 /// sample rate and frame count of the file's format (not the client format)
359 ///
360 /// Returns: An OSStatus error code.
361 ///
362 /// # Safety
363 ///
364 /// - `in_ext_audio_file` must be a valid pointer.
365 /// - `out_frame_offset` must be a valid pointer.
366 pub fn ExtAudioFileTell(
367 in_ext_audio_file: ExtAudioFileRef,
368 out_frame_offset: NonNull<i64>,
369 ) -> OSStatus;
370}
371
372extern "C-unwind" {
373 /// Get information about a property
374 ///
375 ///
376 /// Parameter `inExtAudioFile`: The extended audio file object.
377 ///
378 /// Parameter `inPropertyID`: The property being queried.
379 ///
380 /// Parameter `outSize`: If non-null, on exit, this is set to the size of the property's value.
381 ///
382 /// Parameter `outWritable`: If non-null, on exit, this indicates whether the property value is settable.
383 ///
384 /// Returns: An OSStatus error code.
385 ///
386 /// # Safety
387 ///
388 /// - `in_ext_audio_file` must be a valid pointer.
389 /// - `out_size` must be a valid pointer or null.
390 /// - `out_writable` must be a valid pointer or null.
391 pub fn ExtAudioFileGetPropertyInfo(
392 in_ext_audio_file: ExtAudioFileRef,
393 in_property_id: ExtAudioFilePropertyID,
394 out_size: *mut u32,
395 out_writable: *mut Boolean,
396 ) -> OSStatus;
397}
398
399extern "C-unwind" {
400 /// Get a property value.
401 ///
402 ///
403 /// Parameter `inExtAudioFile`: The extended audio file object.
404 ///
405 /// Parameter `inPropertyID`: The property being fetched.
406 ///
407 /// Parameter `ioPropertyDataSize`: On entry, the size (in bytes) of the memory pointed to by outPropertyData.
408 /// On exit, the actual size of the property data returned.
409 ///
410 /// Parameter `outPropertyData`: The value of the property is copied to the memory this points to.
411 ///
412 /// Returns: An OSStatus error code.
413 ///
414 /// # Safety
415 ///
416 /// - `in_ext_audio_file` must be a valid pointer.
417 /// - `io_property_data_size` must be a valid pointer.
418 /// - `out_property_data` must be a valid pointer.
419 pub fn ExtAudioFileGetProperty(
420 in_ext_audio_file: ExtAudioFileRef,
421 in_property_id: ExtAudioFilePropertyID,
422 io_property_data_size: NonNull<u32>,
423 out_property_data: NonNull<c_void>,
424 ) -> OSStatus;
425}
426
427extern "C-unwind" {
428 /// Set a property value.
429 ///
430 ///
431 /// Parameter `inExtAudioFile`: The extended audio file object.
432 ///
433 /// Parameter `inPropertyID`: The property being set.
434 ///
435 /// Parameter `inPropertyDataSize`: The size of the property data, in bytes.
436 ///
437 /// Parameter `inPropertyData`: Points to the property's new value.
438 ///
439 /// Returns: An OSStatus error code.
440 ///
441 /// # Safety
442 ///
443 /// - `in_ext_audio_file` must be a valid pointer.
444 /// - `in_property_data` must be a valid pointer.
445 pub fn ExtAudioFileSetProperty(
446 in_ext_audio_file: ExtAudioFileRef,
447 in_property_id: ExtAudioFilePropertyID,
448 in_property_data_size: u32,
449 in_property_data: NonNull<c_void>,
450 ) -> OSStatus;
451}