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 #[unsafe(method(initWithRenderBlock:))]
108 #[unsafe(method_family = init)]
109 pub unsafe fn initWithRenderBlock(
110 this: Allocated<Self>,
111 block: AVAudioSourceNodeRenderBlock,
112 ) -> Retained<Self>;
113
114 #[cfg(all(
115 feature = "AVAudioFormat",
116 feature = "AVAudioTypes",
117 feature = "block2",
118 feature = "objc2-core-audio-types"
119 ))]
120 /// Create a node with a render block.
121 ///
122 /// Parameter `format`: The format of the PCM audio data that will be supplied by the block.
123 ///
124 /// Parameter `block`: The block to supply audio data to the output.
125 ///
126 /// The block can be called on realtime or non-realtime threads depending on the engine’s
127 /// operating mode and it is the client's responsibility to handle it in a thread-safe manner.
128 ///
129 /// The audio format for the output bus will be set from the connection format when connecting
130 /// to another node.
131 ///
132 /// AVAudioSourceNode supports different audio formats for the block and output, but only
133 /// Linear PCM conversions are supported (sample rate, bit depth, interleaving).
134 #[unsafe(method(initWithFormat:renderBlock:))]
135 #[unsafe(method_family = init)]
136 pub unsafe fn initWithFormat_renderBlock(
137 this: Allocated<Self>,
138 format: &AVAudioFormat,
139 block: AVAudioSourceNodeRenderBlock,
140 ) -> Retained<Self>;
141 );
142}
143
144/// Methods declared on superclass `NSObject`.
145#[cfg(feature = "AVAudioNode")]
146impl AVAudioSourceNode {
147 extern_methods!(
148 #[unsafe(method(new))]
149 #[unsafe(method_family = new)]
150 pub unsafe fn new() -> Retained<Self>;
151 );
152}