1 /* 2 * Copyright (c) 2020-2021 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 Audio 18 * @{ 19 * 20 * @brief Defines audio-related APIs, including custom data types and functions for loading drivers, 21 * accessing a driver adapter, and rendering and capturing audios. 22 * 23 * @since 1.0 24 * @version 1.0 25 */ 26 27 /** 28 * @file audio_control.h 29 * 30 * @brief Declares APIs for audio control. 31 * 32 * @since 1.0 33 * @version 1.0 34 */ 35 36 #ifndef AUDIO_CONTROL_H 37 #define AUDIO_CONTROL_H 38 39 #include "audio_types.h" 40 namespace OHOS::HDI::Audio_Bluetooth { 41 /** 42 * @brief Provides control-related APIs for audio rendering or capturing, including functions to 43 * start, stop, pause, and resume audio rendering or capturing, and flush data in the audio buffer. 44 * 45 * @since 1.0 46 * @version 1.0 47 */ 48 struct AudioControl { 49 /** 50 * @brief Starts audio rendering or capturing. 51 * 52 * @param handle Indicates the audio handle. 53 * @return Returns <b>0</b> if the rendering or capturing is successfully started; 54 * returns a negative value otherwise. 55 * @see Stop 56 */ 57 int32_t (*Start)(AudioHandle handle); 58 59 /** 60 * @brief Stops audio rendering or capturing. 61 * 62 * @param handle Indicates the audio handle. 63 * @return Returns <b>0</b> if the rendering or capturing is successfully stopped; 64 * returns a negative value otherwise. 65 * @see Start 66 */ 67 int32_t (*Stop)(AudioHandle handle); 68 69 /** 70 * @brief Pauses audio rendering or capturing. 71 * 72 * @param handle Indicates the audio handle. 73 * @return Returns <b>0</b> if the rendering or capturing is successfully paused; 74 * returns a negative value otherwise. 75 * @see Resume 76 */ 77 int32_t (*Pause)(AudioHandle handle); 78 79 /** 80 * @brief Resumes audio rendering or capturing. 81 * 82 * @param handle Indicates the audio handle. 83 * @return Returns <b>0</b> if the rendering or capturing is successfully resumed; 84 * returns a negative value otherwise. 85 * @see Pause 86 */ 87 int32_t (*Resume)(AudioHandle handle); 88 89 /** 90 * @brief Flushes data in the audio buffer. 91 * 92 * @param handle Indicates the audio handle. 93 * @return Returns <b>0</b> if the flush is successful; returns a negative value otherwise. 94 */ 95 int32_t (*Flush)(AudioHandle handle); 96 97 /** 98 * @brief Sets or cancels the standby mode of the audio device. 99 * 100 * @param handle Indicates the audio handle. 101 * @return Returns <b>0</b> if the device is set to standby mode; returns a positive value if the standby mode is 102 * canceled; returns a negative value if the setting fails. 103 */ 104 int32_t (*TurnStandbyMode)(AudioHandle handle); 105 106 /** 107 * @brief Dumps information about the audio device. 108 * 109 * @param handle Indicates the audio handle. 110 * @param range Indicates the range of the device information to dump, which can be brief or full information. 111 * @param fd Indicates the file to which the device information will be dumped. 112 * @return Returns <b>0</b> if the operation is successful; returns a negative value otherwise. 113 */ 114 int32_t (*AudioDevDump)(AudioHandle handle, int32_t range, int32_t fd); 115 }; 116 } 117 #endif /* AUDIO_CONTROL_H */ 118 /** @} */ 119