1094332d3Sopenharmony_ci/*
2094332d3Sopenharmony_ci * Copyright (c) 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#ifndef AUDIO_INTERNAL_H
17094332d3Sopenharmony_ci#define AUDIO_INTERNAL_H
18094332d3Sopenharmony_ci
19094332d3Sopenharmony_ci#include <math.h>
20094332d3Sopenharmony_ci#include <sys/mman.h>
21094332d3Sopenharmony_ci#include <sys/types.h>
22094332d3Sopenharmony_ci#include <unistd.h>
23094332d3Sopenharmony_ci#include <pthread.h>
24094332d3Sopenharmony_ci#include <errno.h>
25094332d3Sopenharmony_ci#include <servmgr_hdi.h>
26094332d3Sopenharmony_ci#include "audio_manager.h"
27094332d3Sopenharmony_ci#include "audio_common.h"
28094332d3Sopenharmony_ci#include "hdf_base.h"
29094332d3Sopenharmony_cinamespace OHOS::HDI::Audio_Bluetooth {
30094332d3Sopenharmony_ci#ifdef __cplusplus
31094332d3Sopenharmony_ciextern "C" {
32094332d3Sopenharmony_ci#endif
33094332d3Sopenharmony_ci
34094332d3Sopenharmony_ci#define LOG_ENABLE  1
35094332d3Sopenharmony_ci#define LOGV_ENABLE 1
36094332d3Sopenharmony_ci#define NAME_LEN 64
37094332d3Sopenharmony_ci#define BIT_NUM_32 32
38094332d3Sopenharmony_ci#define BIT_NUM_24 24
39094332d3Sopenharmony_ci#define BIT_NUM_16 16
40094332d3Sopenharmony_ci#define BIT_NUM_8 8
41094332d3Sopenharmony_ci#define PERIOD_SIZE 1024
42094332d3Sopenharmony_ci#define PERIOD_COUNT 2
43094332d3Sopenharmony_ci#define FRAME_DATA (8192 * 2)
44094332d3Sopenharmony_ci#define PATHPLAN_LEN 64
45094332d3Sopenharmony_ci#define PATHPLAN_COUNT 32
46094332d3Sopenharmony_ci#define PATH_NAME_LEN 128
47094332d3Sopenharmony_ci#define VOLUME_CHANGE 100
48094332d3Sopenharmony_ci#define SEC_TO_NSEC 1000000000
49094332d3Sopenharmony_ci#define HDMI_PORT_ID 12
50094332d3Sopenharmony_ci#define MAP_MAX 100
51094332d3Sopenharmony_ci#define FORMAT_ONE "%-5d  %-10d  %-20llu  %-15s  %s\n"
52094332d3Sopenharmony_ci#define FORMAT_TWO "%-5d  %-10d  %s\n"
53094332d3Sopenharmony_ci#define ERROR_LOG_MAX_NUM 8
54094332d3Sopenharmony_ci#define ERROR_REASON_DESC_LEN 64
55094332d3Sopenharmony_ci#define RANGE_MAX 5
56094332d3Sopenharmony_ci#define RANGE_MIN 4
57094332d3Sopenharmony_ci#define EXTPARAM_LEN 32
58094332d3Sopenharmony_ci
59094332d3Sopenharmony_ci/**
60094332d3Sopenharmony_ci * @brief Enumerates HAL return value types.
61094332d3Sopenharmony_ci */
62094332d3Sopenharmony_citypedef enum {
63094332d3Sopenharmony_ci    AUDIO_HAL_SUCCESS = 0,
64094332d3Sopenharmony_ci    AUDIO_HAL_ERR_INTERNAL = -1,      /* audio system internal errors */
65094332d3Sopenharmony_ci    AUDIO_HAL_ERR_NOT_SUPPORT = -2,   /* operation is not supported */
66094332d3Sopenharmony_ci    AUDIO_HAL_ERR_INVALID_PARAM = -3, /* parameter is invalid */
67094332d3Sopenharmony_ci    AUDIO_HAL_ERR_INVALID_OBJECT = -4, /**< Invalid object. */
68094332d3Sopenharmony_ci    AUDIO_HAL_ERR_MALLOC_FAIL = -6, /**< Memory allocation fails. */
69094332d3Sopenharmony_ci
70094332d3Sopenharmony_ci    #define HDF_AUDIO_HAL_ERR_START (-7000) /**< Defines the start of the device module error codes. */
71094332d3Sopenharmony_ci    #define HDF_AUDIO_HAL_ERR_NUM(v) (HDF_AUDIO_HAL_ERR_START + (v)) /**< Defines the device module error codes. */
72094332d3Sopenharmony_ci    AUDIO_HAL_ERR_NOTREADY = HDF_AUDIO_HAL_ERR_NUM(-1),      /* audio adapter is not ready */
73094332d3Sopenharmony_ci    AUDIO_HAL_ERR_AI_BUSY = HDF_AUDIO_HAL_ERR_NUM(-2),         /* audio capture is busy now */
74094332d3Sopenharmony_ci    AUDIO_HAL_ERR_AO_BUSY = HDF_AUDIO_HAL_ERR_NUM(-3),         /* audio render is busy now */
75094332d3Sopenharmony_ci} AUDIO_HAL_ERR_CODE;
76094332d3Sopenharmony_ci
77094332d3Sopenharmony_ci#ifndef LOGE
78094332d3Sopenharmony_ci    #define LOGE(fmt, arg...) printf("[Audio:E]" fmt "\n", ##arg)
79094332d3Sopenharmony_ci#endif
80094332d3Sopenharmony_ci#ifndef LOGI
81094332d3Sopenharmony_ci    #define LOGI(fmt, arg...) printf("[Audio:I]" fmt "\n", ##arg)
82094332d3Sopenharmony_ci#endif
83094332d3Sopenharmony_ci#ifndef LOGV
84094332d3Sopenharmony_ci    #define LOGV(fmt, arg...) printf("[Audio:V]" fmt "\n", ##arg)
85094332d3Sopenharmony_ci#endif
86094332d3Sopenharmony_ci
87094332d3Sopenharmony_ci#if !LOG_ENABLE
88094332d3Sopenharmony_ci    #undef LOGE
89094332d3Sopenharmony_ci    #undef LOGI
90094332d3Sopenharmony_ci    #undef LOGV
91094332d3Sopenharmony_ci
92094332d3Sopenharmony_ci    #define LOGE(...)
93094332d3Sopenharmony_ci    #define LOGI(...)
94094332d3Sopenharmony_ci    #define LOGV(...)
95094332d3Sopenharmony_ci#else
96094332d3Sopenharmony_ci    #if !LOGV_ENABLE
97094332d3Sopenharmony_ci        #undef LOGV
98094332d3Sopenharmony_ci        #define LOGV(...)
99094332d3Sopenharmony_ci    #endif // !LOGV_ENABLE
100094332d3Sopenharmony_ci#endif // LOG_ENABLE
101094332d3Sopenharmony_ci
102094332d3Sopenharmony_ci#ifndef UNUSED
103094332d3Sopenharmony_ci    #define UNUSED(x) ((void)(x))
104094332d3Sopenharmony_ci#endif
105094332d3Sopenharmony_ci
106094332d3Sopenharmony_ci#ifndef UT_TEST
107094332d3Sopenharmony_ci    #define STATIC_T static
108094332d3Sopenharmony_ci#else
109094332d3Sopenharmony_ci    #define STATIC_T
110094332d3Sopenharmony_ci#endif
111094332d3Sopenharmony_ci
112094332d3Sopenharmony_ci#define  USECASE_AUDIO_RENDER_DEEP_BUFFER  "deep-buffer-render"
113094332d3Sopenharmony_ci#define  USECASE_AUDIO_RENDER_LOW_LATENCY  "low-latency-render"
114094332d3Sopenharmony_ci
115094332d3Sopenharmony_ci#define AUDIO_ATTR_PARAM_ROUTE "attr-route"
116094332d3Sopenharmony_ci#define ROUTE_SAMPLE "attr-route=x;"
117094332d3Sopenharmony_ci#define AUDIO_ATTR_PARAM_FORMAT "attr-format"
118094332d3Sopenharmony_ci#define FORMAT_SAMPLE "attr-format=xx;"
119094332d3Sopenharmony_ci#define AUDIO_ATTR_PARAM_CHANNELS "attr-channels"
120094332d3Sopenharmony_ci#define CHANNELS_SAMPLE "attr-channels=x;"
121094332d3Sopenharmony_ci#define AUDIO_ATTR_PARAM_FRAME_COUNT "attr-frame-count"
122094332d3Sopenharmony_ci#define FRAME_COUNT_SAMPLE "attr-frame-count=xxxxxxxxxxxxxxxxxxxx;"
123094332d3Sopenharmony_ci#define AUDIO_ATTR_PARAM_SAMPLING_RATE "attr-sampling-rate"
124094332d3Sopenharmony_ci#define SAMPLING_RATE_SAMPLE "attr-sampling-rate=xxxxx"
125094332d3Sopenharmony_ci#define AUDIO_ATTR_PARAM_CONNECT "usb-connect"
126094332d3Sopenharmony_ci#define AUDIO_ATTR_PARAM_DISCONNECT "usb-disconnect"
127094332d3Sopenharmony_ci#ifdef A2DP_HDI_SERVICE
128094332d3Sopenharmony_ci#define A2DP_SUSPEND "A2dpSuspended"
129094332d3Sopenharmony_ci#endif
130094332d3Sopenharmony_ci
131094332d3Sopenharmony_ci#define TELHPONE_RATE 8000
132094332d3Sopenharmony_ci#define BROADCAST_AM_RATE 11025
133094332d3Sopenharmony_ci#define BROADCAST_FM_RATE 22050
134094332d3Sopenharmony_ci#define MINI_CAM_DV_RATE 32000
135094332d3Sopenharmony_ci#define MUSIC_RATE 44100
136094332d3Sopenharmony_ci#define HIGHT_MUSIC_RATE 48000
137094332d3Sopenharmony_ci#define AUDIO_SAMPLE_RATE_12000 12000
138094332d3Sopenharmony_ci#define AUDIO_SAMPLE_RATE_16000 16000
139094332d3Sopenharmony_ci#define AUDIO_SAMPLE_RATE_24000 24000
140094332d3Sopenharmony_ci#define AUDIO_SAMPLE_RATE_64000 64000
141094332d3Sopenharmony_ci#define AUDIO_SAMPLE_RATE_96000 96000
142094332d3Sopenharmony_ci#define MAX_TIME_INFO_LEN 64
143094332d3Sopenharmony_ci
144094332d3Sopenharmony_ci#ifndef OPEN_AUDIO_LOG_WITH_TIME
145094332d3Sopenharmony_ci#define LOG_FUN_INFO() do { \
146094332d3Sopenharmony_ci        printf("%s: [%s]: [%d]\n", __FILE__, __func__, __LINE__); \
147094332d3Sopenharmony_ci    } while (0)
148094332d3Sopenharmony_ci
149094332d3Sopenharmony_ci#define LOG_FUN_ERR(fmt, arg...) do { \
150094332d3Sopenharmony_ci        printf("%s: [%s]: [%d]:[ERROR]:" fmt"\n", __FILE__, __func__, __LINE__, ##arg); \
151094332d3Sopenharmony_ci    } while (0)
152094332d3Sopenharmony_ci
153094332d3Sopenharmony_ci#define LOG_PARA_INFO(fmt, arg...) do { \
154094332d3Sopenharmony_ci        printf("%s: [%s]: [%d]:[INFO]:" fmt"\n", __FILE__, __func__, __LINE__, ##arg); \
155094332d3Sopenharmony_ci    } while (0)
156094332d3Sopenharmony_ci#else
157094332d3Sopenharmony_ci#define LOG_FUN_INFO() do { \
158094332d3Sopenharmony_ci    } while (0)
159094332d3Sopenharmony_ci
160094332d3Sopenharmony_ci#define LOG_FUN_ERR(fmt, arg...) do { \
161094332d3Sopenharmony_ci        char s[MAX_TIME_INFO_LEN] = {0}; \
162094332d3Sopenharmony_ci        AudioGetSysTime(s, MAX_TIME_INFO_LEN); \
163094332d3Sopenharmony_ci        printf("%s %s: [%s]: [%d]:[ERROR]:" fmt"\n", s, __FILE__, __func__, __LINE__, ##arg); \
164094332d3Sopenharmony_ci    } while (0)
165094332d3Sopenharmony_ci
166094332d3Sopenharmony_ci#define LOG_PARA_INFO(fmt, arg...) do { \
167094332d3Sopenharmony_ci    } while (0)
168094332d3Sopenharmony_ci#endif
169094332d3Sopenharmony_ci
170094332d3Sopenharmony_cistruct DevHandleCapture {
171094332d3Sopenharmony_ci    void *object;
172094332d3Sopenharmony_ci};
173094332d3Sopenharmony_ci
174094332d3Sopenharmony_cistruct DevHandle {
175094332d3Sopenharmony_ci    void *object;
176094332d3Sopenharmony_ci};
177094332d3Sopenharmony_ci
178094332d3Sopenharmony_cistruct AudioPortAndCapability {
179094332d3Sopenharmony_ci    struct AudioPort port;
180094332d3Sopenharmony_ci    struct AudioPortCapability capability;
181094332d3Sopenharmony_ci    AudioPortPassthroughMode mode;
182094332d3Sopenharmony_ci};
183094332d3Sopenharmony_ci
184094332d3Sopenharmony_cistruct AudioHwAdapter {
185094332d3Sopenharmony_ci    struct AudioAdapter common;
186094332d3Sopenharmony_ci    struct AudioAdapterDescriptor adapterDescriptor;
187094332d3Sopenharmony_ci    struct AudioPortAndCapability *portCapabilitys;
188094332d3Sopenharmony_ci    struct HdfRemoteService *proxyRemoteHandle; // proxyRemoteHandle
189094332d3Sopenharmony_ci    int32_t adapterMgrRenderFlag;
190094332d3Sopenharmony_ci};
191094332d3Sopenharmony_ci
192094332d3Sopenharmony_cistruct AudioFrameRenderMode {
193094332d3Sopenharmony_ci    uint64_t frames;
194094332d3Sopenharmony_ci    struct AudioTimeStamp time;
195094332d3Sopenharmony_ci    struct AudioSampleAttributes attrs;
196094332d3Sopenharmony_ci    AudioChannelMode mode;
197094332d3Sopenharmony_ci    uint32_t byteRate;
198094332d3Sopenharmony_ci    uint32_t periodSize;
199094332d3Sopenharmony_ci    uint32_t periodCount;
200094332d3Sopenharmony_ci    uint32_t startThreshold;
201094332d3Sopenharmony_ci    uint32_t stopThreshold;
202094332d3Sopenharmony_ci    uint32_t silenceThreshold;
203094332d3Sopenharmony_ci    uint32_t silenceSize;
204094332d3Sopenharmony_ci    char *buffer;
205094332d3Sopenharmony_ci    uint64_t bufferFrameSize;
206094332d3Sopenharmony_ci    uint64_t bufferSize;
207094332d3Sopenharmony_ci    RenderCallback callback;
208094332d3Sopenharmony_ci    void* cookie;
209094332d3Sopenharmony_ci    struct AudioMmapBufferDescriptor mmapBufDesc;
210094332d3Sopenharmony_ci};
211094332d3Sopenharmony_ci
212094332d3Sopenharmony_cistruct AudioGain {
213094332d3Sopenharmony_ci    float gain;
214094332d3Sopenharmony_ci    float gainMin;
215094332d3Sopenharmony_ci    float gainMax;
216094332d3Sopenharmony_ci};
217094332d3Sopenharmony_ci
218094332d3Sopenharmony_cistruct AudioVol {
219094332d3Sopenharmony_ci    int volMin;
220094332d3Sopenharmony_ci    int volMax;
221094332d3Sopenharmony_ci};
222094332d3Sopenharmony_ci
223094332d3Sopenharmony_cistruct AudioCtlParam {
224094332d3Sopenharmony_ci    bool mute;
225094332d3Sopenharmony_ci    float volume;
226094332d3Sopenharmony_ci    float speed;
227094332d3Sopenharmony_ci    bool pause;
228094332d3Sopenharmony_ci    bool stop;
229094332d3Sopenharmony_ci    pthread_mutex_t mutex;
230094332d3Sopenharmony_ci    bool mutexFlag;
231094332d3Sopenharmony_ci    pthread_cond_t functionCond;
232094332d3Sopenharmony_ci    struct AudioVol volThreshold;
233094332d3Sopenharmony_ci    struct AudioGain audioGain;
234094332d3Sopenharmony_ci};
235094332d3Sopenharmony_ci
236094332d3Sopenharmony_cienum PathRoute {
237094332d3Sopenharmony_ci    DEEP_BUFF = 0,
238094332d3Sopenharmony_ci    RECORD,
239094332d3Sopenharmony_ci    RECORD_LOW_LATRNCY,
240094332d3Sopenharmony_ci    LOW_LATRNCY,
241094332d3Sopenharmony_ci};
242094332d3Sopenharmony_ci
243094332d3Sopenharmony_cistruct PathPlan {
244094332d3Sopenharmony_ci    char pathPlanName[PATHPLAN_LEN];
245094332d3Sopenharmony_ci    int value;
246094332d3Sopenharmony_ci};
247094332d3Sopenharmony_ci
248094332d3Sopenharmony_cistruct PathDeviceSwitch {
249094332d3Sopenharmony_ci    char deviceSwitch[PATHPLAN_LEN];
250094332d3Sopenharmony_ci    int32_t value;
251094332d3Sopenharmony_ci};
252094332d3Sopenharmony_ci
253094332d3Sopenharmony_cistruct PathDeviceInfo {
254094332d3Sopenharmony_ci    char deviceType[NAME_LEN];
255094332d3Sopenharmony_ci    int32_t deviceNum;
256094332d3Sopenharmony_ci    struct PathDeviceSwitch deviceSwitchs[PATHPLAN_COUNT];
257094332d3Sopenharmony_ci};
258094332d3Sopenharmony_ci
259094332d3Sopenharmony_cistruct PathSelect {
260094332d3Sopenharmony_ci    char useCase[NAME_LEN];
261094332d3Sopenharmony_ci    struct PathDeviceInfo deviceInfo;
262094332d3Sopenharmony_ci    int useCaseDeviceNum;
263094332d3Sopenharmony_ci    struct PathPlan pathPlan[PATHPLAN_COUNT];
264094332d3Sopenharmony_ci};
265094332d3Sopenharmony_ci
266094332d3Sopenharmony_cistruct HwInfo {
267094332d3Sopenharmony_ci    uint32_t card;
268094332d3Sopenharmony_ci    uint32_t device;
269094332d3Sopenharmony_ci    int flags;
270094332d3Sopenharmony_ci    char adapterName[NAME_LEN];
271094332d3Sopenharmony_ci    struct AudioPort portDescript;
272094332d3Sopenharmony_ci    struct AudioDeviceDescriptor deviceDescript;
273094332d3Sopenharmony_ci    PathRoute pathroute;
274094332d3Sopenharmony_ci    struct PathSelect pathSelect;
275094332d3Sopenharmony_ci};
276094332d3Sopenharmony_ci
277094332d3Sopenharmony_cistruct AudioHwRenderMode {
278094332d3Sopenharmony_ci    struct AudioCtlParam ctlParam;
279094332d3Sopenharmony_ci    struct HwInfo hwInfo;
280094332d3Sopenharmony_ci};
281094332d3Sopenharmony_ci
282094332d3Sopenharmony_cistruct AudioHwRenderParam {
283094332d3Sopenharmony_ci    struct AudioHwRenderMode renderMode;
284094332d3Sopenharmony_ci    struct AudioFrameRenderMode frameRenderMode;
285094332d3Sopenharmony_ci};
286094332d3Sopenharmony_ci
287094332d3Sopenharmony_cistruct ErrorDump {
288094332d3Sopenharmony_ci    int32_t errorCode;
289094332d3Sopenharmony_ci    int32_t count;
290094332d3Sopenharmony_ci    unsigned long long frames;
291094332d3Sopenharmony_ci    char* reason;                       // Specific reasons for failure
292094332d3Sopenharmony_ci    char* currentTime;
293094332d3Sopenharmony_ci};
294094332d3Sopenharmony_ci
295094332d3Sopenharmony_cistruct ErrorLog {
296094332d3Sopenharmony_ci    uint32_t totalErrors;
297094332d3Sopenharmony_ci    uint32_t iter;
298094332d3Sopenharmony_ci    struct ErrorDump errorDump[ERROR_LOG_MAX_NUM];
299094332d3Sopenharmony_ci};
300094332d3Sopenharmony_ci
301094332d3Sopenharmony_cistruct AudioHwRender {
302094332d3Sopenharmony_ci    struct AudioRender common;
303094332d3Sopenharmony_ci    struct AudioHwRenderParam renderParam;
304094332d3Sopenharmony_ci    struct HdfRemoteService *proxyRemoteHandle; // proxyRemoteHandle
305094332d3Sopenharmony_ci    struct ErrorLog errorLog;
306094332d3Sopenharmony_ci};
307094332d3Sopenharmony_ci
308094332d3Sopenharmony_cistruct ParamValMap {
309094332d3Sopenharmony_ci    char key[EXTPARAM_LEN];
310094332d3Sopenharmony_ci    char value[EXTPARAM_LEN];
311094332d3Sopenharmony_ci};
312094332d3Sopenharmony_ci
313094332d3Sopenharmony_cistruct ExtraParams {
314094332d3Sopenharmony_ci    int32_t route;
315094332d3Sopenharmony_ci    int32_t format;
316094332d3Sopenharmony_ci    uint32_t channels;
317094332d3Sopenharmony_ci    uint64_t frames;
318094332d3Sopenharmony_ci    uint32_t sampleRate;
319094332d3Sopenharmony_ci    bool flag;
320094332d3Sopenharmony_ci#ifdef A2DP_HDI_SERVICE
321094332d3Sopenharmony_ci    uint32_t audioStreamCtl;
322094332d3Sopenharmony_ci#endif
323094332d3Sopenharmony_ci};
324094332d3Sopenharmony_ci
325094332d3Sopenharmony_cienum ErrorDumpCode {
326094332d3Sopenharmony_ci    WRITE_FRAME_ERROR_CODE = -5,
327094332d3Sopenharmony_ci};
328094332d3Sopenharmony_ci
329094332d3Sopenharmony_cienum AudioServiceNameType {
330094332d3Sopenharmony_ci    AUDIO_SERVICE_IN = 0,
331094332d3Sopenharmony_ci    AUDIO_SERVICE_OUT,
332094332d3Sopenharmony_ci    AUDIO_SERVICE_MAX,
333094332d3Sopenharmony_ci};
334094332d3Sopenharmony_ci
335094332d3Sopenharmony_ciint32_t GetAudioRenderFunc(struct AudioHwRender *hwRender, const char *adapterName);
336094332d3Sopenharmony_ciint32_t CheckParaDesc(const struct AudioDeviceDescriptor *desc, const char *type);
337094332d3Sopenharmony_ciint32_t CheckParaAttr(const struct AudioSampleAttributes *attrs);
338094332d3Sopenharmony_ciint32_t AttrFormatToBit(const struct AudioSampleAttributes *attrs, int32_t *format);
339094332d3Sopenharmony_ciint32_t InitHwRenderParam(struct AudioHwRender *hwRender, const struct AudioDeviceDescriptor *desc,
340094332d3Sopenharmony_ci                          const struct AudioSampleAttributes *attrs);
341094332d3Sopenharmony_ciint32_t InitForGetPortCapability(struct AudioPort portIndex, struct AudioPortCapability *capabilityIndex);
342094332d3Sopenharmony_civoid AudioAdapterReleaseCapSubPorts(const struct AudioPortAndCapability *portCapabilitys, int32_t num);
343094332d3Sopenharmony_ciint32_t AudioAdapterInitAllPorts(struct AudioAdapter *adapter);
344094332d3Sopenharmony_civoid AudioReleaseRenderHandle(struct AudioHwRender *hwRender);
345094332d3Sopenharmony_ciint32_t AudioAdapterCreateRenderPre(struct AudioHwRender *hwRender, const struct AudioDeviceDescriptor *desc,
346094332d3Sopenharmony_ci                                    const struct AudioSampleAttributes *attrs, const struct AudioHwAdapter *hwAdapter);
347094332d3Sopenharmony_ciint32_t AudioAdapterBindServiceRender(struct AudioHwRender *hwRender);
348094332d3Sopenharmony_ciint32_t AudioAdapterCreateRender(struct AudioAdapter *adapter, const struct AudioDeviceDescriptor *desc,
349094332d3Sopenharmony_ci                                 const struct AudioSampleAttributes *attrs, struct AudioRender **render);
350094332d3Sopenharmony_ciint32_t AudioAdapterDestroyRender(struct AudioAdapter *adapter, struct AudioRender *render);
351094332d3Sopenharmony_ciint32_t AudioAdapterGetPortCapability(struct AudioAdapter *adapter, const struct AudioPort *port,
352094332d3Sopenharmony_ci                                      struct AudioPortCapability *capability);
353094332d3Sopenharmony_ciint32_t AudioAdapterSetPassthroughMode(struct AudioAdapter *adapter, const struct AudioPort *port,
354094332d3Sopenharmony_ci                                       AudioPortPassthroughMode mode);
355094332d3Sopenharmony_ciint32_t AudioAdapterGetPassthroughMode(struct AudioAdapter *adapter, const struct AudioPort *port,
356094332d3Sopenharmony_ci                                       AudioPortPassthroughMode *mode);
357094332d3Sopenharmony_ciint32_t AudioAdapterSetExtraParams(struct AudioAdapter *adapter, enum AudioExtParamKey key,
358094332d3Sopenharmony_ci                                   const char *condition, const char *value);
359094332d3Sopenharmony_ciint32_t AudioAdapterGetExtraParams(struct AudioAdapter *adapter, enum AudioExtParamKey key,
360094332d3Sopenharmony_ci                                   const char *condition, char *value, int32_t length);
361094332d3Sopenharmony_ciint32_t PcmBytesToFrames(const struct AudioFrameRenderMode *frameRenderMode, uint64_t bytes, uint32_t *frameCount);
362094332d3Sopenharmony_ciint32_t AudioRenderStart(AudioHandle handle);
363094332d3Sopenharmony_ciint32_t AudioRenderStop(AudioHandle handle);
364094332d3Sopenharmony_ciint32_t AudioRenderPause(AudioHandle handle);
365094332d3Sopenharmony_ciint32_t AudioRenderResume(AudioHandle handle);
366094332d3Sopenharmony_ciint32_t AudioRenderFlush(AudioHandle handle);
367094332d3Sopenharmony_ciint32_t AudioRenderGetFrameSize(AudioHandle handle, uint64_t *size);
368094332d3Sopenharmony_ciint32_t AudioRenderGetFrameCount(AudioHandle handle, uint64_t *count);
369094332d3Sopenharmony_ciint32_t AudioRenderSetSampleAttributes(AudioHandle handle, const struct AudioSampleAttributes *attrs);
370094332d3Sopenharmony_ciint32_t AudioRenderGetSampleAttributes(AudioHandle handle, struct AudioSampleAttributes *attrs);
371094332d3Sopenharmony_ciint32_t AudioRenderGetCurrentChannelId(AudioHandle handle, uint32_t *channelId);
372094332d3Sopenharmony_ciint32_t AudioRenderCheckSceneCapability(AudioHandle handle, const struct AudioSceneDescriptor *scene,
373094332d3Sopenharmony_ci                                        bool *supported);
374094332d3Sopenharmony_ciint32_t AudioRenderSelectScene(AudioHandle handle, const struct AudioSceneDescriptor *scene);
375094332d3Sopenharmony_ciint32_t AudioRenderSetMute(AudioHandle handle, bool mute);
376094332d3Sopenharmony_ciint32_t AudioRenderGetMute(AudioHandle handle, bool *mute);
377094332d3Sopenharmony_ciint32_t AudioRenderSetVolume(AudioHandle handle, float volume);
378094332d3Sopenharmony_ciint32_t AudioRenderGetVolume(AudioHandle handle, float *volume);
379094332d3Sopenharmony_ciint32_t AudioRenderGetGainThreshold(AudioHandle handle, float *min, float *max);
380094332d3Sopenharmony_ciint32_t AudioRenderGetGain(AudioHandle handle, float *gain);
381094332d3Sopenharmony_ciint32_t AudioRenderSetGain(AudioHandle handle, float gain);
382094332d3Sopenharmony_ciint32_t AudioRenderGetLatency(struct AudioRender *render, uint32_t *ms);
383094332d3Sopenharmony_ciint32_t AudioRenderRenderFrame(struct AudioRender *render, const void *frame,
384094332d3Sopenharmony_ci                               uint64_t requestBytes, uint64_t *replyBytes);
385094332d3Sopenharmony_ciint32_t AudioRenderGetRenderPosition(struct AudioRender *render, uint64_t *frames, struct AudioTimeStamp *time);
386094332d3Sopenharmony_ciint32_t AudioRenderSetRenderSpeed(struct AudioRender *render, float speed);
387094332d3Sopenharmony_ciint32_t AudioRenderGetRenderSpeed(struct AudioRender *render, float *speed);
388094332d3Sopenharmony_ciint32_t AudioRenderSetChannelMode(struct AudioRender *render, AudioChannelMode mode);
389094332d3Sopenharmony_ciint32_t AudioRenderGetChannelMode(struct AudioRender *render, AudioChannelMode *mode);
390094332d3Sopenharmony_ciint32_t AudioRenderSetExtraParams(AudioHandle handle, const char *keyValueList);
391094332d3Sopenharmony_ciint32_t AudioRenderGetExtraParams(AudioHandle handle, char *keyValueList, int32_t listLenth);
392094332d3Sopenharmony_ciint32_t AudioRenderReqMmapBuffer(AudioHandle handle, int32_t reqSize, struct AudioMmapBufferDescriptor *desc);
393094332d3Sopenharmony_ciint32_t AudioRenderGetMmapPosition(AudioHandle handle, uint64_t *frames, struct AudioTimeStamp *time);
394094332d3Sopenharmony_ciint32_t AudioRenderTurnStandbyMode(AudioHandle handle);
395094332d3Sopenharmony_ciint32_t AudioRenderAudioDevDump(AudioHandle handle, int32_t range, int32_t fd);
396094332d3Sopenharmony_ciint32_t AudioRenderRegCallback(struct AudioRender *render, RenderCallback callback, void* cookie);
397094332d3Sopenharmony_ciint32_t AudioRenderDrainBuffer(struct AudioRender *render, AudioDrainNotifyType *type);
398094332d3Sopenharmony_ci
399094332d3Sopenharmony_ci#ifdef __cplusplus
400094332d3Sopenharmony_ci}
401094332d3Sopenharmony_ci#endif
402094332d3Sopenharmony_ci}
403094332d3Sopenharmony_ci#endif
404