1/*
2 * Copyright (c) 2023 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 HdiAudio
18 * @
19 *
20 * @brief Provides unified APIs for audio services to access audio drivers.
21 *
22 * An audio service can obtain an audio driver object or agent and then call APIs provided by this object or agent to
23 * access different types of audio devices based on the audio IDs, thereby obtaining audio information,
24 * subscribing to or unsubscribing from audio data, enabling or disabling an audio,
25 * setting the audio data reporting mode, and setting audio options such as the accuracy and measurement range.
26 *
27 * @since 4.1
28 * @version 2.0
29 */
30
31package ohos.hdi.audio.v2_0;
32
33import ohos.hdi.audio.v2_0.AudioTypes;
34import ohos.hdi.audio.v2_0.IAudioAdapter;
35
36/**
37 * @brief Manages audio adapters through a specific adapter driver program loaded based on the given audio
38 * adapter descriptor.
39 *
40 * @see IAudioAdapter
41 * @since 4.1
42 * @version 2.0
43 */
44interface IAudioManager {
45    /**
46     * @brief Obtains the list of all adapters supported by an audio driver.
47     *
48     * @param manager Indicates the pointer to the audio adapter manager to operate.
49     * @param descs Indicates the double pointer to the audio adapter list.
50     * @param size Indicates the pointer to the length of the list.
51     * @return Returns <b>0</b> if the list is obtained successfully; returns a negative value otherwise.
52     * @see LoadAdapter
53     */
54    GetAllAdapters([out] struct AudioAdapterDescriptor[] descs);
55
56    /**
57     * @brief Loads the driver for an audio adapter.
58     *
59     * For example, to load a USB driver, you may need to load a dynamic-link library (*.so) in specific implementation.
60     *
61     * @param manager Indicates the pointer to the audio adapter manager to operate.
62     * @param desc Indicates the pointer to the descriptor of the audio adapter.
63     * @param adapter Indicates the double pointer to the audio adapter.
64     * @return Returns <b>0</b> if the driver is loaded successfully; returns a negative value otherwise.
65     * @see GetAllAdapters
66     * @see UnloadAdapter
67     */
68    LoadAdapter([in] struct AudioAdapterDescriptor desc, [out] IAudioAdapter adapter);
69
70    /**
71     * @brief Unloads the driver of an audio adapter.
72     *
73     * @param manager Indicates the pointer to the audio adapter manager to operate.
74     * @param adapter Indicates the pointer to the audio adapter whose driver will be unloaded.
75     * @see LoadAdapter
76     */
77    UnloadAdapter([in] String adapterName);
78
79    /**
80     * @brief Release the IAudioManager Object.
81     *
82     * @param object Indicates the pointer to the audio adapter manager to operate.
83     * @return Returns <b>true</b> if the Object is released; returns <b>false</b> otherwise.
84     */
85    ReleaseAudioManagerObject();
86}
87