• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #ifndef AUDIO_PROXY_COMMON_FUN_TEST_H
17 #define AUDIO_PROXY_COMMON_FUN_TEST_H
18 
19 #include <string>
20 #include "hdf_base.h"
21 #include "audio_types.h"
22 #include "audio_internal.h"
23 #include "audio_proxy_internal.h"
24 #include "audio_proxy_manager.h"
25 #include "audio_render.h"
26 #include "audio_capture.h"
27 
28 namespace comfun {
29     const int32_t PORTNUM = 1;
30     const int32_t AUDIO_CAPTURE_CHANNELCOUNT = 1;
31     const int32_t AUDIO_CHANNELCOUNT = 2;
32     const int32_t AUDIO_SAMPLE_RATE_48K = 48000;
33     const int32_t DEEP_BUFFER_RENDER_PERIOD_SIZE = 4096;
34     const int32_t INT_32_MAX = 0x7fffffff;
35     const int32_t SILENCE_THRESHOLD = 16 * 1024;
36     const int32_t DEFAULT_RENDER_SAMPLING_RATE = 48000;
37     const int32_t DEEP_BUFFER_RENDER_PERIOD_COUNT = 8;
38     const int32_t AUDIO_FORMAT_PCM_BIT = 16;
39     const int32_t MANAGER_ADAPTER_NAME_LEN = 32;
40     const int32_t AUDIO_CAPTURE_BUF_TEST = 8192 * 2;
41     const int32_t AUDIO_RENDER_BUF_TEST = 1024;
42     const int32_t AUDIO_ADAPTER_BUF_TEST = 1024;
43     const int32_t ADAPTER_COUNT = 32;
44     const float HALF_OF_NORMAL_VALUE = 0.5;
45     const float MIN_VALUE_OUT_OF_BOUNDS = -1;
46     const float MAX_VALUE_OUT_OF_BOUNDS = 2;
47     using TestAudioManager = struct AudioManager;
48     const std::string ADAPTER_NAME_USB = "usb";
49     const std::string FUNCTION_NAME = "GetAudioManagerFuncs";
50     const std::string RESOLVED_PATH = HDF_LIBRARY_FULL_PATH("libhdi_audio_client");
51 
52     void *GetDynamicLibHandle(const std::string path);
53     int32_t InitPort(struct AudioPort &portIndex);
54     int32_t InitHwRender(struct AudioHwRender &hwRender,
55         const struct AudioDeviceDescriptor &desc, const struct AudioSampleAttributes &attrs);
56     int32_t InitHwCapture(struct AudioHwCapture &hwCapture, const struct AudioDeviceDescriptor &desc,
57         const struct AudioSampleAttributes &attrs);
58     int32_t InitAttrs(struct AudioSampleAttributes &attrs);
59     int32_t InitDevDesc(struct AudioDeviceDescriptor &devDesc);
60     int32_t InitDevDesc(struct AudioDeviceDescriptor &devDesc, const uint32_t portId, int pins);
61     int32_t InitAttrsCapture(struct AudioSampleAttributes &attrs);
62     int32_t InitDevDescCapture(struct AudioDeviceDescriptor &devDesc);
63     int32_t AudioRenderCallbackUtTest(enum AudioCallbackType type, void *reserved, void *cookie);
64     int32_t GetLoadAdapter(TestAudioManager *manager, int portType,
65         const std::string &adapterName, struct AudioAdapter **adapter, struct AudioPort *&audioPort);
66     int32_t GetAdapters(TestAudioManager *manager, struct AudioAdapterDescriptor **descs, int &size);
67     int32_t SwitchAdapter(struct AudioAdapterDescriptor *descs, const std::string &adapterNameCase,
68         int portFlag, struct AudioPort *&audioPort, int size);
69 }
70 #endif
71