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;

/// Declare the audio resource manager.
/// Audio resource manager provides many functions for developer to manage system resources to avoid
/// underrun or overrun in audio playback and recording.
///
///
/// Available since API-level: 20
#[cfg(feature = "api-20")]
#[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
#[repr(C)]
pub struct OH_AudioResourceManager {
    _unused: [u8; 0],
}
/// Declare the audio workgroup.
/// The handle of audio workgroup is used for workgroup related functions.
/// The system will manage cpu resources on a workgroup basis instead of thread.
/// For parallel task threads, you can add them into one workgroup, and for
/// asynchronous task threads, use one workgroup for each thread.
/// There is an upper limit to the total number of workgroups for each process,
/// so application should release the workgroup which is no longer in use.
///
///
/// Available since API-level: 20
#[cfg(feature = "api-20")]
#[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
#[repr(C)]
pub struct OH_AudioWorkgroup {
    _unused: [u8; 0],
}
extern "C" {
    /// Fetch the audio resource manager handle, which is a singleton.
    ///
    /// # Arguments
    ///
    /// * `resourceManager` - output parameter to get [`#OH_AudioResourceManager`].
    ///
    /// # Returns
    ///
    /// * [`#AUDIOCOMMON_RESULT_SUCCESS`] if execution succeeds
    /// [`#AUDIOCOMMON_RESULT_ERROR_INVALID_PARAM`] if input param is nullptr
    ///
    /// Available since API-level: 20
    #[cfg(feature = "api-20")]
    #[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
    pub fn OH_AudioManager_GetAudioResourceManager(
        resourceManager: *mut *mut OH_AudioResourceManager,
    ) -> OH_AudioCommon_Result;
    /// Create a workgroup for audio data processing threads in application.
    /// System manages cpu resources by workgroup configuration.
    ///
    /// # Arguments
    ///
    /// * `resourceManager` - [`OH_AudioResourceManager`] handle
    /// provided by [`OH_AudioManager_GetAudioRoutingManager`].
    ///
    /// * `name` - workgroup name
    ///
    /// * `group` - [`OH_AudioWorkgroup`] handle for managing audio data processing threads.
    ///
    /// # Returns
    ///
    /// * [`#AUDIOCOMMON_RESULT_SUCCESS`] if execution succeeds
    /// [`#AUDIOCOMMON_RESULT_ERROR_INVALID_PARAM`] if input param is nullptr
    /// [`#AUDIOCOMMON_RESULT_ERROR_NO_MEMORY`] out of workgroup resources
    /// [`#AUDIOCOMMON_RESULT_ERROR_SYSTEM`] system process error occurs
    ///
    /// Available since API-level: 20
    #[cfg(feature = "api-20")]
    #[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
    pub fn OH_AudioResourceManager_CreateWorkgroup(
        resourceManager: *mut OH_AudioResourceManager,
        name: *const ::core::ffi::c_char,
        group: *mut *mut OH_AudioWorkgroup,
    ) -> OH_AudioCommon_Result;
    /// Release the workgroup created before.
    ///
    /// # Arguments
    ///
    /// * `resourceManager` - [`OH_AudioResourceManager`] handle
    /// provided by [`OH_AudioManager_GetAudioRoutingManager`].
    ///
    /// * `group` - [`OH_AudioWorkgroup`] handle provided by [`OH_AudioResourceManager_CreateWorkgroup`].
    ///
    /// # Returns
    ///
    /// * [`#AUDIOCOMMON_RESULT_SUCCESS`] if execution succeeds
    /// [`#AUDIOCOMMON_RESULT_ERROR_INVALID_PARAM`] if input param is nullptr
    /// [`#AUDIOCOMMON_RESULT_ERROR_SYSTEM`] system process error occurs
    ///
    /// Available since API-level: 20
    #[cfg(feature = "api-20")]
    #[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
    pub fn OH_AudioResourceManager_ReleaseWorkgroup(
        resourceManager: *mut OH_AudioResourceManager,
        group: *mut OH_AudioWorkgroup,
    ) -> OH_AudioCommon_Result;
    /// Add current thread into a specified audio workgroup as audio data processing thread.
    ///
    /// # Arguments
    ///
    /// * `group` - [`OH_AudioWorkgroup`] handle provided by [`OH_AudioResourceManager_CreateWorkgroup`].
    ///
    /// * `tokenId` - a token id that represent the thread added.
    ///
    /// # Returns
    ///
    /// * [`#AUDIOCOMMON_RESULT_SUCCESS`] if execution succeeds
    /// [`#AUDIOCOMMON_RESULT_ERROR_INVALID_PARAM`] if input param is nullptr
    /// [`#AUDIOCOMMON_RESULT_ERROR_NO_MEMORY`] out of resources for the new thread
    /// [`#AUDIOCOMMON_RESULT_ERROR_SYSTEM`] system process error occurs
    ///
    /// Available since API-level: 20
    #[cfg(feature = "api-20")]
    #[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
    pub fn OH_AudioWorkgroup_AddCurrentThread(
        group: *mut OH_AudioWorkgroup,
        tokenId: *mut i32,
    ) -> OH_AudioCommon_Result;
    /// Remove the thread from a specified audio workgroup.
    ///
    /// # Arguments
    ///
    /// * `group` - [`OH_AudioWorkgroup`] handle provided by [`OH_AudioResourceManager_CreateWorkgroup`].
    ///
    /// * `tokenId` - id for thread returned by {link OH_AudioWorkgroup_AddCurrentThread}
    ///
    /// # Returns
    ///
    /// * [`#AUDIOCOMMON_RESULT_SUCCESS`] if execution succeeds
    /// [`#AUDIOCOMMON_RESULT_ERROR_INVALID_PARAM`] if input param is nullptr or token id is invalid
    /// [`#AUDIOCOMMON_RESULT_ERROR_SYSTEM`] system process error occurs
    ///
    /// Available since API-level: 20
    #[cfg(feature = "api-20")]
    #[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
    pub fn OH_AudioWorkgroup_RemoveThread(
        group: *mut OH_AudioWorkgroup,
        tokenId: i32,
    ) -> OH_AudioCommon_Result;
    /// Notify system the audio workgroup start working. Call this function before processing the audio frame.
    ///
    /// # Arguments
    ///
    /// * `group` - [`OH_AudioWorkgroup`] handle provided by [`OH_AudioResourceManager_CreateWorkgroup`].
    ///
    /// * `startTime` - the time when audio thread start working, using system time. The unit of time is milliseconds.
    ///
    /// * `deadlineTime` - the time before which audio work should be finished, otherwise underrun may happens.
    /// The unit of time is milliseconds.
    ///
    /// # Returns
    ///
    /// * [`#AUDIOCOMMON_RESULT_SUCCESS`] if execution succeeds
    /// [`#AUDIOCOMMON_RESULT_ERROR_INVALID_PARAM`] if input param is nullptr, or time is invalid
    /// [`#AUDIOCOMMON_RESULT_ERROR_SYSTEM`] system process error occurs
    ///
    /// Available since API-level: 20
    #[cfg(feature = "api-20")]
    #[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
    pub fn OH_AudioWorkgroup_Start(
        group: *mut OH_AudioWorkgroup,
        startTime: u64,
        deadlineTime: u64,
    ) -> OH_AudioCommon_Result;
    /// Notify system the audio workgroup stop working. Call this function after the audio frame processing
    /// is completed.
    ///
    /// # Arguments
    ///
    /// * `group` - [`OH_AudioWorkgroup`] handle provided by [`OH_AudioResourceManager_CreateWorkgroup`].
    ///
    /// # Returns
    ///
    /// * [`#AUDIOCOMMON_RESULT_SUCCESS`] if execution succeeds
    /// [`#AUDIOCOMMON_RESULT_ERROR_INVALID_PARAM`] if input param is nullptr
    /// [`#AUDIOCOMMON_RESULT_ERROR_SYSTEM`] system process error occurs
    ///
    /// Available since API-level: 20
    #[cfg(feature = "api-20")]
    #[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
    pub fn OH_AudioWorkgroup_Stop(group: *mut OH_AudioWorkgroup) -> OH_AudioCommon_Result;
}