objc2_avf_audio/generated/
AVAudioRoutingArbiter.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::*;
6use objc2_foundation::*;
7
8use crate::*;
9
10/// The category describes the general type of audio that the app plans to use.
11///
12/// Provides context to the operating system about the type of audio an application intends to use. The system uses this information
13/// when arbitrating between Apple products that want to take ownership of Bluetooth audio routes.
14///
15/// Used for Audio playback.
16///
17/// Used for recording and playing back audio.
18///
19/// Appropriate for Voice over IP(VoIP) applications.
20///
21/// See also [Apple's documentation](https://developer.apple.com/documentation/avfaudio/avaudioroutingarbitrationcategory?language=objc)
22// NS_ENUM
23#[repr(transparent)]
24#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
25pub struct AVAudioRoutingArbitrationCategory(pub NSInteger);
26impl AVAudioRoutingArbitrationCategory {
27    #[doc(alias = "AVAudioRoutingArbitrationCategoryPlayback")]
28    pub const Playback: Self = Self(0);
29    #[doc(alias = "AVAudioRoutingArbitrationCategoryPlayAndRecord")]
30    pub const PlayAndRecord: Self = Self(1);
31    #[doc(alias = "AVAudioRoutingArbitrationCategoryPlayAndRecordVoice")]
32    pub const PlayAndRecordVoice: Self = Self(2);
33}
34
35unsafe impl Encode for AVAudioRoutingArbitrationCategory {
36    const ENCODING: Encoding = NSInteger::ENCODING;
37}
38
39unsafe impl RefEncode for AVAudioRoutingArbitrationCategory {
40    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
41}
42
43extern_class!(
44    /// The interface to participate in audio routing arbitration.
45    ///
46    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfaudio/avaudioroutingarbiter?language=objc)
47    #[unsafe(super(NSObject))]
48    #[derive(Debug, PartialEq, Eq, Hash)]
49    pub struct AVAudioRoutingArbiter;
50);
51
52unsafe impl Send for AVAudioRoutingArbiter {}
53
54unsafe impl Sync for AVAudioRoutingArbiter {}
55
56unsafe impl NSObjectProtocol for AVAudioRoutingArbiter {}
57
58impl AVAudioRoutingArbiter {
59    extern_methods!(
60        #[unsafe(method(init))]
61        #[unsafe(method_family = init)]
62        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
63
64        #[unsafe(method(new))]
65        #[unsafe(method_family = new)]
66        pub unsafe fn new() -> Retained<Self>;
67
68        /// Returns the singleton AVAudioRoutingArbiter instance.
69        #[unsafe(method(sharedRoutingArbiter))]
70        #[unsafe(method_family = none)]
71        pub unsafe fn sharedRoutingArbiter() -> Retained<AVAudioRoutingArbiter>;
72
73        #[cfg(feature = "block2")]
74        /// Begin routing arbitration to take ownership of nearby Bluetooth audio routes.
75        ///
76        /// When an app wants to participate in automatic audio arbitration for the wireless headphones route, it has to begin arbitration
77        /// specifying its arbitration session category. It provides the operating system time to arbitrate with other nearby Apple
78        /// devices to obtain ownership of supported Bluetooth audio devices. Then upon completion of arbitration, the operating system
79        /// will automatically determine  whether to route audio to the nearby Bluetooth device. Once arbitration completes, the application
80        /// is free to start running audio I/O. I/O will be started upon the app request even if the -beginArbitrationWithCategory:completionHandler: fails.
81        /// This method should also be used whenever restarting audio I/O in order to allow the system to arbitrate for ownership of a Bluetooth
82        /// device that may have been taken by another nearby Apple device during the time that I/O was stopped.
83        ///
84        /// Parameter `category`: The category describes the general type of audio that the app plans to use.
85        ///
86        /// Parameter `handler`: A client-supplied block called asynchronously when audio routing arbitration is completed.
87        /// This completion handler takes the following parameters:
88        /// defaultDeviceChanged
89        /// Indicating that the system default audio device has been changed as a result of the arbitration operation.
90        /// error
91        /// An error object that indicates why the request failed, or nil if the request was successful.
92        #[unsafe(method(beginArbitrationWithCategory:completionHandler:))]
93        #[unsafe(method_family = none)]
94        pub unsafe fn beginArbitrationWithCategory_completionHandler(
95            &self,
96            category: AVAudioRoutingArbitrationCategory,
97            handler: &block2::Block<dyn Fn(Bool, *mut NSError)>,
98        );
99
100        /// Stop participating in audio routing arbitration.
101        ///
102        /// When an application has stopped using audio for the foreseeable future, it should notify the system. For example,
103        /// in Voice over IP (VoIP)  use cases, the application should call -leaveArbitration when the VoIP call has ended.
104        /// This allows the system to make a better decision when other participating Apple devices would like to take ownership
105        /// of a nearby Bluetooth device. Applications should not call this API in cases where audio is only momentarily paused.
106        #[unsafe(method(leaveArbitration))]
107        #[unsafe(method_family = none)]
108        pub unsafe fn leaveArbitration(&self);
109    );
110}