1 /*
2  * Copyright (c) 2023 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 #ifndef HDF_AUDIO_SERVER_MANAGER_H
17 #define HDF_AUDIO_SERVER_MANAGER_H
18 
19 #include "audio_events.h"
20 #include "audio_internal.h"
21 #include "hdf_audio_server.h"
22 #include "hdf_device_desc.h"
23 #include "hdf_log.h"
24 
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28 
29 /* RenderManage Info */
30 struct AudioInfoInAdapter {
31     const char *adapterName;
32     struct AudioAdapter *adapter;
33     int adapterUserNum;
34     int renderStatus;
35     int renderPriority;
36     struct AudioRender *render;
37     bool renderBusy;
38     bool renderDestory;
39     uint32_t renderPid;
40     int captureStatus;
41     int capturePriority;
42     struct AudioCapture *capture;
43     bool captureBusy;
44     bool captureDestory;
45     uint32_t capturePid;
46 };
47 
48 int32_t ServerManageGetAdapterNum(int32_t serverAdapterNum);
49 int32_t AdapterManageInit(const struct AudioAdapterDescriptor *descs, int32_t num);
50 void AdaptersServerManageInfomationRecycle(void);
51 int32_t AudioAdapterListGetAdapterCapture(const char *adapterName,
52     struct AudioAdapter **adapter, struct AudioCapture **capture);
53 int32_t AudioDestroyCaptureInfoInAdapter(const char *adapterName);
54 int32_t AudioCreatCaptureCheck(const char *adapterName, const int32_t priority);
55 int32_t AudioAddCaptureInfoInAdapter(const char *adapterName,
56     struct AudioCapture *capture,
57     const struct AudioAdapter *adapter,
58     const int32_t priority,
59     uint32_t capturePid);
60 int32_t AudioAdapterListGetAdapter(const char *adapterName, struct AudioAdapter **adapter);
61 int32_t AudioCreatRenderCheck(const char *adapterName, const int32_t priority);
62 int32_t AudioAddRenderInfoInAdapter(const char *adapterName,
63     struct AudioRender *render,
64     const struct AudioAdapter *adapter,
65     const int32_t priority,
66     uint32_t renderPid);
67 void AudioSetRenderStatus(const char *adapterName, bool renderStatus);
68 int32_t AudioGetRenderStatus(const char *adapterName);
69 int32_t AudioDestroyRenderInfoInAdapter(const char *adapterName);
70 int32_t AudioAdapterListGetAdapterRender(const char *adapterName,
71     struct AudioAdapter **adapter, struct AudioRender **render);
72 int32_t AudioAdapterListGetRender(const char *adapterName,
73     struct AudioRender **render, uint32_t pid);
74 int32_t AudioAdapterListGetCapture(const char *adapterName,
75     struct AudioCapture **capture, uint32_t pid);
76 int32_t AudioAdapterFrameGetCapture(const char *adapterName,
77     struct AudioCapture **capture, uint32_t pid, uint32_t *index);
78 int32_t AudioAdapterListDestory(const char *adapterName, struct AudioAdapter **adapter);
79 int32_t AudioAdapterListAdd(const char *adapterName, struct AudioAdapter *adapter);
80 void AudioSetCaptureStatus(const char *adapterName, bool captureStatus);
81 void AudioSetCaptureBusy(uint32_t index, bool captureStatus);
82 int32_t AudioGetCaptureStatus(const char *adapterName);
83 int32_t AudioServerGetAdapterNum(void);
84 int32_t AudioAdapterCheckListExist(const char *adapterName);
85 #ifdef __cplusplus
86 }
87 #endif
88 #endif
89