ohaudio-sys 0.1.0

Raw Bindings to the audio module of OpenHarmony
Documentation
// automatically generated by rust-bindgen 0.71.1

#![allow(non_upper_case_globals)]
#![allow(non_camel_case_types)]
#![allow(non_snake_case)]
use crate::audio_common::OH_AudioCommon_Result;
#[cfg(feature = "api-13")]
use crate::audio_device_base::OH_AudioDevice_BlockStatus;
use crate::audio_device_base::{
    OH_AudioDeviceDescriptorArray, OH_AudioDevice_ChangeType, OH_AudioDevice_Flag,
    OH_AudioDevice_Usage,
};
use crate::audiostream_base::{OH_AudioStream_SourceType, OH_AudioStream_Usage};

/// Declaring the audio routing manager.
/// The handle of audio routing manager used for routing and device related functions.
///
///
/// Available since API-level: 12
#[cfg(feature = "api-12")]
#[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
#[repr(C)]
pub struct OH_AudioRoutingManager {
    _unused: [u8; 0],
}
/// This function pointer will point to the callback function that
/// is used to return the changing audio device descriptors.
/// There may be more than one audio device descriptor returned.
///
/// # Arguments
///
/// * `type` - the [`OH_AudioDevice_ChangeType`] is connect or disconnect.
///
/// * `audioDeviceDescriptorArray` - the [`OH_AudioDeviceDescriptorArray`]
/// pointer variable which will be set the audio device descriptors value.
/// Do not release the audioDeviceDescriptorArray pointer separately
/// instead call [`OH_AudioRoutingManager_ReleaseDevices`] to release the DeviceDescriptor array
/// when it is no use anymore.
///
/// Available since API-level: 12
#[cfg(feature = "api-12")]
#[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
pub type OH_AudioRoutingManager_OnDeviceChangedCallback = ::core::option::Option<
    unsafe extern "C" fn(
        type_: OH_AudioDevice_ChangeType,
        audioDeviceDescriptorArray: *mut OH_AudioDeviceDescriptorArray,
    ) -> i32,
>;
/// This type defines the callback function that is used to receive the audio devices' block status.
///
/// # Arguments
///
/// * `audioDeviceDescriptorArray` - The [`OH_AudioDeviceDescriptorArray`]
/// pointer variable which will be set the audio device descriptors value.
/// Do not release the audioDeviceDescriptorArray pointer separately instead of calling
/// [`OH_AudioRoutingManager_ReleaseDevices`] to release the DeviceDescriptor array when it is no use anymore.
///
/// * `status` - The [`OH_AudioDevice_BlockStatus`] is the block status.
///
/// * `userData` - User data which is passed by user.
///
/// Available since API-level: 13
#[cfg(feature = "api-13")]
#[cfg_attr(docsrs, doc(cfg(feature = "api-13")))]
pub type OH_AudioRoutingManager_OnDeviceBlockStatusCallback = ::core::option::Option<
    unsafe extern "C" fn(
        audioDeviceDescriptorArray: *mut OH_AudioDeviceDescriptorArray,
        status: OH_AudioDevice_BlockStatus,
        userData: *mut ::core::ffi::c_void,
    ),
