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
56extern_conformance!(
57 unsafe impl NSObjectProtocol for AVAudioRoutingArbiter {}
58);
59
60impl AVAudioRoutingArbiter {
61 extern_methods!(
62 #[unsafe(method(init))]
63 #[unsafe(method_family = init)]
64 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
65
66 #[unsafe(method(new))]
67 #[unsafe(method_family = new)]
68 pub unsafe fn new() -> Retained<Self>;
69
70 /// Returns the singleton AVAudioRoutingArbiter instance.
71 #[unsafe(method(sharedRoutingArbiter))]
72 #[unsafe(method_family = none)]
73 pub unsafe fn sharedRoutingArbiter() -> Retained<AVAudioRoutingArbiter>;
74
75 #[cfg(feature = "block2")]
76 /// Begin routing arbitration to take ownership of nearby Bluetooth audio routes.
77 ///
78 /// When an app wants to participate in automatic audio arbitration for the wireless headphones route, it has to begin arbitration
79 /// specifying its arbitration session category. It provides the operating system time to arbitrate with other nearby Apple
80 /// devices to obtain ownership of supported Bluetooth audio devices. Then upon completion of arbitration, the operating system
81 /// will automatically determine whether to route audio to the nearby Bluetooth device. Once arbitration completes, the application
82 /// is free to start running audio I/O. I/O will be started upon the app request even if the -beginArbitrationWithCategory:completionHandler: fails.
83 /// This method should also be used whenever restarting audio I/O in order to allow the system to arbitrate for ownership of a Bluetooth
84 /// device that may have been taken by another nearby Apple device during the time that I/O was stopped.
85 ///
86 /// Parameter `category`: The category describes the general type of audio that the app plans to use.
87 ///
88 /// Parameter `handler`: A client-supplied block called asynchronously when audio routing arbitration is completed.
89 /// This completion handler takes the following parameters:
90 /// defaultDeviceChanged
91 /// Indicating that the system default audio device has been changed as a result of the arbitration operation.
92 /// error
93 /// An error object that indicates why the request failed, or nil if the request was successful.
94 #[unsafe(method(beginArbitrationWithCategory:completionHandler:))]
95 #[unsafe(method_family = none)]
96 pub unsafe fn beginArbitrationWithCategory_completionHandler(
97 &self,
98 category: AVAudioRoutingArbitrationCategory,
99 handler: &block2::DynBlock<dyn Fn(Bool, *mut NSError)>,
100 );
101
102 /// Stop participating in audio routing arbitration.
103 ///
104 /// When an application has stopped using audio for the foreseeable future, it should notify the system. For example,
105 /// in Voice over IP (VoIP) use cases, the application should call -leaveArbitration when the VoIP call has ended.
106 /// This allows the system to make a better decision when other participating Apple devices would like to take ownership
107 /// of a nearby Bluetooth device. Applications should not call this API in cases where audio is only momentarily paused.
108 #[unsafe(method(leaveArbitration))]
109 #[unsafe(method_family = none)]
110 pub unsafe fn leaveArbitration(&self);
111 );
112}