1 /* 2 * Copyright (c) 2024-2024 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 #ifndef SOURCE_USERDATA_H 16 #define SOURCE_USERDATA_H 17 18 #include <sys/eventfd.h> 19 #include <poll.h> 20 #include <pulsecore/core.h> 21 #include <pulsecore/log.h> 22 #include <pulsecore/module.h> 23 #include <pulsecore/source.h> 24 #include <pulsecore/thread-mq.h> 25 #include <pulsecore/thread.h> 26 #include <pulsecore/hashmap.h> 27 28 #include "common/hdi_adapter_info.h" 29 #include "intf_def.h" 30 31 #define DEFAULT_SCENE_BYPASS "scene.bypass" 32 #define MAX_SCENE_NAME_LEN 100 33 #define SCENE_TYPE_OFFSET 32 34 #define CAPTURER_ID_OFFSET 16 35 #define BYTE_SIZE_SAMPLE_U8 1 36 #define BYTE_SIZE_SAMPLE_S16 2 37 #define BYTE_SIZE_SAMPLE_S24 3 38 #define BYTE_SIZE_SAMPLE_S32 4 39 #define BASE_TEN 10 40 41 struct Userdata { 42 pa_core *core; 43 pa_module *module; 44 pa_source *source; 45 pa_thread *thread; 46 pa_thread_mq threadMq; 47 pa_thread *threadCap; 48 pa_asyncmsgq *CaptureMq; 49 pa_rtpoll *rtpoll; 50 uint32_t bufferSize; 51 uint32_t openMicSpeaker; 52 pa_usec_t blockUsec; 53 pa_usec_t timestamp; 54 struct SourceAdapterAttr attrs; 55 bool isCapturerStarted; 56 pa_atomic_t captureFlag; 57 pa_atomic_t quitCaptureFlag; 58 EcType ecType; 59 const char *ecAdapaterName; 60 uint32_t ecSamplingRate; 61 int32_t ecFormat; 62 uint32_t ecChannels; 63 pa_sample_spec ecSpec; 64 MicRefSwitch micRef; 65 uint32_t micRefRate; 66 int32_t micRefFormat; 67 uint32_t micRefChannels; 68 pa_sample_spec micRefSpec; 69 struct SourceAdapter *sourceAdapter; 70 pa_hashmap *sceneToCountMap; 71 pa_hashmap *sceneToPreResamplerMap; 72 pa_hashmap *sceneToEcResamplerMap; 73 pa_hashmap *sceneToMicRefResamplerMap; 74 struct SourceAdapter *sourceAdapterEc; 75 struct SourceAdapter *sourceAdapterMicRef; 76 uint64_t requestBytesEc; 77 uint64_t requestBytesMicRef; 78 void *bufferEc; 79 void *bufferMicRef; 80 uint32_t captureId; 81 uint32_t renderId; 82 pa_resampler *defaultSceneResampler; 83 pa_rtpoll_item *rtpollItem; 84 int eventFd; 85 }; 86 87 struct AlgoSpecs { 88 pa_sample_spec micSpec; 89 pa_sample_spec ecSpec; 90 pa_sample_spec micRefSpec; 91 }; 92 93 #endif // SOURCE_USERDATA_H