blob: cf6031fcba46606a574b8e9b26c78b8581637f9d [file] [log] [blame]
Shunkai Yao51202502022-12-12 06:11:46 +00001/*
2 * Copyright (C) 2022 The Android Open Source Project
3 *
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#pragma once
18
Shunkai Yaoc6308712023-02-22 17:53:04 +000019#include <aidl/android/hardware/common/Ashmem.h>
20
Shunkai Yao51202502022-12-12 06:11:46 +000021#include <media/audiohal/EffectBufferHalInterface.h>
22#include <system/audio_effect.h>
23
24namespace android {
25namespace effect {
26
27class EffectBufferHalAidl : public EffectBufferHalInterface {
28 public:
29 static status_t allocate(size_t size, sp<EffectBufferHalInterface>* buffer);
30 static status_t mirror(void* external, size_t size, sp<EffectBufferHalInterface>* buffer);
31
32 audio_buffer_t* audioBuffer() override;
33 void* externalData() const override;
34
35 size_t getSize() const override { return mBufferSize; }
36
37 void setExternalData(void* external) override;
38 void setFrameCount(size_t frameCount) override;
39 bool checkFrameCountChange() override;
40
41 void update() override;
42 void commit() override;
43 void update(size_t size) override;
44 void commit(size_t size) override;
45
46 private:
47 friend class EffectBufferHalInterface;
48
Shunkai Yaoc6308712023-02-22 17:53:04 +000049 // buffer size in bytes
Shunkai Yao51202502022-12-12 06:11:46 +000050 const size_t mBufferSize;
51 bool mFrameCountChanged;
52 void* mExternalData;
53 audio_buffer_t mAudioBuffer;
54
55 // Can not be constructed directly by clients.
56 explicit EffectBufferHalAidl(size_t size);
57
58 ~EffectBufferHalAidl();
Shunkai Yaoc6308712023-02-22 17:53:04 +000059 void copy(void* dst, const void* src, size_t n) const;
Shunkai Yao51202502022-12-12 06:11:46 +000060 status_t init();
61};
62
63} // namespace effect
64} // namespace android