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::Block<
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")]
61unsafe impl NSObjectProtocol for AVAudioSinkNode {}
62
63#[cfg(feature = "AVAudioNode")]
64impl AVAudioSinkNode {
65    extern_methods!(
66        #[unsafe(method(init))]
67        #[unsafe(method_family = init)]
68        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
69
70        #[cfg(all(
71            feature = "AVAudioTypes",
72            feature = "block2",
73            feature = "objc2-core-audio-types"
74        ))]
75        /// Create a node with a receiver block.
76        ///
77        /// Parameter `block`: The block that receives audio data from the input.
78        ///
79        /// The receiver block is called when the input data is available.
80        ///
81        /// The block will be called on the realtime thread and it is the client's responsibility to
82        /// handle it in a thread-safe manner and to not make any blocking calls.
83        ///
84        /// The audio format for the input bus will be set from the connection format when connecting
85        /// to another node.
86        ///
87        /// The audio format for the data received by the block will be set to the node's input format.
88        #[unsafe(method(initWithReceiverBlock:))]
89        #[unsafe(method_family = init)]
90        pub unsafe fn initWithReceiverBlock(
91            this: Allocated<Self>,
92            block: AVAudioSinkNodeReceiverBlock,
93        ) -> Retained<Self>;
94    );
95}
96
97/// Methods declared on superclass `NSObject`.
98#[cfg(feature = "AVAudioNode")]
99impl AVAudioSinkNode {
100    extern_methods!(
101        #[unsafe(method(new))]
102        #[unsafe(method_family = new)]
103        pub unsafe fn new() -> Retained<Self>;
104    );
105}