1 /*
2  * Copyright (c) 2022 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 
41 namespace OHOS {
42 /**
43  * @brief Provides control-related APIs for audio rendering or capturing, including functions to
44  * start, stop, pause, and resume audio rendering or capturing, and flush data in the audio buffer.
45  *
46  * @since 1.0
47  * @version 1.0
48  */
49 struct AudioControl {
50     /**
51      * @brief Starts audio rendering or capturing.
52      *
53      * @param handle Indicates the audio handle.
54      * @return Returns <b>0</b> if the rendering or capturing is successfully started;
55      * returns a negative value otherwise.
56      * @see Stop
57      */
58     int32_t (*Start)(AudioHandle handle);
59 
60     /**
61      * @brief Stops audio rendering or capturing.
62      *
63      * @param handle Indicates the audio handle.
64      * @return Returns <b>0</b> if the rendering or capturing is successfully stopped;
65      * returns a negative value otherwise.
66      * @see Start
67      */
68     int32_t (*Stop)(AudioHandle handle);
69 
70     /**
71      * @brief Pauses audio rendering or capturing.
72      *
73      * @param handle Indicates the audio handle.
74      * @return Returns <b>0</b> if the rendering or capturing is successfully paused;
75      * returns a negative value otherwise.
76      * @see Resume
77      */
78     int32_t (*Pause)(AudioHandle handle);
79 
80     /**
81      * @brief Resumes audio rendering or capturing.
82      *
83      * @param handle Indicates the audio handle.
84      * @return Returns <b>0</b> if the rendering or capturing is successfully resumed;
85      * returns a negative value otherwise.
86      * @see Pause
87      */
88     int32_t (*Resume)(AudioHandle handle);
89 
90     /**
91      * @brief Flushes data in the audio buffer.
92      *
93      * @param handle Indicates the audio handle.
94      * @return Returns <b>0</b> if the flush is successful; returns a negative value otherwise.
95      */
96     int32_t (*Flush)(AudioHandle handle);
97 
98     /**
99      * @brief Sets or cancels the standby mode of the audio device.
100      *
101      * @param handle Indicates the audio handle.
102      * @return Returns <b>0</b> if the device is set to standby mode; returns a positive value if the standby mode is
103      * canceled; returns a negative value if the setting fails.
104      */
105     int32_t (*TurnStandbyMode)(AudioHandle handle);
106 
107     /**
108      * @brief Dumps information about the audio device.
109      *
110      * @param handle Indicates the audio handle.
111      * @param range Indicates the range of the device information to dump, which can be brief or full information.
112      * @param fd Indicates the file to which the device information will be dumped.
113      * @return Returns <b>0</b> if the operation is successful; returns a negative value otherwise.
114      */
115     int32_t (*AudioDevDump)(AudioHandle handle, int32_t range, int32_t fd);
116 
117     /**
118      * @brief Query whether the vendor support pause and resume.
119      *
120      * @param handle Indicates the audio handle.
121      * @param supportPause Indicates the state whether the vendor supports pausing. Value <b>true</b> means that
122      * the vendor supports, and <b>false</b> means the opposite.
123      * @param supportResume Indicates the state whether the vendor supports resuming. Value <b>true</b> means that
124      * the vendor supports, and <b>false</b> means the opposite.
125      * @return Returns <b>0</b> if the operation is successful; returns a negative value otherwise.
126      * @see IsSupportsPauseAndResume
127      */
128     int32_t (*IsSupportsPauseAndResume)(AudioHandle handle, bool *supportPause, bool *supportResume);
129 };
130 } /* end of OHOS */
131 #endif /* AUDIO_CONTROL_H */
132 /** @} */
133