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