• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2024 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 /**
17  * @addtogroup OHAudio
18  * @{
19  *
20  * @brief Provide the definition of the C interface for the audio module.
21  *
22  * @syscap SystemCapability.Multimedia.Audio.Core
23  *
24  * @since 12
25  * @version 1.0
26  */
27 
28 /**
29  * @file native_audio_manager.h
30  *
31  * @brief Declare audio manager related interfaces.
32  *
33  * @library libohaudio.so
34  * @syscap SystemCapability.Multimedia.Audio.Core
35  * @kit AudioKit
36  * @since 12
37  * @version 1.0
38  */
39 #ifndef NATIVE_AUDIO_MANAGER_H
40 #define NATIVE_AUDIO_MANAGER_H
41 
42 #include "native_audio_common.h"
43 #ifdef __cplusplus
44 extern "C" {
45 #endif
46 
47 /**
48  * @brief Declare the audio manager.
49  * The handle of audio manager is used for audio management related functions.
50  *
51  * @since 12
52  */
53 typedef struct OH_AudioManager OH_AudioManager;
54 
55 /**
56  * @brief Prototype for the audio scene change function that is passed to
57  *     {@link OH_AudioManager_RegisterAudioSceneChangeCallback}.
58  *
59  * @param userData userdata which is passed by register.
60  * @param scene the latest audio scene.
61  * @since 20
62  */
63 typedef void (*OH_AudioManager_OnAudioSceneChangeCallback) (
64     void *userData,
65     OH_AudioScene scene
66 );
67 
68 /**
69  * @brief Get audio manager handle.
70  *
71  * @param audioManager the {@link OH_AudioManager} handle received from this function.
72  * @return Function result code:
73  *         {@link AUDIOCOMMON_RESULT_SUCCESS} If the execution is successful.
74  *         {@link AUDIOCOMMON_RESULT_ERROR_INVALID_PARAM}:
75  *                                                        1.The param of audioManager is nullptr;
76  * @since 12
77  */
78 OH_AudioCommon_Result OH_GetAudioManager(OH_AudioManager **audioManager);
79 
80 /**
81  * @brief Get audio scene.
82  * @param audioManager the {@link OH_AudioManager} handle received from {@link OH_GetAudioManager}.
83  * @param scene the {@link OH_AudioScene} pointer to receive the result.
84  * @return Function result code:
85  *         {@link AUDIOCOMMON_RESULT_SUCCESS} If the execution is successful.
86  *         {@link AUDIOCOMMON_RESULT_ERROR_INVALID_PARAM}:
87  *                                                        1.The param of audioManager is nullptr;
88  *                                                        2.The param of scene is nullptr.
89  * @since 12
90  */
91 OH_AudioCommon_Result OH_GetAudioScene(OH_AudioManager* manager, OH_AudioScene *scene);
92 
93 /**
94  * @brief Register callback to receive audio scene changed events.
95  *
96  * @param manager {@link OH_AudioManager} handle received from {@link OH_GetAudioManager}.
97  * @param callback callback function which will be called when audio scene changed.
98  * @param userData pointer to a data structure that will be passed to the callback functions.
99  * @return
100  *     {@link AUDIOCOMMON_RESULT_SUCCESS} if the execution is successful
101  *     {@link AUDIOCOMMON_RESULT_ERROR_INVALID_PARAM}
102  *                                                   1.param of manager is nullptr
103  *                                                   2.param of callback is nullptr
104  *     {@link #AUDIOCOMMON_RESULT_ERROR_SYSTEM} system process error occurs
105  * @since 20
106  */
107 OH_AudioCommon_Result OH_AudioManager_RegisterAudioSceneChangeCallback(OH_AudioManager *manager,
108     OH_AudioManager_OnAudioSceneChangeCallback callback, void *userData);
109 
110 /**
111  * @brief Unregister audio scene change callback.
112  *
113  * @param manager {@link OH_AudioManager} handle received from {@link OH_GetAudioManager}.
114  * @param callback callback function which registered in {@link OH_AudioManager_RegisterAudioSceneChangeCallback}.
115  * @return
116  *     {@link AUDIOCOMMON_RESULT_SUCCESS} if the execution is successful
117  *     {@link AUDIOCOMMON_RESULT_ERROR_INVALID_PARAM}
118  *                                                   1.param of manager is nullptr
119  *                                                   2.param of callback is nullptr
120  *     {@link #AUDIOCOMMON_RESULT_ERROR_SYSTEM} system process error occurs
121  * @since 20
122  */
123 OH_AudioCommon_Result OH_AudioManager_UnregisterAudioSceneChangeCallback(OH_AudioManager *manager,
124     OH_AudioManager_OnAudioSceneChangeCallback callback);
125 
126 #ifdef __cplusplus
127 }
128 #endif
129 /** @} */
130 #endif // NATIVE_AUDIO_ROUTING_MANAGER_H