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 * 83 * @param manager the {@link OH_AudioManager} handle received from {@link OH_GetAudioManager}. 84 * @param scene the {@link OH_AudioScene} pointer to receive the result. 85 * @return Function result code: 86 * {@link AUDIOCOMMON_RESULT_SUCCESS} If the execution is successful. 87 * {@link AUDIOCOMMON_RESULT_ERROR_INVALID_PARAM}: 88 * 1.The param of audioManager is nullptr; 89 * 2.The param of scene is nullptr. 90 * @since 12 91 */ 92 OH_AudioCommon_Result OH_GetAudioScene(OH_AudioManager* manager, OH_AudioScene *scene); 93 94 /** 95 * @brief Register callback to receive audio scene changed events. 96 * 97 * @param manager {@link OH_AudioManager} handle received from {@link OH_GetAudioManager}. 98 * @param callback callback function which will be called when audio scene changed. 99 * @param userData pointer to a data structure that will be passed to the callback functions. 100 * @return 101 * {@link AUDIOCOMMON_RESULT_SUCCESS} if the execution is successful 102 * {@link AUDIOCOMMON_RESULT_ERROR_INVALID_PARAM} 103 * 1.param of manager is nullptr 104 * 2.param of callback is nullptr 105 * {@link #AUDIOCOMMON_RESULT_ERROR_SYSTEM} system process error occurs 106 * @since 20 107 */ 108 OH_AudioCommon_Result OH_AudioManager_RegisterAudioSceneChangeCallback(OH_AudioManager *manager, 109 OH_AudioManager_OnAudioSceneChangeCallback callback, void *userData); 110 111 /** 112 * @brief Unregister audio scene change callback. 113 * 114 * @param manager {@link OH_AudioManager} handle received from {@link OH_GetAudioManager}. 115 * @param callback callback function which registered in {@link OH_AudioManager_RegisterAudioSceneChangeCallback}. 116 * @return 117 * {@link AUDIOCOMMON_RESULT_SUCCESS} if the execution is successful 118 * {@link AUDIOCOMMON_RESULT_ERROR_INVALID_PARAM} 119 * 1.param of manager is nullptr 120 * 2.param of callback is nullptr 121 * {@link #AUDIOCOMMON_RESULT_ERROR_SYSTEM} system process error occurs 122 * @since 20 123 */ 124 OH_AudioCommon_Result OH_AudioManager_UnregisterAudioSceneChangeCallback(OH_AudioManager *manager, 125 OH_AudioManager_OnAudioSceneChangeCallback callback); 126 127 #ifdef __cplusplus 128 } 129 #endif 130 131 #endif // NATIVE_AUDIO_ROUTING_MANAGER_H 132 /** @} */