1 /* 2 * Copyright (c) 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_adapter.h 29 * 30 * @brief Declares APIs for operations related to the audio adapter. 31 * 32 * @since 1.0 33 * @version 1.0 34 */ 35 36 #ifndef AUDIO_HDI_FUZZER_COMMON_H 37 #define AUDIO_HDI_FUZZER_COMMON_H 38 #include <iostream> 39 #include <cstring> 40 #include "audio_adapter.h" 41 #include "audio_internal.h" 42 #include "audio_types.h" 43 #include "audio_proxy_manager.h" 44 45 namespace HMOS { 46 namespace Audio { 47 using namespace std; 48 49 #ifdef AUDIO_ADM_SO 50 const std::string FUNCTION_NAME = "GetAudioManagerFuncs"; 51 const std::string RESOLVED_PATH = HDF_LIBRARY_FULL_PATH("libhdi_audio"); 52 using TestAudioManager = struct AudioManager; 53 #endif 54 #ifdef AUDIO_ADM_SERVICE 55 const std::string FUNCTION_NAME = "GetAudioProxyManagerFuncs"; 56 const std::string RESOLVED_PATH = HDF_LIBRARY_FULL_PATH("libhdi_audio_client"); 57 using TestAudioManager = struct AudioProxyManager; 58 #endif 59 const uint32_t INT_32_MAX = 0x7fffffff; 60 const uint32_t MOVE_RIGHT_NUM = 3; 61 const int MOVE_LEFT_NUM = 8; 62 const int CHANNELCOUNT = 2; 63 const int FILE_CAPTURE_SIZE = 1024 * 1024 * 1; 64 const int SAMPLERATE = 48000; 65 const int DEEP_BUFFER_RENDER_PERIOD_SIZE = 4096; 66 const int BUFFER_LENTH = 1024 * 16; 67 const uint64_t MEGABYTE = 1024; 68 const int FRAME_SIZE = 1024; 69 const int FRAME_COUNT = 4; 70 const int ADAPTER_COUNT = 32; 71 const int TRY_NUM_FRAME = 20; 72 const int AUDIO_ADAPTER_MAX_NUM = 3; 73 const string AUDIO_LOW_LATENCY_CAPTURE_FILE = "//bin/lowlatencycapturetest.wav"; 74 const string AUDIO_LOW_LATENCY_RENDER_FILE = "//bin/lowlatencyrendertest.wav"; 75 76 77 enum AudioPCMBit { 78 PCM_8_BIT = 8, 79 PCM_16_BIT = 16, 80 PCM_24_BIT = 24, 81 PCM_32_BIT = 32, 82 }; 83 int32_t GetManager(TestAudioManager *&manager); 84 85 int32_t InitAttrs(struct AudioSampleAttributes& attrs); 86 87 int32_t InitDevDesc(struct AudioDeviceDescriptor& devDesc, const uint32_t portId, enum AudioPortPin pins); 88 89 int32_t GetAdapters(TestAudioManager *manager, struct AudioAdapterDescriptor **descs, int &size); 90 91 int32_t GetLoadAdapter(TestAudioManager *manager, struct AudioAdapter **adapter, struct AudioPort *&audioPort); 92 93 int32_t AudioCreateRender(TestAudioManager *manager, struct AudioAdapter **adapter, struct AudioRender **render); 94 95 int32_t AudioGetManagerCreateRender(TestAudioManager *&manager, struct AudioAdapter **adapter, 96 struct AudioRender **render); 97 98 int32_t AudioGetManagerCreateStartRender(TestAudioManager *&manager, struct AudioAdapter **adapter, 99 struct AudioRender **render); 100 101 int32_t AudioCreateCapture(TestAudioManager *manager, struct AudioAdapter **adapter, struct AudioCapture **capture); 102 103 int32_t AudioGetManagerCreateCapture(TestAudioManager *&manager, struct AudioAdapter **adapter, 104 struct AudioCapture **capture); 105 106 int32_t AudioGetManagerCreateStartCapture(TestAudioManager *&manager, struct AudioAdapter **adapter, 107 struct AudioCapture **capture); 108 109 int32_t InitMmapDesc(FILE *fp, struct AudioMmapBufferDescripter &desc, int32_t &reqSize, bool flag); 110 } 111 } 112 #endif // AUDIO_HDI_FUZZER_COMMON_H 113 114