blob: f4887084dc4eb5da04a41aeb94a72d0ad0ff6197 [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
19#include <media/audiohal/EffectBufferHalInterface.h>
20#include <system/audio_effect.h>
21
22namespace android {
23namespace effect {
24
25class EffectBufferHalAidl : public EffectBufferHalInterface {
26 public:
27 static status_t allocate(size_t size, sp<EffectBufferHalInterface>* buffer);
28 static status_t mirror(void* external, size_t size, sp<EffectBufferHalInterface>* buffer);
29
30 audio_buffer_t* audioBuffer() override;
31 void* externalData() const override;
32
33 size_t getSize() const override { return mBufferSize; }
34
35 void setExternalData(void* external) override;
36 void setFrameCount(size_t frameCount) override;
37 bool checkFrameCountChange() override;
38
39 void update() override;
40 void commit() override;
41 void update(size_t size) override;
42 void commit(size_t size) override;
43
44 private:
45 friend class EffectBufferHalInterface;
46
47 const size_t mBufferSize;
48 bool mFrameCountChanged;
49 void* mExternalData;
50 audio_buffer_t mAudioBuffer;
51
52 // Can not be constructed directly by clients.
53 explicit EffectBufferHalAidl(size_t size);
54
55 ~EffectBufferHalAidl();
56
57 status_t init();
58};
59
60} // namespace effect
61} // namespace android