1 /* 2 * Copyright (c) 2025 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 HPAE_PCM_PROCESS_H 17 #define HPAE_PCM_PROCESS_H 18 #include <vector> 19 #include "securec.h" 20 namespace OHOS { 21 namespace AudioStandard { 22 namespace HPAE { 23 class HpaePcmProcess { 24 public: HpaePcmProcess(float * begin,size_t size)25 HpaePcmProcess(float *begin, size_t size) : pcmDataPtr_(begin), size_(size) {} 26 27 float &operator[](size_t index) 28 { 29 return *(pcmDataPtr_ + index); 30 } 31 32 const float &operator[](size_t index) const 33 { 34 return *(pcmDataPtr_ + index); 35 } 36 Size()37 size_t Size() const 38 { 39 return size_; 40 } 41 Begin()42 float *Begin() 43 { 44 return pcmDataPtr_; 45 } 46 End()47 float *End() 48 { 49 return pcmDataPtr_ + size_; 50 } 51 Begin()52 const float *Begin() const 53 { 54 return pcmDataPtr_; 55 } 56 End()57 const float *End() const 58 { 59 return pcmDataPtr_ + size_; 60 } 61 62 HpaePcmProcess(const HpaePcmProcess &other) = default; 63 64 HpaePcmProcess &operator = (const HpaePcmProcess &other); 65 66 HpaePcmProcess &operator = (const std::vector<float>& other); 67 68 HpaePcmProcess &operator += (const HpaePcmProcess &other); 69 70 HpaePcmProcess &operator -= (const HpaePcmProcess &other); 71 72 HpaePcmProcess &operator *= (const HpaePcmProcess &other); 73 74 void Reset() ; 75 GetErrNo()76 int32_t GetErrNo() 77 { 78 int32_t tmpErrNo = errNo_; 79 errNo_ = 0; 80 return tmpErrNo; 81 } 82 83 private: 84 int32_t errNo_ = 0; 85 float* const pcmDataPtr_; 86 const size_t size_; 87 }; 88 }}} 89 #endif // HPAE_PCM_PROCESS_H