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