1 /* 2 * Copyright (c) 2020-2021 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 Audio 18 * @{ 19 * 20 * @brief Defines audio-related APIs, including custom data types and functions for loading drivers, 21 * accessing a driver adapter, and rendering and capturing audios. 22 * 23 * @since 1.0 24 * @version 1.0 25 */ 26 27 /** 28 * @file audio_manager.h 29 * 30 * @brief Declares APIs for audio adapter management and loading. 31 * 32 * @since 1.0 33 * @version 1.0 34 */ 35 36 #ifndef AUDIO_MANAGER_H 37 #define AUDIO_MANAGER_H 38 39 #include "audio_types.h" 40 #include "audio_adapter.h" 41 namespace OHOS::HDI::Audio_Bluetooth { 42 /** 43 * @brief Manages audio adapters through a specific adapter driver program loaded based on the given audio 44 * adapter descriptor. 45 * 46 * @see AudioAdapter 47 * @since 1.0 48 * @version 1.0 49 */ 50 struct AudioManager { 51 /** 52 * @brief Obtains the list of all adapters supported by an audio driver. 53 * 54 * @param manager Indicates the pointer to the audio adapter manager to operate. 55 * @param descs Indicates the double pointer to the audio adapter list. 56 * @param size Indicates the pointer to the length of the list. 57 * @return Returns <b>0</b> if the list is obtained successfully; returns a negative value otherwise. 58 * @see LoadAdapter 59 */ 60 int32_t (*GetAllAdapters)(struct AudioManager *manager, struct AudioAdapterDescriptor **descs, int32_t *size); 61 62 /** 63 * @brief Loads the driver for an audio adapter. 64 * 65 * For example, to load a USB driver, you may need to load a dynamic-link library (*.so) in specific implementation. 66 * 67 * @param manager Indicates the pointer to the audio adapter manager to operate. 68 * @param desc Indicates the pointer to the descriptor of the audio adapter. 69 * @param adapter Indicates the double pointer to the audio adapter. 70 * @return Returns <b>0</b> if the driver is loaded successfully; returns a negative value otherwise. 71 * @see GetAllAdapters 72 * @see UnloadAdapter 73 */ 74 int32_t (*LoadAdapter)(struct AudioManager *manager, const struct AudioAdapterDescriptor *desc, 75 struct AudioAdapter **adapter); 76 77 /** 78 * @brief Unloads the driver of an audio adapter. 79 * 80 * @param manager Indicates the pointer to the audio adapter manager to operate. 81 * @param adapter Indicates the pointer to the audio adapter whose driver will be unloaded. 82 * @see LoadAdapter 83 */ 84 void (*UnloadAdapter)(struct AudioManager *manager, struct AudioAdapter *adapter); 85 }; 86 87 /** 88 * @brief Obtains the operation function list of the {@link AudioManager} class. 89 * 90 * @return Returns the pointer to the <b>AudioManager</b> object if the list is obtained; returns <b>NULL</b> otherwise. 91 */ 92 struct AudioManager *GetAudioManagerFuncs(void); 93 } 94 #endif /* AUDIO_MANAGER_H */ 95 /** @} */ 96