objc2_audio_toolbox/generated/
AudioServices.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ffi::*;
4use core::ptr::NonNull;
5#[cfg(feature = "objc2-core-foundation")]
6use objc2_core_foundation::*;
7
8use crate::*;
9
10/// [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/kaudioservicesnoerror?language=objc)
11pub const kAudioServicesNoError: OSStatus = 0;
12/// [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/kaudioservicesunsupportedpropertyerror?language=objc)
13pub const kAudioServicesUnsupportedPropertyError: OSStatus = 0x7074793f;
14/// [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/kaudioservicesbadpropertysizeerror?language=objc)
15pub const kAudioServicesBadPropertySizeError: OSStatus = 0x2173697a;
16/// [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/kaudioservicesbadspecifiersizeerror?language=objc)
17pub const kAudioServicesBadSpecifierSizeError: OSStatus = 0x21737063;
18/// [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/kaudioservicessystemsoundunspecifiederror?language=objc)
19pub const kAudioServicesSystemSoundUnspecifiedError: OSStatus = -1500;
20/// [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/kaudioservicessystemsoundclienttimedouterror?language=objc)
21pub const kAudioServicesSystemSoundClientTimedOutError: OSStatus = -1501;
22/// [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/kaudioservicessystemsoundexceededmaximumdurationerror?language=objc)
23pub const kAudioServicesSystemSoundExceededMaximumDurationError: OSStatus = -1502;
24
25/// SystemSoundIDs are created by the System Sound client application
26/// for playback of a provided AudioFile.
27///
28/// See also [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/systemsoundid?language=objc)
29pub type SystemSoundID = u32;
30
31/// Type used for specifying an AudioServices property.
32///
33/// See also [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/audioservicespropertyid?language=objc)
34pub type AudioServicesPropertyID = u32;
35
36/// A function to be executed when a SystemSoundID finishes playing.
37///
38/// AudioServicesSystemSoundCompletionProc may be provided by client application to be
39/// called when a SystemSoundID has completed playback.
40///
41/// Parameter `ssID`: The SystemSoundID that completed playback
42///
43/// Parameter `clientData`: Client application user data
44///
45/// See also [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/audioservicessystemsoundcompletionproc?language=objc)
46pub type AudioServicesSystemSoundCompletionProc =
47    Option<unsafe extern "C-unwind" fn(SystemSoundID, *mut c_void)>;
48
49/// [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/ksystemsoundid_userpreferredalert?language=objc)
50pub const kSystemSoundID_UserPreferredAlert: SystemSoundID = 0x00001000;
51/// [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/ksystemsoundid_flashscreen?language=objc)
52pub const kSystemSoundID_FlashScreen: SystemSoundID = 0x00000FFE;
53/// [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/kuserpreferredalert?language=objc)
54pub const kUserPreferredAlert: SystemSoundID = kSystemSoundID_UserPreferredAlert;
55
56/// [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/ksystemsoundid_vibrate?language=objc)
57pub const kSystemSoundID_Vibrate: SystemSoundID = 0x00000FFF;
58
59/// [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/kaudioservicespropertyisuisound?language=objc)
60pub const kAudioServicesPropertyIsUISound: AudioServicesPropertyID = 0x69737569;
61/// [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/kaudioservicespropertycompleteplaybackifappdies?language=objc)
62pub const kAudioServicesPropertyCompletePlaybackIfAppDies: AudioServicesPropertyID = 0x69666469;
63
64extern "C-unwind" {
65    /// Allows the application to designate an audio file for playback by the System Sound server.
66    ///
67    /// Returned SystemSoundIDs are passed to AudioServicesPlayAlertSoundWithCompletion()
68    /// and AudioServicesPlaySystemSoundWithCompletion() to be played.
69    ///
70    /// The maximum supported duration for a system sound is 30 secs.
71    ///
72    /// Parameter `inFileURL`: A CFURLRef for an AudioFile.
73    ///
74    /// Parameter `outSystemSoundID`: Returns a SystemSoundID.
75    ///
76    /// # Safety
77    ///
78    /// `out_system_sound_id` must be a valid pointer.
79    #[cfg(feature = "objc2-core-foundation")]
80    pub fn AudioServicesCreateSystemSoundID(
81        in_file_url: &CFURL,
82        out_system_sound_id: NonNull<SystemSoundID>,
83    ) -> OSStatus;
84}
85
86extern "C-unwind" {
87    /// Allows the System Sound server to dispose any resources needed for the provided
88    /// SystemSoundID.
89    ///
90    /// Allows the application to tell the System Sound server that the resources for the
91    /// associated audio file are no longer required.
92    ///
93    /// Parameter `inSystemSoundID`: A SystemSoundID that the application no longer needs to use.
94    pub fn AudioServicesDisposeSystemSoundID(in_system_sound_id: SystemSoundID) -> OSStatus;
95}
96
97extern "C-unwind" {
98    /// Play an alert sound
99    ///
100    /// Play the sound designated by the provided SystemSoundID with alert sound behavior.
101    ///
102    /// Parameter `inSystemSoundID`: The SystemSoundID to be played. On the desktop the kSystemSoundID_UserPreferredAlert
103    /// constant can be passed in to play back the alert sound selected by the user
104    /// in System Preferences. On iOS there is no preferred user alert sound.
105    ///
106    /// Parameter `inCompletionBlock`: The completion block gets executed for every attempt to play a system sound irrespective
107    /// of success or failure. The callbacks are issued on a serial queue and the client is
108    /// responsible for handling thread safety.
109    #[cfg(feature = "block2")]
110    pub fn AudioServicesPlayAlertSoundWithCompletion(
111        in_system_sound_id: SystemSoundID,
112        in_completion_block: Option<&block2::DynBlock<dyn Fn()>>,
113    );
114}
115
116extern "C-unwind" {
117    /// Play a system sound
118    ///
119    /// Play the sound designated by the provided SystemSoundID.
120    ///
121    /// Parameter `inSystemSoundID`: The SystemSoundID to be played.
122    ///
123    /// Parameter `inCompletionBlock`: The completion block gets executed for every attempt to play a system sound irrespective
124    /// of success or failure. The callbacks are issued on a serial queue and the client is
125    /// responsible for handling thread safety.
126    #[cfg(feature = "block2")]
127    pub fn AudioServicesPlaySystemSoundWithCompletion(
128        in_system_sound_id: SystemSoundID,
129        in_completion_block: Option<&block2::DynBlock<dyn Fn()>>,
130    );
131}
132
133extern "C-unwind" {
134    /// Get information about the size of an AudioServices property and whether it can
135    /// be set.
136    ///
137    /// Parameter `inPropertyID`: a AudioServicesPropertyID constant.
138    ///
139    /// Parameter `inSpecifierSize`: The size of the specifier data.
140    ///
141    /// Parameter `inSpecifier`: A specifier is a buffer of data used as an input argument to some of the
142    /// properties.
143    ///
144    /// Parameter `outPropertyDataSize`: The size in bytes of the current value of the property. In order to get the
145    /// property value, you will need a buffer of this size.
146    ///
147    /// Parameter `outWritable`: Will be set to 1 if writable, or 0 if read only.
148    ///
149    /// Returns: returns kAudioServicesNoError if successful.
150    ///
151    /// # Safety
152    ///
153    /// - `in_specifier` must be a valid pointer or null.
154    /// - `out_property_data_size` must be a valid pointer or null.
155    /// - `out_writable` must be a valid pointer or null.
156    pub fn AudioServicesGetPropertyInfo(
157        in_property_id: AudioServicesPropertyID,
158        in_specifier_size: u32,
159        in_specifier: *const c_void,
160        out_property_data_size: *mut u32,
161        out_writable: *mut Boolean,
162    ) -> OSStatus;
163}
164
165extern "C-unwind" {
166    /// Retrieve the indicated property data
167    ///
168    /// Parameter `inPropertyID`: a AudioServicesPropertyID constant.
169    ///
170    /// Parameter `inSpecifierSize`: The size of the specifier data.
171    ///
172    /// Parameter `inSpecifier`: A specifier is a buffer of data used as an input argument to some of the
173    /// properties.
174    ///
175    /// Parameter `ioPropertyDataSize`: On input, the size of the outPropertyData buffer. On output the number of
176    /// bytes written to the buffer.
177    ///
178    /// Parameter `outPropertyData`: The buffer in which to write the property data. May be NULL if caller only
179    /// wants ioPropertyDataSize to be filled with the amount that would have been
180    /// written.
181    ///
182    /// Returns: returns kAudioServicesNoError if successful.
183    ///
184    /// # Safety
185    ///
186    /// - `in_specifier` must be a valid pointer or null.
187    /// - `io_property_data_size` must be a valid pointer.
188    /// - `out_property_data` must be a valid pointer or null.
189    pub fn AudioServicesGetProperty(
190        in_property_id: AudioServicesPropertyID,
191        in_specifier_size: u32,
192        in_specifier: *const c_void,
193        io_property_data_size: NonNull<u32>,
194        out_property_data: *mut c_void,
195    ) -> OSStatus;
196}
197
198extern "C-unwind" {
199    /// Set the indicated property data
200    ///
201    /// Parameter `inPropertyID`: a AudioServicesPropertyID constant.
202    ///
203    /// Parameter `inSpecifierSize`: The size of the specifier data.
204    ///
205    /// Parameter `inSpecifier`: A specifier is a buffer of data used as an input argument to some of the
206    /// properties.
207    ///
208    /// Parameter `inPropertyDataSize`: The size of the inPropertyData buffer.
209    ///
210    /// Parameter `inPropertyData`: The buffer containing the property data.
211    ///
212    /// Returns: returns kAudioServicesNoError if successful.
213    ///
214    /// # Safety
215    ///
216    /// - `in_specifier` must be a valid pointer or null.
217    /// - `in_property_data` must be a valid pointer.
218    pub fn AudioServicesSetProperty(
219        in_property_id: AudioServicesPropertyID,
220        in_specifier_size: u32,
221        in_specifier: *const c_void,
222        in_property_data_size: u32,
223        in_property_data: NonNull<c_void>,
224    ) -> OSStatus;
225}
226
227extern "C-unwind" {
228    /// This function will be deprecated in a future release. Use AudioServicesPlayAlertSoundWithCompletion instead.
229    ///
230    ///
231    ///
232    /// Play an Alert Sound
233    ///
234    /// Play the provided SystemSoundID with AlertSound behavior.
235    ///
236    /// Parameter `inSystemSoundID`: A SystemSoundID for the System Sound server to play. On the desktop you
237    /// can pass the kSystemSoundID_UserPreferredAlert constant to playback the alert sound
238    /// selected by the user in System Preferences. On iOS there is no preferred user alert sound.
239    pub fn AudioServicesPlayAlertSound(in_system_sound_id: SystemSoundID);
240}
241
242extern "C-unwind" {
243    /// This function will be deprecated in a future release. Use AudioServicesPlaySystemSoundWithCompletion instead.
244    ///
245    ///
246    ///
247    /// Play the sound designated by the provided SystemSoundID.
248    ///
249    /// A SystemSoundID indicating the desired System Sound to be played.
250    ///
251    /// Parameter `inSystemSoundID`: A SystemSoundID for the System Sound server to play.
252    pub fn AudioServicesPlaySystemSound(in_system_sound_id: SystemSoundID);
253}
254
255extern "C-unwind" {
256    /// This function will be deprecated in a future release. Use AudioServicesPlayAlertSoundWithCompletion
257    /// or AudioServicesPlaySystemSoundWithCompletion instead.
258    ///
259    ///
260    ///
261    /// Call the provided Completion Routine when provided SystemSoundID
262    /// finishes playing.
263    ///
264    /// Once set, the System Sound server will send a message to the System Sound client
265    /// indicating which SystemSoundID has finished playing.
266    ///
267    /// Parameter `inSystemSoundID`: The SystemSoundID to associate with the provided completion
268    /// routine.
269    ///
270    /// Parameter `inRunLoop`: A CFRunLoopRef indicating the desired run loop the completion routine should
271    /// be run on. Pass NULL to use the main run loop.
272    ///
273    /// Parameter `inRunLoopMode`: A CFStringRef indicating the run loop mode for the runloop where the
274    /// completion routine will be executed. Pass NULL to use kCFRunLoopDefaultMode.
275    ///
276    /// Parameter `inCompletionRoutine`: An AudioServicesSystemSoundCompletionProc to be called when the provided
277    /// SystemSoundID has completed playing in the server.
278    ///
279    /// Parameter `inClientData`: A void* to pass client data to the completion routine.
280    ///
281    /// # Safety
282    ///
283    /// - `in_run_loop` possibly has additional threading requirements.
284    /// - `in_completion_routine` must be implemented correctly.
285    /// - `in_client_data` must be a valid pointer or null.
286    #[cfg(feature = "objc2-core-foundation")]
287    pub fn AudioServicesAddSystemSoundCompletion(
288        in_system_sound_id: SystemSoundID,
289        in_run_loop: Option<&CFRunLoop>,
290        in_run_loop_mode: Option<&CFString>,
291        in_completion_routine: AudioServicesSystemSoundCompletionProc,
292        in_client_data: *mut c_void,
293    ) -> OSStatus;
294}
295
296extern "C-unwind" {
297    /// This function will be deprecated in a future release. Use AudioServicesPlayAlertSoundWithCompletion
298    /// or AudioServicesPlaySystemSoundWithCompletion instead.
299    ///
300    ///
301    ///
302    /// Disassociate any completion proc for the specified SystemSoundID
303    ///
304    /// Tells the SystemSound client to remove any completion proc associated with the
305    /// provided SystemSoundID
306    ///
307    /// Parameter `inSystemSoundID`: The SystemSoundID for which completion routines should be
308    /// removed.
309    pub fn AudioServicesRemoveSystemSoundCompletion(in_system_sound_id: SystemSoundID);
310}
311
312extern "C" {
313    /// Keys that are passed in a dictionary to AudioServicesPlaySystemSoundWithDetails
314    ///
315    /// Must be any non-nil CASpatialAudioExperience. The system sound
316    /// will have this spatial experience for the duration of its
317    /// playback and cannot change mid-playback.
318    ///
319    /// See also [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/kaudioservicesdetailintendedspatialexperience?language=objc)
320    #[cfg(feature = "objc2-core-foundation")]
321    pub static kAudioServicesDetailIntendedSpatialExperience: &'static CFString;
322}
323
324extern "C-unwind" {
325    /// Play the sound designated by the provided SystemSoundID.
326    ///
327    /// Parameter `inSystemSoundID`: A SystemSoundID for the system sound server to play.
328    ///
329    /// Parameter `inDetails`: A set of details as described above.
330    ///
331    /// Parameter `inCompletionBlock`: The completion block gets executed for every attempt to play a system sound irrespective
332    /// of success or failure. The callbacks are issued on a serial queue and the client is
333    /// responsible for handling thread safety.
334    ///
335    /// # Safety
336    ///
337    /// `in_details` generics must be of the correct type.
338    #[cfg(all(feature = "block2", feature = "objc2-core-foundation"))]
339    pub fn AudioServicesPlaySystemSoundWithDetails(
340        in_system_sound_id: SystemSoundID,
341        in_details: Option<&CFDictionary>,
342        in_completion_block: Option<&block2::DynBlock<dyn Fn()>>,
343    );
344}
345
346extern "C-unwind" {
347    /// Play the alert designated by the provided SystemSoundID.
348    ///
349    /// Parameter `inSystemSoundID`: A SystemSoundID for the system sound server to play with alert sound behavior.
350    ///
351    /// Parameter `inDetails`: A set of details as described above.
352    ///
353    /// Parameter `inCompletionBlock`: The completion block gets executed for every attempt to play a system sound irrespective
354    /// of success or failure. The callbacks are issued on a serial queue and the client is
355    /// responsible for handling thread safety.
356    ///
357    /// # Safety
358    ///
359    /// `in_details` generics must be of the correct type.
360    #[cfg(all(feature = "block2", feature = "objc2-core-foundation"))]
361    pub fn AudioServicesPlayAlertSoundWithDetails(
362        in_system_sound_id: SystemSoundID,
363        in_details: Option<&CFDictionary>,
364        in_completion_block: Option<&block2::DynBlock<dyn Fn()>>,
365    );
366}