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 "offline_stream_in_client.h" 25 #include "oh_audio_buffer.h" 26 27 namespace OHOS { 28 namespace AudioStandard { 29 class OfflineAudioEffectChainImpl : public OfflineAudioEffectChain { 30 public: 31 int32_t Configure(const AudioStreamInfo &inInfo, const AudioStreamInfo &outInfo) override; 32 33 int32_t SetParam(const std::vector<uint8_t> ¶m) override; 34 35 int32_t Prepare() override; 36 37 int32_t GetEffectBufferSize(uint32_t &inBufferSize, uint32_t &outBufferSize) override; 38 39 int32_t Process(uint8_t *inBuffer, int32_t inSize, uint8_t *outBuffer, int32_t outSize) override; 40 41 void Release() override; 42 OfflineAudioEffectChainImpl()43 OfflineAudioEffectChainImpl(){}; 44 45 OfflineAudioEffectChainImpl(const std::string &chainName); 46 47 ~OfflineAudioEffectChainImpl(); 48 49 int32_t CreateEffectChain(); 50 private: 51 void InitDump(); 52 53 std::string chainName_; 54 std::shared_ptr<OfflineStreamInClient> offlineStreamInClient_ = nullptr; 55 std::shared_ptr<AudioSharedMemory> clientBufferIn_ = nullptr; 56 std::shared_ptr<AudioSharedMemory> clientBufferOut_ = nullptr; 57 uint8_t *inBufferBase_ = nullptr; 58 uint8_t *outBufferBase_ = nullptr; 59 std::mutex streamClientMutex_; 60 FILE *dumpFileIn_ = nullptr; 61 FILE *dumpFileOut_ = nullptr; 62 }; 63 } // namespace AudioStandard 64 } // namespace OHOS 65 #endif // OFFLINE_AUDIO_EFFECT_CHAIN_IMPL_H