objc2_avf_audio/generated/AVAudioSourceNode.rs
1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ptr::NonNull;
4use objc2::__framework_prelude::*;
5#[cfg(feature = "objc2-core-audio-types")]
6use objc2_core_audio_types::*;
7
8use crate::*;
9
10/// Block to supply audio data to AVAudioSourceNode
11///
12/// Parameter `isSilence`: The client may use this flag to indicate that the buffer it vends contains only silence.
13/// The receiver of the buffer can then use the flag as a hint as to whether the buffer needs
14/// to be processed or not.
15/// Note that because the flag is only a hint, when setting the silence flag, the originator of
16/// a buffer must also ensure that it contains silence (zeroes).
17///
18/// Parameter `timestamp`: The HAL time at which the audio data will be rendered. If there is a sample rate conversion
19/// or time compression/expansion downstream, the sample time will not be valid.
20///
21/// Parameter `frameCount`: The number of sample frames of audio data requested.
22///
23/// Parameter `outputData`: The output data.
24///
25/// The caller must supply valid buffers in outputData's mBuffers' mData and mDataByteSize.
26/// mDataByteSize must be consistent with frameCount. This block may provide output in those
27/// specified buffers, or it may replace the mData pointers with pointers to memory which it
28/// owns and guarantees will remain valid until the next render cycle.
29///
30/// Returns: An OSStatus result code. If an error is returned, the audio data should be assumed to be
31/// invalid.
32///
33/// See also [Apple's documentation](https://developer.apple.com/documentation/avfaudio/avaudiosourcenoderenderblock?language=objc)
34#[cfg(all(
35 feature = "AVAudioTypes",
36 feature = "block2",
37 feature = "objc2-core-audio-types"
38))]
39pub type AVAudioSourceNodeRenderBlock = *mut block2::DynBlock<
40 dyn Fn(
41 NonNull<Bool>,
42 NonNull<AudioTimeStamp>,
43 AVAudioFrameCount,
44 NonNull<AudioBufferList>,
45 ) -> OSStatus,
46>;
47
48extern_class!(
49 /// AVAudioSourceNode wraps a client provided block to supply audio.
50 ///
51 /// With AVAudioSourceNode the client can supply audio data for rendering through an
52 /// AVAudioSourceNodeRenderBlock block.
53 /// This is similar to setting the input callback on an Audio Unit with the
54 /// kAudioUnitProperty_SetRenderCallback property.
55 ///
56 /// See also [Apple's documentation](https://developer.apple.com/documentation/avfaudio/avaudiosourcenode?language=objc)
57 #[unsafe(super(AVAudioNode, NSObject))]
58 #[derive(Debug, PartialEq, Eq, Hash)]
59 #[cfg(feature = "AVAudioNode")]
60 pub struct AVAudioSourceNode;
61);
62
63#[cfg(all(feature = "AVAudioMixing", feature = "AVAudioNode"))]
64extern_conformance!(
65 unsafe impl AVAudio3DMixing for AVAudioSourceNode {}
66);
67
68#[cfg(all(feature = "AVAudioMixing", feature = "AVAudioNode"))]
69extern_conformance!(
70 unsafe impl AVAudioMixing for AVAudioSourceNode {}
71);
72
73#[cfg(all(feature = "AVAudioMixing", feature = "AVAudioNode"))]
74extern_conformance!(
75 unsafe impl AVAudioStereoMixing for AVAudioSourceNode {}
76);
77
78#[cfg(feature = "AVAudioNode")]
79extern_conformance!(
80 unsafe impl NSObjectProtocol for AVAudioSourceNode {}
81);
82
83#[cfg(feature = "AVAudioNode")]
84impl AVAudioSourceNode {
85 extern_methods!(
86 #[unsafe(method(init))]
87 #[unsafe(method_family = init)]
88 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
89
90 #[cfg(all(
91 feature = "AVAudioTypes",
92 feature = "block2",
93 feature = "objc2-core-audio-types"
94 ))]
95 /// Create a node with a render block.
96 ///
97 /// Parameter `block`: The block to supply audio data to the output.
98 ///
99 /// The block can be called on realtime or non-realtime threads depending on the engine’s
100 /// operating mode and it is the client's responsibility to handle it in a thread-safe manner.
101 ///
102 /// The audio format for the output bus will be set from the connection format when connecting
103 /// to another node.
104 ///
105 /// The audio format for the block will be set to the node's output format. If node is
106 /// reconnected with a different output format, the audio format for the block will also change.
107 ///
108 /// # Safety
109 ///
110 /// `block` must be a valid pointer.
111 #[unsafe(method(initWithRenderBlock:))]
112 #[unsafe(method_family = init)]
113 pub unsafe fn initWithRenderBlock(
114 this: Allocated<Self>,
115 block: AVAudioSourceNodeRenderBlock,
116 ) -> Retained<Self>;
117
118 #[cfg(all(
119 feature = "AVAudioFormat",
120 feature = "AVAudioTypes",
121 feature = "block2",
122 feature = "objc2-core-audio-types"
123 ))]
124 /// Create a node with a render block.
125 ///
126 /// Parameter `format`: The format of the PCM audio data that will be supplied by the block.
127 ///
128 /// Parameter `block`: The block to supply audio data to the output.
129 ///
130 /// The block can be called on realtime or non-realtime threads depending on the engine’s
131 /// operating mode and it is the client's responsibility to handle it in a thread-safe manner.
132 ///
133 /// The audio format for the output bus will be set from the connection format when connecting
134 /// to another node.
135 ///
136 /// AVAudioSourceNode supports different audio formats for the block and output, but only
137 /// Linear PCM conversions are supported (sample rate, bit depth, interleaving).
138 ///
139 /// # Safety
140 ///
141 /// `block` must be a valid pointer.
142 #[unsafe(method(initWithFormat:renderBlock:))]
143 #[unsafe(method_family = init)]
144 pub unsafe fn initWithFormat_renderBlock(
145 this: Allocated<Self>,
146 format: &AVAudioFormat,
147 block: AVAudioSourceNodeRenderBlock,
148 ) -> Retained<Self>;
149 );
150}
151
152/// Methods declared on superclass `NSObject`.
153#[cfg(feature = "AVAudioNode")]
154impl AVAudioSourceNode {
155 extern_methods!(
156 #[unsafe(method(new))]
157 #[unsafe(method_family = new)]
158 pub unsafe fn new() -> Retained<Self>;
159 );
160}