/* * Copyright (c) 2020-2021 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * @addtogroup Audio * @{ * * @brief Defines audio-related APIs, including custom data types and functions for loading drivers, * accessing a driver adapter, and rendering and capturing audios. * * @since 1.0 * @version 1.0 */ /** * @file audio_volume.h * * @brief Declares APIs for audio volume. * * @since 1.0 * @version 1.0 */ #ifndef AUDIO_VOLUME_H #define AUDIO_VOLUME_H #include "audio_types.h" /** * @brief Provides volume-related APIs for audio rendering or capturing, including functions to * set the mute operation, volume, and gain. * * @since 1.0 * @version 1.0 */ struct AudioVolume { /** * @brief Sets the mute operation for the audio. * * @param handle Indicates the audio handle. * @param mute Specifies whether to mute the audio. Value true means to mute the audio, * and false means the opposite. * @return Returns 0 if the setting is successful; returns a negative value otherwise. * @see GetMute */ int32_t (*SetMute)(AudioHandle handle, bool mute); /** * @brief Obtains the mute operation set for the audio. * * @param handle Indicates the audio handle. * @param mute Indicates the pointer to the mute operation set for the audio. Value true means that * the audio is muted, and false means the opposite. * @return Returns 0 if the mute operation is obtained; returns a negative value otherwise. * @see SetMute */ int32_t (*GetMute)(AudioHandle handle, bool *mute); /** * @brief Sets the audio volume. * * The volume ranges from 0.0 to 1.0. If the volume level in an audio service ranges from 0 to 15, * 0.0 indicates that the audio is muted, and 1.0 indicates the maximum volume level (15). * * @param handle Indicates the audio handle. * @param volume Indicates the volume to set. The value ranges from 0.0 to 1.0. * @return Returns 0 if the setting is successful; returns a negative value otherwise. * @see GetVolume */ int32_t (*SetVolume)(AudioHandle handle, float volume); /** * @brief Obtains the audio volume. * * @param handle Indicates the audio handle. * @param volume Indicates the pointer to the volume to obtain. The value ranges from 0.0 to 1.0. * @return Returns 0 if the volume is obtained; returns a negative value otherwise. * @see SetVolume */ int32_t (*GetVolume)(AudioHandle handle, float *volume); /** * @brief Obtains the range of the audio gain. * * The audio gain can be expressed in one of the following two ways (depending on the chip platform), * corresponding to two types of value ranges: *