Skip to main content

ohaudio_sys/audio_resource_manager/
audio_resource_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
8/// Declare the audio resource manager.
9/// Audio resource manager provides many functions for developer to manage system resources to avoid
10/// underrun or overrun in audio playback and recording.
11///
12///
13/// Available since API-level: 20
14#[cfg(feature = "api-20")]
15#[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
16#[repr(C)]
17pub struct OH_AudioResourceManager {
18    _unused: [u8; 0],
19}
20/// Declare the audio workgroup.
21/// The handle of audio workgroup is used for workgroup related functions.
22/// The system will manage cpu resources on a workgroup basis instead of thread.
23/// For parallel task threads, you can add them into one workgroup, and for
24/// asynchronous task threads, use one workgroup for each thread.
25/// There is an upper limit to the total number of workgroups for each process,
26/// so application should release the workgroup which is no longer in use.
27///
28///
29/// Available since API-level: 20
30#[cfg(feature = "api-20")]
31#[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
32#[repr(C)]
33pub struct OH_AudioWorkgroup {
34    _unused: [u8; 0],
35}
36extern "C" {
37    /// Fetch the audio resource manager handle, which is a singleton.
38    ///
39    /// # Arguments
40    ///
41    /// * `resourceManager` - output parameter to get [`#OH_AudioResourceManager`].
42    ///
43    /// # Returns
44    ///
45    /// * [`#AUDIOCOMMON_RESULT_SUCCESS`] if execution succeeds
46    /// [`#AUDIOCOMMON_RESULT_ERROR_INVALID_PARAM`] if input param is nullptr
47    ///
48    /// Available since API-level: 20
49    #[cfg(feature = "api-20")]
50    #[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
51    pub fn OH_AudioManager_GetAudioResourceManager(
52        resourceManager: *mut *mut OH_AudioResourceManager,
53    ) -> OH_AudioCommon_Result;
54    /// Create a workgroup for audio data processing threads in application.
55    /// System manages cpu resources by workgroup configuration.
56    ///
57    /// # Arguments
58    ///
59    /// * `resourceManager` - [`OH_AudioResourceManager`] handle
60    /// provided by [`OH_AudioManager_GetAudioRoutingManager`].
61    ///
62    /// * `name` - workgroup name
63    ///
64    /// * `group` - [`OH_AudioWorkgroup`] handle for managing audio data processing threads.
65    ///
66    /// # Returns
67    ///
68    /// * [`#AUDIOCOMMON_RESULT_SUCCESS`] if execution succeeds
69    /// [`#AUDIOCOMMON_RESULT_ERROR_INVALID_PARAM`] if input param is nullptr
70    /// [`#AUDIOCOMMON_RESULT_ERROR_NO_MEMORY`] out of workgroup resources
71    /// [`#AUDIOCOMMON_RESULT_ERROR_SYSTEM`] system process error occurs
72    ///
73    /// Available since API-level: 20
74    #[cfg(feature = "api-20")]
75    #[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
76    pub fn OH_AudioResourceManager_CreateWorkgroup(
77        resourceManager: *mut OH_AudioResourceManager,
78        name: *const ::core::ffi::c_char,
79        group: *mut *mut OH_AudioWorkgroup,
80    ) -> OH_AudioCommon_Result;
81    /// Release the workgroup created before.
82    ///
83    /// # Arguments
84    ///
85    /// * `resourceManager` - [`OH_AudioResourceManager`] handle
86    /// provided by [`OH_AudioManager_GetAudioRoutingManager`].
87    ///
88    /// * `group` - [`OH_AudioWorkgroup`] handle provided by [`OH_AudioResourceManager_CreateWorkgroup`].
89    ///
90    /// # Returns
91    ///
92    /// * [`#AUDIOCOMMON_RESULT_SUCCESS`] if execution succeeds
93    /// [`#AUDIOCOMMON_RESULT_ERROR_INVALID_PARAM`] if input param is nullptr
94    /// [`#AUDIOCOMMON_RESULT_ERROR_SYSTEM`] system process error occurs
95    ///
96    /// Available since API-level: 20
97    #[cfg(feature = "api-20")]
98    #[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
99    pub fn OH_AudioResourceManager_ReleaseWorkgroup(
100        resourceManager: *mut OH_AudioResourceManager,
101        group: *mut OH_AudioWorkgroup,
102    ) -> OH_AudioCommon_Result;
103    /// Add current thread into a specified audio workgroup as audio data processing thread.
104    ///
105    /// # Arguments
106    ///
107    /// * `group` - [`OH_AudioWorkgroup`] handle provided by [`OH_AudioResourceManager_CreateWorkgroup`].
108    ///
109    /// * `tokenId` - a token id that represent the thread added.
110    ///
111    /// # Returns
112    ///
113    /// * [`#AUDIOCOMMON_RESULT_SUCCESS`] if execution succeeds
114    /// [`#AUDIOCOMMON_RESULT_ERROR_INVALID_PARAM`] if input param is nullptr
115    /// [`#AUDIOCOMMON_RESULT_ERROR_NO_MEMORY`] out of resources for the new thread
116    /// [`#AUDIOCOMMON_RESULT_ERROR_SYSTEM`] system process error occurs
117    ///
118    /// Available since API-level: 20
119    #[cfg(feature = "api-20")]
120    #[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
121    pub fn OH_AudioWorkgroup_AddCurrentThread(
122        group: *mut OH_AudioWorkgroup,
123        tokenId: *mut i32,
124    ) -> OH_AudioCommon_Result;
125    /// Remove the thread from a specified audio workgroup.
126    ///
127    /// # Arguments
128    ///
129    /// * `group` - [`OH_AudioWorkgroup`] handle provided by [`OH_AudioResourceManager_CreateWorkgroup`].
130    ///
131    /// * `tokenId` - id for thread returned by {link OH_AudioWorkgroup_AddCurrentThread}
132    ///
133    /// # Returns
134    ///
135    /// * [`#AUDIOCOMMON_RESULT_SUCCESS`] if execution succeeds
136    /// [`#AUDIOCOMMON_RESULT_ERROR_INVALID_PARAM`] if input param is nullptr or token id is invalid
137    /// [`#AUDIOCOMMON_RESULT_ERROR_SYSTEM`] system process error occurs
138    ///
139    /// Available since API-level: 20
140    #[cfg(feature = "api-20")]
141    #[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
142    pub fn OH_AudioWorkgroup_RemoveThread(
143        group: *mut OH_AudioWorkgroup,
144        tokenId: i32,
145    ) -> OH_AudioCommon_Result;
146    /// Notify system the audio workgroup start working. Call this function before processing the audio frame.
147    ///
148    /// # Arguments
149    ///
150    /// * `group` - [`OH_AudioWorkgroup`] handle provided by [`OH_AudioResourceManager_CreateWorkgroup`].
151    ///
152    /// * `startTime` - the time when audio thread start working, using system time. The unit of time is milliseconds.
153    ///
154    /// * `deadlineTime` - the time before which audio work should be finished, otherwise underrun may happens.
155    /// The unit of time is milliseconds.
156    ///
157    /// # Returns
158    ///
159    /// * [`#AUDIOCOMMON_RESULT_SUCCESS`] if execution succeeds
160    /// [`#AUDIOCOMMON_RESULT_ERROR_INVALID_PARAM`] if input param is nullptr, or time is invalid
161    /// [`#AUDIOCOMMON_RESULT_ERROR_SYSTEM`] system process error occurs
162    ///
163    /// Available since API-level: 20
164    #[cfg(feature = "api-20")]
165    #[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
166    pub fn OH_AudioWorkgroup_Start(
167        group: *mut OH_AudioWorkgroup,
168        startTime: u64,
169        deadlineTime: u64,
170    ) -> OH_AudioCommon_Result;
171    /// Notify system the audio workgroup stop working. Call this function after the audio frame processing
172    /// is completed.
173    ///
174    /// # Arguments
175    ///
176    /// * `group` - [`OH_AudioWorkgroup`] handle provided by [`OH_AudioResourceManager_CreateWorkgroup`].
177    ///
178    /// # Returns
179    ///
180    /// * [`#AUDIOCOMMON_RESULT_SUCCESS`] if execution succeeds
181    /// [`#AUDIOCOMMON_RESULT_ERROR_INVALID_PARAM`] if input param is nullptr
182    /// [`#AUDIOCOMMON_RESULT_ERROR_SYSTEM`] system process error occurs
183    ///
184    /// Available since API-level: 20
185    #[cfg(feature = "api-20")]
186    #[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
187    pub fn OH_AudioWorkgroup_Stop(group: *mut OH_AudioWorkgroup) -> OH_AudioCommon_Result;
188}