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_volume.h
29094332d3Sopenharmony_ci *
30094332d3Sopenharmony_ci * @brief Declares APIs for audio volume.
31094332d3Sopenharmony_ci *
32094332d3Sopenharmony_ci * @since 1.0
33094332d3Sopenharmony_ci * @version 1.0
34094332d3Sopenharmony_ci */
35094332d3Sopenharmony_ci
36094332d3Sopenharmony_ci#ifndef AUDIO_VOLUME_H
37094332d3Sopenharmony_ci#define AUDIO_VOLUME_H
38094332d3Sopenharmony_ci
39094332d3Sopenharmony_ci#include "audio_types.h"
40094332d3Sopenharmony_ci
41094332d3Sopenharmony_ci/**
42094332d3Sopenharmony_ci * @brief Provides volume-related APIs for audio rendering or capturing, including functions to
43094332d3Sopenharmony_ci * set the mute operation, volume, and gain.
44094332d3Sopenharmony_ci *
45094332d3Sopenharmony_ci * @since 1.0
46094332d3Sopenharmony_ci * @version 1.0
47094332d3Sopenharmony_ci */
48094332d3Sopenharmony_cistruct AudioVolume {
49094332d3Sopenharmony_ci    /**
50094332d3Sopenharmony_ci     * @brief Sets the mute operation for the audio.
51094332d3Sopenharmony_ci     *
52094332d3Sopenharmony_ci     * @param handle Indicates the audio handle.
53094332d3Sopenharmony_ci     * @param mute Specifies whether to mute the audio. Value <b>true</b> means to mute the audio,
54094332d3Sopenharmony_ci     * and <b>false</b> means the opposite.
55094332d3Sopenharmony_ci     * @return Returns <b>0</b> if the setting is successful; returns a negative value otherwise.
56094332d3Sopenharmony_ci     * @see GetMute
57094332d3Sopenharmony_ci     */
58094332d3Sopenharmony_ci    int32_t (*SetMute)(AudioHandle handle, bool mute);
59094332d3Sopenharmony_ci
60094332d3Sopenharmony_ci    /**
61094332d3Sopenharmony_ci     * @brief Obtains the mute operation set for the audio.
62094332d3Sopenharmony_ci     *
63094332d3Sopenharmony_ci     * @param handle Indicates the audio handle.
64094332d3Sopenharmony_ci     * @param mute Indicates the pointer to the mute operation set for the audio. Value <b>true</b> means that
65094332d3Sopenharmony_ci     * the audio is muted, and <b>false</b> means the opposite.
66094332d3Sopenharmony_ci     * @return Returns <b>0</b> if the mute operation is obtained; returns a negative value otherwise.
67094332d3Sopenharmony_ci     * @see SetMute
68094332d3Sopenharmony_ci     */
69094332d3Sopenharmony_ci    int32_t (*GetMute)(AudioHandle handle, bool *mute);
70094332d3Sopenharmony_ci
71094332d3Sopenharmony_ci    /**
72094332d3Sopenharmony_ci     * @brief Sets the audio volume.
73094332d3Sopenharmony_ci     *
74094332d3Sopenharmony_ci     * The volume ranges from 0.0 to 1.0. If the volume level in an audio service ranges from 0 to 15,
75094332d3Sopenharmony_ci     * <b>0.0</b> indicates that the audio is muted, and <b>1.0</b> indicates the maximum volume level (15).
76094332d3Sopenharmony_ci     *
77094332d3Sopenharmony_ci     * @param handle Indicates the audio handle.
78094332d3Sopenharmony_ci     * @param volume Indicates the volume to set. The value ranges from 0.0 to 1.0.
79094332d3Sopenharmony_ci     * @return Returns <b>0</b> if the setting is successful; returns a negative value otherwise.
80094332d3Sopenharmony_ci     * @see GetVolume
81094332d3Sopenharmony_ci     */
82094332d3Sopenharmony_ci    int32_t (*SetVolume)(AudioHandle handle, float volume);
83094332d3Sopenharmony_ci
84094332d3Sopenharmony_ci    /**
85094332d3Sopenharmony_ci     * @brief Obtains the audio volume.
86094332d3Sopenharmony_ci     *
87094332d3Sopenharmony_ci     * @param handle Indicates the audio handle.
88094332d3Sopenharmony_ci     * @param volume Indicates the pointer to the volume to obtain. The value ranges from 0.0 to 1.0.
89094332d3Sopenharmony_ci     * @return Returns <b>0</b> if the volume is obtained; returns a negative value otherwise.
90094332d3Sopenharmony_ci     * @see SetVolume
91094332d3Sopenharmony_ci     */
92094332d3Sopenharmony_ci    int32_t (*GetVolume)(AudioHandle handle, float *volume);
93094332d3Sopenharmony_ci
94094332d3Sopenharmony_ci    /**
95094332d3Sopenharmony_ci     * @brief Obtains the range of the audio gain.
96094332d3Sopenharmony_ci     *
97094332d3Sopenharmony_ci     * The audio gain can be expressed in one of the following two ways (depending on the chip platform),
98094332d3Sopenharmony_ci     * corresponding to two types of value ranges:
99094332d3Sopenharmony_ci     * <ul>
100094332d3Sopenharmony_ci     *   <li>Actual audio gain values, for example, ranging from -50 to 6 dB</li>
101094332d3Sopenharmony_ci     *   <li>Float numbers ranging from 0.0 to 1.0, where <b>0.0</b> means to mute the audio,
102094332d3Sopenharmony_ci     *     and <b>1.0</b> means the maximum gain value, for example, 6 dB</li>
103094332d3Sopenharmony_ci     * </ul>
104094332d3Sopenharmony_ci     * @param handle Indicates the audio handle.
105094332d3Sopenharmony_ci     * @param min Indicates the pointer to the minimum value of the range.
106094332d3Sopenharmony_ci     * @param max Indicates the pointer to the maximum value of the range.
107094332d3Sopenharmony_ci     * @return Returns <b>0</b> if the range is obtained; returns a negative value otherwise.
108094332d3Sopenharmony_ci     * @see GetGain
109094332d3Sopenharmony_ci     * @see SetGain
110094332d3Sopenharmony_ci     */
111094332d3Sopenharmony_ci    int32_t (*GetGainThreshold)(AudioHandle handle, float *min, float *max);
112094332d3Sopenharmony_ci
113094332d3Sopenharmony_ci    /**
114094332d3Sopenharmony_ci     * @brief Obtains the audio gain.
115094332d3Sopenharmony_ci     *
116094332d3Sopenharmony_ci     * @param handle Indicates the audio handle.
117094332d3Sopenharmony_ci     * @param gain Indicates the pointer to the audio gain.
118094332d3Sopenharmony_ci     * @return Returns <b>0</b> if the audio gain is obtained; returns a negative value otherwise.
119094332d3Sopenharmony_ci     * @see GetGainThreshold
120094332d3Sopenharmony_ci     * @see SetGain
121094332d3Sopenharmony_ci     */
122094332d3Sopenharmony_ci    int32_t (*GetGain)(AudioHandle handle, float *gain);
123094332d3Sopenharmony_ci
124094332d3Sopenharmony_ci    /**
125094332d3Sopenharmony_ci     * @brief Sets the audio gain.
126094332d3Sopenharmony_ci     *
127094332d3Sopenharmony_ci     * @param handle Indicates the audio handle.
128094332d3Sopenharmony_ci     * @param gain Indicates the audio gain to set.
129094332d3Sopenharmony_ci     * @return Returns <b>0</b> if the setting is successful; returns a negative value otherwise.
130094332d3Sopenharmony_ci     * @see GetGainThreshold
131094332d3Sopenharmony_ci     * @see GetGain
132094332d3Sopenharmony_ci     */
133094332d3Sopenharmony_ci    int32_t (*SetGain)(AudioHandle handle, float gain);
134094332d3Sopenharmony_ci};
135094332d3Sopenharmony_ci
136094332d3Sopenharmony_ci#endif /* AUDIO_VOLUME_H */
137094332d3Sopenharmony_ci/** @} */
138