1094332d3Sopenharmony_ci/* 2094332d3Sopenharmony_ci * Copyright (c) 2020-2021 Huawei Device Co., Ltd. 3094332d3Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 4094332d3Sopenharmony_ci * you may not use this file except in compliance with the License. 5094332d3Sopenharmony_ci * You may obtain a copy of the License at 6094332d3Sopenharmony_ci * 7094332d3Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 8094332d3Sopenharmony_ci * 9094332d3Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 10094332d3Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 11094332d3Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12094332d3Sopenharmony_ci * See the License for the specific language governing permissions and 13094332d3Sopenharmony_ci * limitations under the License. 14094332d3Sopenharmony_ci */ 15094332d3Sopenharmony_ci 16094332d3Sopenharmony_ci/** 17094332d3Sopenharmony_ci * @addtogroup Audio 18094332d3Sopenharmony_ci * @{ 19094332d3Sopenharmony_ci * 20094332d3Sopenharmony_ci * @brief Defines audio-related APIs, including custom data types and functions for loading drivers, 21094332d3Sopenharmony_ci * accessing a driver adapter, and rendering and capturing audios. 22094332d3Sopenharmony_ci * 23094332d3Sopenharmony_ci * @since 1.0 24094332d3Sopenharmony_ci * @version 1.0 25094332d3Sopenharmony_ci */ 26094332d3Sopenharmony_ci 27094332d3Sopenharmony_ci/** 28094332d3Sopenharmony_ci * @file audio_manager.h 29094332d3Sopenharmony_ci * 30094332d3Sopenharmony_ci * @brief Declares APIs for audio adapter management and loading. 31094332d3Sopenharmony_ci * 32094332d3Sopenharmony_ci * @since 1.0 33094332d3Sopenharmony_ci * @version 1.0 34094332d3Sopenharmony_ci */ 35094332d3Sopenharmony_ci 36094332d3Sopenharmony_ci#ifndef AUDIO_MANAGER_H 37094332d3Sopenharmony_ci#define AUDIO_MANAGER_H 38094332d3Sopenharmony_ci 39094332d3Sopenharmony_ci#include "audio_types.h" 40094332d3Sopenharmony_ci#include "audio_adapter.h" 41094332d3Sopenharmony_cinamespace OHOS::HDI::Audio_Bluetooth { 42094332d3Sopenharmony_ci/** 43094332d3Sopenharmony_ci * @brief Manages audio adapters through a specific adapter driver program loaded based on the given audio 44094332d3Sopenharmony_ci * adapter descriptor. 45094332d3Sopenharmony_ci * 46094332d3Sopenharmony_ci * @see AudioAdapter 47094332d3Sopenharmony_ci * @since 1.0 48094332d3Sopenharmony_ci * @version 1.0 49094332d3Sopenharmony_ci */ 50094332d3Sopenharmony_cistruct AudioManager { 51094332d3Sopenharmony_ci /** 52094332d3Sopenharmony_ci * @brief Obtains the list of all adapters supported by an audio driver. 53094332d3Sopenharmony_ci * 54094332d3Sopenharmony_ci * @param manager Indicates the pointer to the audio adapter manager to operate. 55094332d3Sopenharmony_ci * @param descs Indicates the double pointer to the audio adapter list. 56094332d3Sopenharmony_ci * @param size Indicates the pointer to the length of the list. 57094332d3Sopenharmony_ci * @return Returns <b>0</b> if the list is obtained successfully; returns a negative value otherwise. 58094332d3Sopenharmony_ci * @see LoadAdapter 59094332d3Sopenharmony_ci */ 60094332d3Sopenharmony_ci int32_t (*GetAllAdapters)(struct AudioManager *manager, struct AudioAdapterDescriptor **descs, int32_t *size); 61094332d3Sopenharmony_ci 62094332d3Sopenharmony_ci /** 63094332d3Sopenharmony_ci * @brief Loads the driver for an audio adapter. 64094332d3Sopenharmony_ci * 65094332d3Sopenharmony_ci * For example, to load a USB driver, you may need to load a dynamic-link library (*.so) in specific implementation. 66094332d3Sopenharmony_ci * 67094332d3Sopenharmony_ci * @param manager Indicates the pointer to the audio adapter manager to operate. 68094332d3Sopenharmony_ci * @param desc Indicates the pointer to the descriptor of the audio adapter. 69094332d3Sopenharmony_ci * @param adapter Indicates the double pointer to the audio adapter. 70094332d3Sopenharmony_ci * @return Returns <b>0</b> if the driver is loaded successfully; returns a negative value otherwise. 71094332d3Sopenharmony_ci * @see GetAllAdapters 72094332d3Sopenharmony_ci * @see UnloadAdapter 73094332d3Sopenharmony_ci */ 74094332d3Sopenharmony_ci int32_t (*LoadAdapter)(struct AudioManager *manager, const struct AudioAdapterDescriptor *desc, 75094332d3Sopenharmony_ci struct AudioAdapter **adapter); 76094332d3Sopenharmony_ci 77094332d3Sopenharmony_ci /** 78094332d3Sopenharmony_ci * @brief Unloads the driver of an audio adapter. 79094332d3Sopenharmony_ci * 80094332d3Sopenharmony_ci * @param manager Indicates the pointer to the audio adapter manager to operate. 81094332d3Sopenharmony_ci * @param adapter Indicates the pointer to the audio adapter whose driver will be unloaded. 82094332d3Sopenharmony_ci * @see LoadAdapter 83094332d3Sopenharmony_ci */ 84094332d3Sopenharmony_ci void (*UnloadAdapter)(struct AudioManager *manager, struct AudioAdapter *adapter); 85094332d3Sopenharmony_ci}; 86094332d3Sopenharmony_ci 87094332d3Sopenharmony_ci/** 88094332d3Sopenharmony_ci * @brief Obtains the operation function list of the {@link AudioManager} class. 89094332d3Sopenharmony_ci * 90094332d3Sopenharmony_ci * @return Returns the pointer to the <b>AudioManager</b> object if the list is obtained; returns <b>NULL</b> otherwise. 91094332d3Sopenharmony_ci */ 92094332d3Sopenharmony_cistruct AudioManager *GetAudioManagerFuncs(void); 93094332d3Sopenharmony_ci} 94094332d3Sopenharmony_ci#endif /* AUDIO_MANAGER_H */ 95094332d3Sopenharmony_ci/** @} */ 96