objc2_avf_audio/generated/AVAudioSinkNode.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 receive audio data from AVAudioSinkNode
11///
12/// Parameter `timestamp`: The time at which the input data will be rendered.
13///
14/// Parameter `frameCount`: The number of sample frames of input provided.
15///
16/// Parameter `inputData`: The input audio data.
17///
18/// The engine will supply valid buffers in inputData's mBuffers' mData and mDataByteSize.
19/// mDataByteSize will be consistent with frameCount.
20///
21/// The pointer to the AudioBufferList is only valid within the scope of this block.
22///
23/// Returns: An OSStatus result code. If an error is returned, the input data should be assumed to be
24/// invalid.
25///
26/// See also [Apple's documentation](https://developer.apple.com/documentation/avfaudio/avaudiosinknodereceiverblock?language=objc)
27#[cfg(all(
28 feature = "AVAudioTypes",
29 feature = "block2",
30 feature = "objc2-core-audio-types"
31))]
32pub type AVAudioSinkNodeReceiverBlock = *mut block2::DynBlock<
33 dyn Fn(NonNull<AudioTimeStamp>, AVAudioFrameCount, NonNull<AudioBufferList>) -> OSStatus,
34>;
35
36extern_class!(
37 /// AVAudioSinkNode wraps a client provided block to receive input audio on the audio IO thread.
38 ///
39 /// AVAudioSinkNode is restricted to be used in the input chain and does not support format
40 /// conversion. Hence when connecting to an AVAudioSinkNode node, the format for the connection
41 /// should be the output scope format of the input node (essentialy the format should match the input hardware
42 /// sample rate).
43 ///
44 /// The voice processing IO unit is an exception to the above as it supports sample rate conversion.
45 /// The input scope format (HW format) and output scope format (client format) of the input node can differ
46 /// in that case.
47 ///
48 /// This node is only supported when the engine is rendering to the audio device and not in
49 /// manual rendering mode.
50 ///
51 /// AVAudioSinkNode does not have an output bus and therefore it does not support tapping.
52 ///
53 /// See also [Apple's documentation](https://developer.apple.com/documentation/avfaudio/avaudiosinknode?language=objc)
54 #[unsafe(super(AVAudioNode, NSObject))]
55 #[derive(Debug, PartialEq, Eq, Hash)]
56 #[cfg(feature = "AVAudioNode")]
57 pub struct AVAudioSinkNode;
58);
59
60#[cfg(feature = "AVAudioNode")]
61extern_conformance!(
62 unsafe impl NSObjectProtocol for AVAudioSinkNode {}
63);
64
65#[cfg(feature = "AVAudioNode")]
66impl AVAudioSinkNode {
67 extern_methods!(
68 #[unsafe(method(init))]
69 #[unsafe(method_family = init)]
70 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
71
72 #[cfg(all(
73 feature = "AVAudioTypes",
74 feature = "block2",
75 feature = "objc2-core-audio-types"
76 ))]
77 /// Create a node with a receiver block.
78 ///
79 /// Parameter `block`: The block that receives audio data from the input.
80 ///
81 /// The receiver block is called when the input data is available.
82 ///
83 /// The block will be called on the realtime thread and it is the client's responsibility to
84 /// handle it in a thread-safe manner and to not make any blocking calls.
85 ///
86 /// The audio format for the input bus will be set from the connection format when connecting
87 /// to another node.
88 ///
89 /// The audio format for the data received by the block will be set to the node's input format.
90 #[unsafe(method(initWithReceiverBlock:))]
91 #[unsafe(method_family = init)]
92 pub unsafe fn initWithReceiverBlock(
93 this: Allocated<Self>,
94 block: AVAudioSinkNodeReceiverBlock,
95 ) -> Retained<Self>;
96 );
97}
98
99/// Methods declared on superclass `NSObject`.
100#[cfg(feature = "AVAudioNode")]
101impl AVAudioSinkNode {
102 extern_methods!(
103 #[unsafe(method(new))]
104 #[unsafe(method_family = new)]
105 pub unsafe fn new() -> Retained<Self>;
106 );
107}