objc2_avf_audio/generated/
AVAudioUnit.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6#[cfg(feature = "objc2-audio-toolbox")]
7#[cfg(not(target_os = "watchos"))]
8use objc2_audio_toolbox::*;
9use objc2_foundation::*;
10
11use crate::*;
12
13extern_class!(
14    /// An AVAudioNode implemented by an audio unit.
15    ///
16    /// An AVAudioUnit is an AVAudioNode implemented by an audio unit. Depending on the type of
17    /// the audio unit, audio is processed either in real-time or non real-time.
18    ///
19    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfaudio/avaudiounit?language=objc)
20    #[unsafe(super(AVAudioNode, NSObject))]
21    #[derive(Debug, PartialEq, Eq, Hash)]
22    #[cfg(feature = "AVAudioNode")]
23    pub struct AVAudioUnit;
24);
25
26#[cfg(feature = "AVAudioNode")]
27unsafe impl NSObjectProtocol for AVAudioUnit {}
28
29#[cfg(feature = "AVAudioNode")]
30impl AVAudioUnit {
31    extern_methods!(
32        #[cfg(all(feature = "block2", feature = "objc2-audio-toolbox"))]
33        #[cfg(not(target_os = "watchos"))]
34        /// Asynchronously create an instance of an audio unit component, wrapped in an AVAudioUnit.
35        ///
36        /// Parameter `audioComponentDescription`: The component to instantiate.
37        ///
38        /// Parameter `options`: Instantiation options.
39        ///
40        /// Parameter `completionHandler`: Called in an arbitrary thread/queue context when instantiation is complete. The client
41        /// should retain the provided AVAudioUnit.
42        ///
43        /// Components whose flags include kAudioComponentFlag_RequiresAsyncInstantiation must be
44        /// instantiated asynchronously, via this method if they are to be used with AVAudioEngine.
45        /// See the discussion of this flag in AudioToolbox/AudioComponent.h.
46        ///
47        /// The returned AVAudioUnit instance normally will be of a subclass (AVAudioUnitEffect,
48        /// AVAudioUnitGenerator, AVAudioUnitMIDIInstrument, or AVAudioUnitTimeEffect), selected
49        /// according to the component's type.
50        #[unsafe(method(instantiateWithComponentDescription:options:completionHandler:))]
51        #[unsafe(method_family = none)]
52        pub unsafe fn instantiateWithComponentDescription_options_completionHandler(
53            audio_component_description: AudioComponentDescription,
54            options: AudioComponentInstantiationOptions,
55            completion_handler: &block2::Block<dyn Fn(*mut AVAudioUnit, *mut NSError)>,
56        );
57
58        /// Load an audio unit preset.
59        ///
60        /// Parameter `url`: NSURL of the .aupreset file.
61        ///
62        /// Parameter `outError`: A pointer to a NSError object
63        ///
64        /// If the .aupreset file cannot be successfully loaded, an error is returned.
65        #[unsafe(method(loadAudioUnitPresetAtURL:error:_))]
66        #[unsafe(method_family = none)]
67        pub unsafe fn loadAudioUnitPresetAtURL_error(
68            &self,
69            url: &NSURL,
70        ) -> Result<(), Retained<NSError>>;
71
72        #[cfg(feature = "objc2-audio-toolbox")]
73        #[cfg(not(target_os = "watchos"))]
74        /// AudioComponentDescription of the underlying audio unit.
75        #[unsafe(method(audioComponentDescription))]
76        #[unsafe(method_family = none)]
77        pub unsafe fn audioComponentDescription(&self) -> AudioComponentDescription;
78
79        #[cfg(feature = "objc2-audio-toolbox")]
80        #[cfg(not(target_os = "watchos"))]
81        /// Reference to the underlying audio unit.
82        ///
83        /// A reference to the underlying audio unit is provided so that parameters that are not
84        /// exposed by AVAudioUnit subclasses can be modified using the AudioUnit C API.
85        ///
86        /// No operations that may conflict with state maintained by the engine should be performed
87        /// directly on the audio unit. These include changing initialization state, stream formats,
88        /// channel layouts or connections to other audio units.
89        #[unsafe(method(audioUnit))]
90        #[unsafe(method_family = none)]
91        pub unsafe fn audioUnit(&self) -> AudioUnit;
92
93        #[cfg(feature = "objc2-audio-toolbox")]
94        #[cfg(not(target_os = "watchos"))]
95        /// An AUAudioUnit wrapping or underlying the implementation's AudioUnit.
96        ///
97        /// This provides an AUAudioUnit which either wraps or underlies the implementation's
98        /// AudioUnit, depending on how that audio unit is packaged. Applications can interact with this
99        /// AUAudioUnit to control custom properties, select presets, change parameters, etc.
100        ///
101        /// As with the audioUnit property, no operations that may conflict with state maintained by the
102        /// engine should be performed directly on the audio unit. These include changing initialization
103        /// state, stream formats, channel layouts or connections to other audio units.
104        #[unsafe(method(AUAudioUnit))]
105        #[unsafe(method_family = none)]
106        pub unsafe fn AUAudioUnit(&self) -> Retained<AUAudioUnit>;
107
108        /// Name of the audio unit.
109        #[unsafe(method(name))]
110        #[unsafe(method_family = none)]
111        pub unsafe fn name(&self) -> Retained<NSString>;
112
113        /// Manufacturer name of the audio unit.
114        #[unsafe(method(manufacturerName))]
115        #[unsafe(method_family = none)]
116        pub unsafe fn manufacturerName(&self) -> Retained<NSString>;
117
118        /// Version number of the audio unit.
119        #[unsafe(method(version))]
120        #[unsafe(method_family = none)]
121        pub unsafe fn version(&self) -> NSUInteger;
122    );
123}
124
125/// Methods declared on superclass `NSObject`.
126#[cfg(feature = "AVAudioNode")]
127impl AVAudioUnit {
128    extern_methods!(
129        #[unsafe(method(init))]
130        #[unsafe(method_family = init)]
131        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
132
133        #[unsafe(method(new))]
134        #[unsafe(method_family = new)]
135        pub unsafe fn new() -> Retained<Self>;
136    );
137}