1 2 /* 3 * Copyright (c) 2024 Huawei Device Co., Ltd. 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #ifndef OFFLINE_AUDIO_EFFECT_CHAIN_IMPL_H 18 #define OFFLINE_AUDIO_EFFECT_CHAIN_IMPL_H 19 20 #include <mutex> 21 #include <shared_mutex> 22 23 #include "offline_audio_effect_manager.h" 24 #include "oh_audio_buffer.h" 25 26 namespace OHOS { 27 namespace AudioStandard { 28 class OfflineAudioEffectChainImpl : public OfflineAudioEffectChain { 29 public: 30 int32_t Configure(const AudioStreamInfo &inInfo, const AudioStreamInfo &outInfo) override; 31 32 int32_t Prepare() override; 33 34 int32_t GetEffectBufferSize(uint32_t &inBufferSize, uint32_t &outBufferSize) override; 35 36 int32_t Process(uint8_t *inBuffer, int32_t inSize, uint8_t *outBuffer, int32_t outSize) override; 37 38 void Release() override; 39 40 OfflineAudioEffectChainImpl(const std::string &chainName); 41 42 ~OfflineAudioEffectChainImpl(); 43 44 int32_t CreateEffectChain(); 45 private: 46 void InitDump(); 47 48 std::string chainName_; 49 std::shared_ptr<OfflineStreamInClient> offlineStreamInClient_ = nullptr; 50 std::shared_ptr<AudioSharedMemory> clientBufferIn_ = nullptr; 51 std::shared_ptr<AudioSharedMemory> clientBufferOut_ = nullptr; 52 uint8_t *inBufferBase_ = nullptr; 53 uint8_t *outBufferBase_ = nullptr; 54 std::mutex streamClientMutex_; 55 FILE *dumpFileIn_ = nullptr; 56 FILE *dumpFileOut_ = nullptr; 57 }; 58 } // namespace AudioStandard 59 } // namespace OHOS 60 #endif // OFFLINE_AUDIO_EFFECT_CHAIN_IMPL_H