• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 Prepare() override;
34 
35     int32_t GetEffectBufferSize(uint32_t &inBufferSize, uint32_t &outBufferSize) override;
36 
37     int32_t Process(uint8_t *inBuffer, int32_t inSize, uint8_t *outBuffer, int32_t outSize) override;
38 
39     void Release() override;
40 
41     OfflineAudioEffectChainImpl(const std::string &chainName);
42 
43     ~OfflineAudioEffectChainImpl();
44 
45     int32_t CreateEffectChain();
46 private:
47     void InitDump();
48 
49     std::string chainName_;
50     std::shared_ptr<OfflineStreamInClient> offlineStreamInClient_ = nullptr;
51     std::shared_ptr<AudioSharedMemory> clientBufferIn_ = nullptr;
52     std::shared_ptr<AudioSharedMemory> clientBufferOut_ = nullptr;
53     uint8_t *inBufferBase_ = nullptr;
54     uint8_t *outBufferBase_ = nullptr;
55     std::mutex streamClientMutex_;
56     FILE *dumpFileIn_ = nullptr;
57     FILE *dumpFileOut_ = nullptr;
58 };
59 } // namespace AudioStandard
60 } // namespace OHOS
61 #endif // OFFLINE_AUDIO_EFFECT_CHAIN_IMPL_H