>;
extern "C" {
    /// Query the audio routing manager handle.
    /// which should be set as the first parameter in routing releated functions.
    ///
    /// # Arguments
    ///
    /// * `audioRoutingManager` - the [`OH_AudioRoutingManager`]
    /// handle returned by [`OH_AudioManager_GetAudioRoutingManager`].
    ///
    /// # Returns
    ///
    /// * Function result code:
    /// [`AUDIOCOMMON_RESULT_SUCCESS`] If the execution is successful.
    ///
    /// Available since API-level: 12
    #[cfg(feature = "api-12")]
    #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
    pub fn OH_AudioManager_GetAudioRoutingManager(
        audioRoutingManager: *mut *mut OH_AudioRoutingManager,
    ) -> OH_AudioCommon_Result;
    /// Query the available devices according to the input deviceFlag.
    ///
    /// # Arguments
    ///
    /// * `audioRoutingManager` - the [`OH_AudioRoutingManager`]
    /// handle returned by [`OH_AudioManager_GetAudioRoutingManager`].
    ///
    /// * `deviceFlag` - the [`OH_AudioDevice_DeviceFlag`] which is used as
    /// the filter parameter for selecting the target devices.
    ///
    /// * `audioDeviceDescriptorArray` - the [`OH_AudioDeviceDescriptorArray`]
    /// pointer variable which will be set the audio device descriptors value
    /// Do not release the audioDeviceDescriptorArray pointer separately
    /// instead call [`OH_AudioRoutingManager_ReleaseDevices`] to release the DeviceDescriptor array
    /// when it is no use anymore.
    ///
    /// # Returns
    ///
    /// * Function result code:
    /// [`AUDIOCOMMON_RESULT_SUCCESS`] If the execution is successful.
    /// [`AUDIOCOMMON_RESULT_ERROR_INVALID_PARAM`]:
    /// 1.The param of audioRoutingManager is nullptr;
    /// 2.The param of deviceFlag invalid;
    /// 3.The param of audioDeviceDescriptorArray is nullptr.
    /// [`AUDIOCOMMON_RESULT_ERROR_NO_MEMORY`] The param of audioDeviceDescriptorArray is nullptr.
    ///
    /// Available since API-level: 12
    #[cfg(feature = "api-12")]
    #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
    pub fn OH_AudioRoutingManager_GetDevices(
        audioRoutingManager: *mut OH_AudioRoutingManager,
        deviceFlag: OH_AudioDevice_Flag,
        audioDeviceDescriptorArray: *mut *mut OH_AudioDeviceDescriptorArray,
    ) -> OH_AudioCommon_Result;
    /// Get available devices by device usage.
    ///
    /// # Arguments
    ///
    /// * `audioRoutingManager` - the [`OH_AudioRoutingManager`] handle returned
    /// by [`OH_AudioManager_GetAudioRoutingManager`].
    ///
    /// * `deviceUsage` - the [`OH_AudioDevice_Usage`].
    ///
    /// * `audioDeviceDescriptorArray` - the [`OH_AudioDeviceDescriptorArray`]
    /// pointer variable which will be set the audio device descriptors value
    /// Do not release the audioDeviceDescriptorArray pointer separately
    /// instead call [`OH_AudioRoutingManager_ReleaseDevices`] to release the DeviceDescriptor array
    /// when it is no use anymore.
    ///
    /// # Returns
    ///
    /// * Function result code:
    /// [`AUDIOCOMMON_RESULT_SUCCESS`] If the execution is successful.
    /// [`AUDIOCOMMON_RESULT_ERROR_INVALID_PARAM`]:
    /// 1.The param of audioRoutingManager is nullptr;
    /// 2.The param of deviceUsage is invalid;
    /// 3.The param of audioDeviceDescriptorArray is nullptr.
    /// [`AUDIOCOMMON_RESULT_ERROR_NO_MEMORY`] No memory error.
    ///
    /// Available since API-level: 12
    #[cfg(feature = "api-12")]
    #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
    pub fn OH_AudioRoutingManager_GetAvailableDevices(
        audioRoutingManager: *mut OH_AudioRoutingManager,
        deviceUsage: OH_AudioDevice_Usage,
        audioDeviceDescriptorArray: *mut *mut OH_AudioDeviceDescriptorArray,
    ) -> OH_AudioCommon_Result;
    /// Get preferred ouput devices by audio usage.
    ///
    /// # Arguments
    ///
    /// * `audioRoutingManager` - the [`OH_AudioRoutingManager`] handle returned
    /// by [`OH_AudioManager_GetAudioRoutingManager`].
    ///
    /// * `streamUsage` - the [`OH_AudioStream_Usage`].
    ///
    /// * `audioDeviceDescriptorArray` - the [`OH_AudioDeviceDescriptorArray`]
    /// pointer variable which will be set the audio device descriptors value
    /// Do not release the audioDeviceDescriptorArray pointer separately
    /// instead call [`OH_AudioRoutingManager_ReleaseDevices`] to release the DeviceDescriptor array
    /// when it is no use anymore.
    ///
    /// # Returns
    ///
    /// * Function result code:
    /// [`AUDIOCOMMON_RESULT_SUCCESS`] If the execution is successful.
    /// [`AUDIOCOMMON_RESULT_ERROR_INVALID_PARAM`]:
    /// 1.The param of audioRoutingManager is nullptr;
    /// 2.The param of streamUsage is invalid;
    /// 3.The param of audioDeviceDescriptorArray is nullptr.
    /// [`AUDIOCOMMON_RESULT_ERROR_NO_MEMORY`] No memory error.
    ///
    /// Available since API-level: 12
    #[cfg(feature = "api-12")]
    #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
    pub fn OH_AudioRoutingManager_GetPreferredOutputDevice(
        audioRoutingManager: *mut OH_AudioRoutingManager,
        streamUsage: OH_AudioStream_Usage,
        audioDeviceDescriptorArray: *mut *mut OH_AudioDeviceDescriptorArray,
    ) -> OH_AudioCommon_Result;
    /// Get preferred input devices by audio source type.
    /// # Arguments
    ///
    /// * `audioRoutingManager` - the [`OH_AudioRoutingManager`] handle returned
    /// by [`OH_AudioManager_GetAudioRoutingManager`].
    ///
    /// * `sourceType` - the [`OH_AudioStream_SourceType`].
    ///
    /// * `audioDeviceDescriptorArray` - the [`OH_AudioDeviceDescriptorArray`]
    /// pointer variable which will be set the audio device descriptors value
    /// Do not release the audioDeviceDescriptorArray pointer separately
    /// instead call [`OH_AudioRoutingManager_ReleaseDevices`] to release the DeviceDescriptor array
    /// when it is no use anymore.
    ///
    /// # Returns
    ///
    /// * Function result code:
    /// [`AUDIOCOMMON_RESULT_SUCCESS`] If the execution is successful.
    /// [`AUDIOCOMMON_RESULT_ERROR_INVALID_PARAM`]:
    /// 1.The param of audioRoutingManager is nullptr;
    /// 2.The param of sourceType is invalid;
    /// 3.The param of audioDeviceDescriptorArray is nullptr.
    /// [`AUDIOCOMMON_RESULT_ERROR_NO_MEMORY`] No memory error.
    ///
    /// Available since API-level: 12
    #[cfg(feature = "api-12")]
    #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
    pub fn OH_AudioRoutingManager_GetPreferredInputDevice(
        audioRoutingManager: *mut OH_AudioRoutingManager,
        sourceType: OH_AudioStream_SourceType,
        audioDeviceDescriptorArray: *mut *mut OH_AudioDeviceDescriptorArray,
    ) -> OH_AudioCommon_Result;
    /// Register the device change callback of the audio routing manager.
    ///
    /// # Arguments
    ///
    /// * `audioRoutingManager` - the [`OH_AudioRoutingManager`]
    /// handle returned by [`OH_AudioManager_GetAudioRoutingManager`].
    ///
    /// * `deviceFlag` - the [`OH_AudioDevice_DeviceFlag`] which is used to register callback.
    ///
    /// * `callback` - the [`OH_AudioRoutingManager_OnDeviceChangedCallback`]
    /// Callback function which will be called when devices changed.
    ///
    /// # Returns
    ///
    /// * Function result code:
    /// [`AUDIOCOMMON_RESULT_SUCCESS`] If the execution is successful.
    /// [`AUDIOCOMMON_RESULT_ERROR_INVALID_PARAM`]:
    /// 1.The param of audioRoutingManager is nullptr;
    /// 2.The param of deviceFlag invalid;
    /// 3.The param of callback is nullptr.
    ///
    /// Available since API-level: 12
    #[cfg(feature = "api-12")]
    #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
    pub fn OH_AudioRoutingManager_RegisterDeviceChangeCallback(
        audioRoutingManager: *mut OH_AudioRoutingManager,
        deviceFlag: OH_AudioDevice_Flag,
        callback: OH_AudioRoutingManager_OnDeviceChangedCallback,
    ) -> OH_AudioCommon_Result;
    /// Unregister the device change callback of the audio routing manager.
    ///
    /// # Arguments
    ///
    /// * `audioRoutingManager` - the [`OH_AudioRoutingManager`]
    /// handle returned by [`OH_AudioManager_GetAudioRoutingManager`].
    ///
    /// * `callback` - the [`OH_AudioRoutingManager_OnDeviceChangedCallback`]
    /// Callback function which will be called when devices changed.
    ///
    /// # Returns
    ///
    /// * Function result code:
    /// [`AUDIOCOMMON_RESULT_SUCCESS`] If the execution is successful.
    /// [`AUDIOCOMMON_RESULT_ERROR_INVALID_PARAM`]:
    /// 1.The param of audioRoutingManager is nullptr;
    /// 2.The param of callback is nullptr.
    ///
    /// Available since API-level: 12
    #[cfg(feature = "api-12")]
    #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
    pub fn OH_AudioRoutingManager_UnregisterDeviceChangeCallback(
        audioRoutingManager: *mut OH_AudioRoutingManager,
        callback: OH_AudioRoutingManager_OnDeviceChangedCallback,
    ) -> OH_AudioCommon_Result;
    /// Release the audio device descriptor array object.
    ///
    /// # Arguments
    ///
    /// * `audioRoutingManager` - the [`OH_AudioRoutingManager`]
    /// handle returned by [`OH_AudioManager_GetAudioRoutingManager`].
    ///
    /// * `audioDeviceDescriptorArray` - Audio device descriptors should be released.
    /// and get from [`OH_AudioRoutingManager_GetDevices`]
    ///
    /// # Returns
    ///
    /// * Function result code:
    /// [`AUDIOCOMMON_RESULT_SUCCESS`] If the execution is successful.
    /// [`AUDIOCOMMON_RESULT_ERROR_INVALID_PARAM`]:
    /// 1.The param of audioRoutingManager is nullptr;
    /// 2.The param of audioDeviceDescriptorArray is nullptr.
    ///
    /// Available since API-level: 12
    #[cfg(feature = "api-12")]
    #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
    pub fn OH_AudioRoutingManager_ReleaseDevices(
        audioRoutingManager: *mut OH_AudioRoutingManager,
        audioDeviceDescriptorArray: *mut OH_AudioDeviceDescriptorArray,
    ) -> OH_AudioCommon_Result;
    /// Query whether microphone block detection is supported on current device.
    ///
    /// # Arguments
    ///
    /// * `audioRoutingManager` - the [`OH_AudioRoutingManager`] handle returned by
    /// [`OH_AudioManager_GetAudioRoutingManager`].
    ///
    /// * `supported` - query result.
    ///
    /// # Returns
    ///
    /// * Function result code:
    /// [`AUDIOCOMMON_RESULT_SUCCESS`] If the execution is successful.
    /// [`AUDIOCOMMON_RESULT_ERROR_INVALID_PARAM`]:
    /// 1.The param of audioRoutingManager is nullptr;
    /// 2.The param of supported is nullptr.
    ///
    /// Available since API-level: 13
    #[cfg(feature = "api-13")]
    #[cfg_attr(docsrs, doc(cfg(feature = "api-13")))]
    pub fn OH_AudioRoutingManager_IsMicBlockDetectionSupported(
        audioRoutingManager: *mut OH_AudioRoutingManager,
        supported: *mut bool,
    ) -> OH_AudioCommon_Result;
    /// Set the microphone block status callback. Before using this function, users should query whether block
    /// detection is supported on current device. The caller will receive the callback only when it is recording
    /// and the used microphones' block status have changed. Currently, block detecting is only support for microphones
    /// located on the local device.
    ///
    /// # Arguments
    ///
    /// * `audioRoutingManager` - The [`OH_AudioRoutingManager`] handle returned by
    /// [`OH_AudioManager_GetAudioRoutingManager`].
    ///
    /// * `callback` - The function pointer will point to the callback function that is used to receive the block status.
    ///
    /// * `userData` - User data which is passed by user.
    ///
    /// # Returns
    ///
    /// * Function result code:
    /// [`AUDIOCOMMON_RESULT_SUCCESS`] If the execution is successful.
    /// [`AUDIOCOMMON_RESULT_ERROR_INVALID_PARAM`]:
    /// 1.The param of audioRoutingManager is nullptr;
    /// 2.The param of callback is nullptr.
    ///
    /// Available since API-level: 13
    #[cfg(feature = "api-13")]
    #[cfg_attr(docsrs, doc(cfg(feature = "api-13")))]
    pub fn OH_AudioRoutingManager_SetMicBlockStatusCallback(
        audioRoutingManager: *mut OH_AudioRoutingManager,
        callback: OH_AudioRoutingManager_OnDeviceBlockStatusCallback,
        userData: *mut ::core::ffi::c_void,
    ) -> OH_AudioCommon_Result;
}