ohaudio_sys/audio_routing_manager/audio_routing_manager_ffi.rs
1// automatically generated by rust-bindgen 0.71.1
2
3#![allow(non_upper_case_globals)]
4#![allow(non_camel_case_types)]
5#![allow(non_snake_case)]
6use crate::audio_common::OH_AudioCommon_Result;
7#[cfg(feature = "api-13")]
8use crate::audio_device_base::OH_AudioDevice_BlockStatus;
9use crate::audio_device_base::{
10 OH_AudioDeviceDescriptorArray, OH_AudioDevice_ChangeType, OH_AudioDevice_Flag,
11 OH_AudioDevice_Usage,
12};
13use crate::audiostream_base::{OH_AudioStream_SourceType, OH_AudioStream_Usage};
14
15/// Declaring the audio routing manager.
16/// The handle of audio routing manager used for routing and device related functions.
17///
18///
19/// Available since API-level: 12
20#[cfg(feature = "api-12")]
21#[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
22#[repr(C)]
23pub struct OH_AudioRoutingManager {
24 _unused: [u8; 0],
25}
26/// This function pointer will point to the callback function that
27/// is used to return the changing audio device descriptors.
28/// There may be more than one audio device descriptor returned.
29///
30/// # Arguments
31///
32/// * `type` - the [`OH_AudioDevice_ChangeType`] is connect or disconnect.
33///
34/// * `audioDeviceDescriptorArray` - the [`OH_AudioDeviceDescriptorArray`]
35/// pointer variable which will be set the audio device descriptors value.
36/// Do not release the audioDeviceDescriptorArray pointer separately
37/// instead call [`OH_AudioRoutingManager_ReleaseDevices`] to release the DeviceDescriptor array
38/// when it is no use anymore.
39///
40/// Available since API-level: 12
41#[cfg(feature = "api-12")]
42#[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
43pub type OH_AudioRoutingManager_OnDeviceChangedCallback = ::core::option::Option<
44 unsafe extern "C" fn(
45 type_: OH_AudioDevice_ChangeType,
46 audioDeviceDescriptorArray: *mut OH_AudioDeviceDescriptorArray,
47 ) -> i32,
48>;
49/// This type defines the callback function that is used to receive the audio devices' block status.
50///
51/// # Arguments
52///
53/// * `audioDeviceDescriptorArray` - The [`OH_AudioDeviceDescriptorArray`]
54/// pointer variable which will be set the audio device descriptors value.
55/// Do not release the audioDeviceDescriptorArray pointer separately instead of calling
56/// [`OH_AudioRoutingManager_ReleaseDevices`] to release the DeviceDescriptor array when it is no use anymore.
57///
58/// * `status` - The [`OH_AudioDevice_BlockStatus`] is the block status.
59///
60/// * `userData` - User data which is passed by user.
61///
62/// Available since API-level: 13
63#[cfg(feature = "api-13")]
64#[cfg_attr(docsrs, doc(cfg(feature = "api-13")))]
65pub type OH_AudioRoutingManager_OnDeviceBlockStatusCallback = ::core::option::Option<
66 unsafe extern "C" fn(
67 audioDeviceDescriptorArray: *mut OH_AudioDeviceDescriptorArray,
68 status: OH_AudioDevice_BlockStatus,
69 userData: *mut ::core::ffi::c_void,
70 ),
71>;
72extern "C" {
73 /// Query the audio routing manager handle.
74 /// which should be set as the first parameter in routing releated functions.
75 ///
76 /// # Arguments
77 ///
78 /// * `audioRoutingManager` - the [`OH_AudioRoutingManager`]
79 /// handle returned by [`OH_AudioManager_GetAudioRoutingManager`].
80 ///
81 /// # Returns
82 ///
83 /// * Function result code:
84 /// [`AUDIOCOMMON_RESULT_SUCCESS`] If the execution is successful.
85 ///
86 /// Available since API-level: 12
87 #[cfg(feature = "api-12")]
88 #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
89 pub fn OH_AudioManager_GetAudioRoutingManager(
90 audioRoutingManager: *mut *mut OH_AudioRoutingManager,
91 ) -> OH_AudioCommon_Result;
92 /// Query the available devices according to the input deviceFlag.
93 ///
94 /// # Arguments
95 ///
96 /// * `audioRoutingManager` - the [`OH_AudioRoutingManager`]
97 /// handle returned by [`OH_AudioManager_GetAudioRoutingManager`].
98 ///
99 /// * `deviceFlag` - the [`OH_AudioDevice_DeviceFlag`] which is used as
100 /// the filter parameter for selecting the target devices.
101 ///
102 /// * `audioDeviceDescriptorArray` - the [`OH_AudioDeviceDescriptorArray`]
103 /// pointer variable which will be set the audio device descriptors value
104 /// Do not release the audioDeviceDescriptorArray pointer separately
105 /// instead call [`OH_AudioRoutingManager_ReleaseDevices`] to release the DeviceDescriptor array
106 /// when it is no use anymore.
107 ///
108 /// # Returns
109 ///
110 /// * Function result code:
111 /// [`AUDIOCOMMON_RESULT_SUCCESS`] If the execution is successful.
112 /// [`AUDIOCOMMON_RESULT_ERROR_INVALID_PARAM`]:
113 /// 1.The param of audioRoutingManager is nullptr;
114 /// 2.The param of deviceFlag invalid;
115 /// 3.The param of audioDeviceDescriptorArray is nullptr.
116 /// [`AUDIOCOMMON_RESULT_ERROR_NO_MEMORY`] The param of audioDeviceDescriptorArray is nullptr.
117 ///
118 /// Available since API-level: 12
119 #[cfg(feature = "api-12")]
120 #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
121 pub fn OH_AudioRoutingManager_GetDevices(
122 audioRoutingManager: *mut OH_AudioRoutingManager,
123 deviceFlag: OH_AudioDevice_Flag,
124 audioDeviceDescriptorArray: *mut *mut OH_AudioDeviceDescriptorArray,
125 ) -> OH_AudioCommon_Result;
126 /// Get available devices by device usage.
127 ///
128 /// # Arguments
129 ///
130 /// * `audioRoutingManager` - the [`OH_AudioRoutingManager`] handle returned
131 /// by [`OH_AudioManager_GetAudioRoutingManager`].
132 ///
133 /// * `deviceUsage` - the [`OH_AudioDevice_Usage`].
134 ///
135 /// * `audioDeviceDescriptorArray` - the [`OH_AudioDeviceDescriptorArray`]
136 /// pointer variable which will be set the audio device descriptors value
137 /// Do not release the audioDeviceDescriptorArray pointer separately
138 /// instead call [`OH_AudioRoutingManager_ReleaseDevices`] to release the DeviceDescriptor array
139 /// when it is no use anymore.
140 ///
141 /// # Returns
142 ///
143 /// * Function result code:
144 /// [`AUDIOCOMMON_RESULT_SUCCESS`] If the execution is successful.
145 /// [`AUDIOCOMMON_RESULT_ERROR_INVALID_PARAM`]:
146 /// 1.The param of audioRoutingManager is nullptr;
147 /// 2.The param of deviceUsage is invalid;
148 /// 3.The param of audioDeviceDescriptorArray is nullptr.
149 /// [`AUDIOCOMMON_RESULT_ERROR_NO_MEMORY`] No memory error.
150 ///
151 /// Available since API-level: 12
152 #[cfg(feature = "api-12")]
153 #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
154 pub fn OH_AudioRoutingManager_GetAvailableDevices(
155 audioRoutingManager: *mut OH_AudioRoutingManager,
156 deviceUsage: OH_AudioDevice_Usage,
157 audioDeviceDescriptorArray: *mut *mut OH_AudioDeviceDescriptorArray,
158 ) -> OH_AudioCommon_Result;
159 /// Get preferred ouput devices by audio usage.
160 ///
161 /// # Arguments
162 ///
163 /// * `audioRoutingManager` - the [`OH_AudioRoutingManager`] handle returned
164 /// by [`OH_AudioManager_GetAudioRoutingManager`].
165 ///
166 /// * `streamUsage` - the [`OH_AudioStream_Usage`].
167 ///
168 /// * `audioDeviceDescriptorArray` - the [`OH_AudioDeviceDescriptorArray`]
169 /// pointer variable which will be set the audio device descriptors value
170 /// Do not release the audioDeviceDescriptorArray pointer separately
171 /// instead call [`OH_AudioRoutingManager_ReleaseDevices`] to release the DeviceDescriptor array
172 /// when it is no use anymore.
173 ///
174 /// # Returns
175 ///
176 /// * Function result code:
177 /// [`AUDIOCOMMON_RESULT_SUCCESS`] If the execution is successful.
178 /// [`AUDIOCOMMON_RESULT_ERROR_INVALID_PARAM`]:
179 /// 1.The param of audioRoutingManager is nullptr;
180 /// 2.The param of streamUsage is invalid;
181 /// 3.The param of audioDeviceDescriptorArray is nullptr.
182 /// [`AUDIOCOMMON_RESULT_ERROR_NO_MEMORY`] No memory error.
183 ///
184 /// Available since API-level: 12
185 #[cfg(feature = "api-12")]
186 #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
187 pub fn OH_AudioRoutingManager_GetPreferredOutputDevice(
188 audioRoutingManager: *mut OH_AudioRoutingManager,
189 streamUsage: OH_AudioStream_Usage,
190 audioDeviceDescriptorArray: *mut *mut OH_AudioDeviceDescriptorArray,
191 ) -> OH_AudioCommon_Result;
192 /// Get preferred input devices by audio source type.
193 /// # Arguments
194 ///
195 /// * `audioRoutingManager` - the [`OH_AudioRoutingManager`] handle returned
196 /// by [`OH_AudioManager_GetAudioRoutingManager`].
197 ///
198 /// * `sourceType` - the [`OH_AudioStream_SourceType`].
199 ///
200 /// * `audioDeviceDescriptorArray` - the [`OH_AudioDeviceDescriptorArray`]
201 /// pointer variable which will be set the audio device descriptors value
202 /// Do not release the audioDeviceDescriptorArray pointer separately
203 /// instead call [`OH_AudioRoutingManager_ReleaseDevices`] to release the DeviceDescriptor array
204 /// when it is no use anymore.
205 ///
206 /// # Returns
207 ///
208 /// * Function result code:
209 /// [`AUDIOCOMMON_RESULT_SUCCESS`] If the execution is successful.
210 /// [`AUDIOCOMMON_RESULT_ERROR_INVALID_PARAM`]:
211 /// 1.The param of audioRoutingManager is nullptr;
212 /// 2.The param of sourceType is invalid;
213 /// 3.The param of audioDeviceDescriptorArray is nullptr.
214 /// [`AUDIOCOMMON_RESULT_ERROR_NO_MEMORY`] No memory error.
215 ///
216 /// Available since API-level: 12
217 #[cfg(feature = "api-12")]
218 #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
219 pub fn OH_AudioRoutingManager_GetPreferredInputDevice(
220 audioRoutingManager: *mut OH_AudioRoutingManager,
221 sourceType: OH_AudioStream_SourceType,
222 audioDeviceDescriptorArray: *mut *mut OH_AudioDeviceDescriptorArray,
223 ) -> OH_AudioCommon_Result;
224 /// Register the device change callback of the audio routing manager.
225 ///
226 /// # Arguments
227 ///
228 /// * `audioRoutingManager` - the [`OH_AudioRoutingManager`]
229 /// handle returned by [`OH_AudioManager_GetAudioRoutingManager`].
230 ///
231 /// * `deviceFlag` - the [`OH_AudioDevice_DeviceFlag`] which is used to register callback.
232 ///
233 /// * `callback` - the [`OH_AudioRoutingManager_OnDeviceChangedCallback`]
234 /// Callback function which will be called when devices changed.
235 ///
236 /// # Returns
237 ///
238 /// * Function result code:
239 /// [`AUDIOCOMMON_RESULT_SUCCESS`] If the execution is successful.
240 /// [`AUDIOCOMMON_RESULT_ERROR_INVALID_PARAM`]:
241 /// 1.The param of audioRoutingManager is nullptr;
242 /// 2.The param of deviceFlag invalid;
243 /// 3.The param of callback is nullptr.
244 ///
245 /// Available since API-level: 12
246 #[cfg(feature = "api-12")]
247 #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
248 pub fn OH_AudioRoutingManager_RegisterDeviceChangeCallback(
249 audioRoutingManager: *mut OH_AudioRoutingManager,
250 deviceFlag: OH_AudioDevice_Flag,
251 callback: OH_AudioRoutingManager_OnDeviceChangedCallback,
252 ) -> OH_AudioCommon_Result;
253 /// Unregister the device change callback of the audio routing manager.
254 ///
255 /// # Arguments
256 ///
257 /// * `audioRoutingManager` - the [`OH_AudioRoutingManager`]
258 /// handle returned by [`OH_AudioManager_GetAudioRoutingManager`].
259 ///
260 /// * `callback` - the [`OH_AudioRoutingManager_OnDeviceChangedCallback`]
261 /// Callback function which will be called when devices changed.
262 ///
263 /// # Returns
264 ///
265 /// * Function result code:
266 /// [`AUDIOCOMMON_RESULT_SUCCESS`] If the execution is successful.
267 /// [`AUDIOCOMMON_RESULT_ERROR_INVALID_PARAM`]:
268 /// 1.The param of audioRoutingManager is nullptr;
269 /// 2.The param of callback is nullptr.
270 ///
271 /// Available since API-level: 12
272 #[cfg(feature = "api-12")]
273 #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
274 pub fn OH_AudioRoutingManager_UnregisterDeviceChangeCallback(
275 audioRoutingManager: *mut OH_AudioRoutingManager,
276 callback: OH_AudioRoutingManager_OnDeviceChangedCallback,
277 ) -> OH_AudioCommon_Result;
278 /// Release the audio device descriptor array object.
279 ///
280 /// # Arguments
281 ///
282 /// * `audioRoutingManager` - the [`OH_AudioRoutingManager`]
283 /// handle returned by [`OH_AudioManager_GetAudioRoutingManager`].
284 ///
285 /// * `audioDeviceDescriptorArray` - Audio device descriptors should be released.
286 /// and get from [`OH_AudioRoutingManager_GetDevices`]
287 ///
288 /// # Returns
289 ///
290 /// * Function result code:
291 /// [`AUDIOCOMMON_RESULT_SUCCESS`] If the execution is successful.
292 /// [`AUDIOCOMMON_RESULT_ERROR_INVALID_PARAM`]:
293 /// 1.The param of audioRoutingManager is nullptr;
294 /// 2.The param of audioDeviceDescriptorArray is nullptr.
295 ///
296 /// Available since API-level: 12
297 #[cfg(feature = "api-12")]
298 #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
299 pub fn OH_AudioRoutingManager_ReleaseDevices(
300 audioRoutingManager: *mut OH_AudioRoutingManager,
301 audioDeviceDescriptorArray: *mut OH_AudioDeviceDescriptorArray,
302 ) -> OH_AudioCommon_Result;
303 /// Query whether microphone block detection is supported on current device.
304 ///
305 /// # Arguments
306 ///
307 /// * `audioRoutingManager` - the [`OH_AudioRoutingManager`] handle returned by
308 /// [`OH_AudioManager_GetAudioRoutingManager`].
309 ///
310 /// * `supported` - query result.
311 ///
312 /// # Returns
313 ///
314 /// * Function result code:
315 /// [`AUDIOCOMMON_RESULT_SUCCESS`] If the execution is successful.
316 /// [`AUDIOCOMMON_RESULT_ERROR_INVALID_PARAM`]:
317 /// 1.The param of audioRoutingManager is nullptr;
318 /// 2.The param of supported is nullptr.
319 ///
320 /// Available since API-level: 13
321 #[cfg(feature = "api-13")]
322 #[cfg_attr(docsrs, doc(cfg(feature = "api-13")))]
323 pub fn OH_AudioRoutingManager_IsMicBlockDetectionSupported(
324 audioRoutingManager: *mut OH_AudioRoutingManager,
325 supported: *mut bool,
326 ) -> OH_AudioCommon_Result;
327 /// Set the microphone block status callback. Before using this function, users should query whether block
328 /// detection is supported on current device. The caller will receive the callback only when it is recording
329 /// and the used microphones' block status have changed. Currently, block detecting is only support for microphones
330 /// located on the local device.
331 ///
332 /// # Arguments
333 ///
334 /// * `audioRoutingManager` - The [`OH_AudioRoutingManager`] handle returned by
335 /// [`OH_AudioManager_GetAudioRoutingManager`].
336 ///
337 /// * `callback` - The function pointer will point to the callback function that is used to receive the block status.
338 ///
339 /// * `userData` - User data which is passed by user.
340 ///
341 /// # Returns
342 ///
343 /// * Function result code:
344 /// [`AUDIOCOMMON_RESULT_SUCCESS`] If the execution is successful.
345 /// [`AUDIOCOMMON_RESULT_ERROR_INVALID_PARAM`]:
346 /// 1.The param of audioRoutingManager is nullptr;
347 /// 2.The param of callback is nullptr.
348 ///
349 /// Available since API-level: 13
350 #[cfg(feature = "api-13")]
351 #[cfg_attr(docsrs, doc(cfg(feature = "api-13")))]
352 pub fn OH_AudioRoutingManager_SetMicBlockStatusCallback(
353 audioRoutingManager: *mut OH_AudioRoutingManager,
354 callback: OH_AudioRoutingManager_OnDeviceBlockStatusCallback,
355 userData: *mut ::core::ffi::c_void,
356 ) -> OH_AudioCommon_Result;
357}