1 /* 2 * Copyright (c) 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 WAKEUP_SOURCE_PROCESS_H 16 #define WAKEUP_SOURCE_PROCESS_H 17 18 #include <memory> 19 #include "queue_util.h" 20 #include "audio_debug.h" 21 22 namespace OHOS { 23 namespace IntellVoiceEngine { 24 using OHOS::IntellVoiceUtils::Uint8ArrayBufferQueue; 25 constexpr uint32_t CHANNEL_ID_0 = 0; 26 constexpr uint32_t CHANNEL_ID_1 = 1; 27 constexpr uint32_t CHANNEL_ID_2 = 2; 28 constexpr uint32_t CHANNEL_ID_3 = 3; 29 30 class WakeupSourceProcess { 31 public: 32 WakeupSourceProcess() = default; 33 ~WakeupSourceProcess(); 34 void Init(uint32_t channelCnt); 35 void Write(const std::vector<std::vector<uint8_t>> &audioData); 36 int32_t Read(std::vector<uint8_t> &data, int32_t readChannel); 37 void Release(); 38 39 private: 40 void WriteChannelData(const std::vector<uint8_t> &channelData, uint32_t channelId); 41 bool ReadChannelData(std::vector<uint8_t> &channelData, uint32_t channelId); 42 void InitDebugFile(uint32_t channelCnt); 43 void WriteDebugData(const std::vector<std::shared_ptr<AudioDebug>> &debugVec, 44 const std::vector<uint8_t> &channelData, uint32_t channelId); 45 void ReleaseDebugFile(); 46 uint32_t channelCnt_ = 0; 47 std::vector<std::unique_ptr<Uint8ArrayBufferQueue>> bufferQueue_; 48 std::vector<std::shared_ptr<AudioDebug>> writeDebug_; 49 std::vector<std::shared_ptr<AudioDebug>> readDebug_; 50 }; 51 } 52 } 53 #endif