blob: 31e0087c23855f47f1c1af356eec8588de4ec2d3 [file] [log] [blame]
Kevin Rocardd4de2882018-02-28 14:33:38 -08001/*
2 * Copyright (C) 2017 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#ifndef ANDROID_HARDWARE_EFFECT_BUFFER_HAL_HIDL_H
18#define ANDROID_HARDWARE_EFFECT_BUFFER_HAL_HIDL_H
19
20#include <android/hardware/audio/effect/2.0/types.h>
21#include <android/hidl/memory/1.0/IMemory.h>
22#include <hidl/HidlSupport.h>
23#include <media/audiohal/EffectBufferHalInterface.h>
24#include <system/audio_effect.h>
25
26using android::hardware::audio::effect::V2_0::AudioBuffer;
27using android::hardware::hidl_memory;
28using android::hidl::memory::V1_0::IMemory;
29
30namespace android {
31
32class EffectBufferHalHidl : public EffectBufferHalInterface
33{
34 public:
35 static status_t allocate(size_t size, sp<EffectBufferHalInterface>* buffer);
36 static status_t mirror(void* external, size_t size, sp<EffectBufferHalInterface>* buffer);
37
38 virtual audio_buffer_t* audioBuffer();
39 virtual void* externalData() const;
40
41 virtual size_t getSize() const override { return mBufferSize; }
42
43 virtual void setExternalData(void* external);
44 virtual void setFrameCount(size_t frameCount);
45 virtual bool checkFrameCountChange();
46
47 virtual void update();
48 virtual void commit();
49 virtual void update(size_t size);
50 virtual void commit(size_t size);
51
52 const AudioBuffer& hidlBuffer() const { return mHidlBuffer; }
53
54 private:
55 friend class EffectBufferHalInterface;
56
57 static uint64_t makeUniqueId();
58
59 const size_t mBufferSize;
60 bool mFrameCountChanged;
61 void* mExternalData;
62 AudioBuffer mHidlBuffer;
63 sp<IMemory> mMemory;
64 audio_buffer_t mAudioBuffer;
65
66 // Can not be constructed directly by clients.
67 explicit EffectBufferHalHidl(size_t size);
68
69 virtual ~EffectBufferHalHidl();
70
71 status_t init();
72};
73
74} // namespace android
75
76#endif // ANDROID_HARDWARE_EFFECT_BUFFER_HAL_HIDL_H