blob: 029d71a74cff00a0d4ba49454e060c847c885f4c [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
Kevin Rocarddf9b4202018-05-10 19:56:08 -070017#ifndef ANDROID_HARDWARE_EFFECT_BUFFER_HAL_HIDL_H
18#define ANDROID_HARDWARE_EFFECT_BUFFER_HAL_HIDL_H
Kevin Rocardd4de2882018-02-28 14:33:38 -080019
Kevin Rocard070e7512018-05-22 09:29:13 -070020#include <android/hardware/audio/effect/2.0/types.h>
Kevin Rocard2390b5d2018-02-28 14:36:53 -080021#include <android/hardware/audio/effect/4.0/types.h>
Kevin Rocardd4de2882018-02-28 14:33:38 -080022#include <android/hidl/memory/1.0/IMemory.h>
23#include <hidl/HidlSupport.h>
24#include <media/audiohal/EffectBufferHalInterface.h>
25#include <system/audio_effect.h>
26
Kevin Rocard070e7512018-05-22 09:29:13 -070027using android::hardware::audio::effect::CPP_VERSION::AudioBuffer;
Kevin Rocardd4de2882018-02-28 14:33:38 -080028using android::hardware::hidl_memory;
29using android::hidl::memory::V1_0::IMemory;
30
31namespace android {
Kevin Rocard070e7512018-05-22 09:29:13 -070032namespace CPP_VERSION {
Kevin Rocardd4de2882018-02-28 14:33:38 -080033
34class EffectBufferHalHidl : public EffectBufferHalInterface
35{
36 public:
37 static status_t allocate(size_t size, sp<EffectBufferHalInterface>* buffer);
38 static status_t mirror(void* external, size_t size, sp<EffectBufferHalInterface>* buffer);
39
40 virtual audio_buffer_t* audioBuffer();
41 virtual void* externalData() const;
42
43 virtual size_t getSize() const override { return mBufferSize; }
44
45 virtual void setExternalData(void* external);
46 virtual void setFrameCount(size_t frameCount);
47 virtual bool checkFrameCountChange();
48
49 virtual void update();
50 virtual void commit();
51 virtual void update(size_t size);
52 virtual void commit(size_t size);
53
54 const AudioBuffer& hidlBuffer() const { return mHidlBuffer; }
55
56 private:
57 friend class EffectBufferHalInterface;
58
59 static uint64_t makeUniqueId();
60
61 const size_t mBufferSize;
62 bool mFrameCountChanged;
63 void* mExternalData;
64 AudioBuffer mHidlBuffer;
65 sp<IMemory> mMemory;
66 audio_buffer_t mAudioBuffer;
67
68 // Can not be constructed directly by clients.
69 explicit EffectBufferHalHidl(size_t size);
70
71 virtual ~EffectBufferHalHidl();
72
73 status_t init();
74};
75
Kevin Rocard070e7512018-05-22 09:29:13 -070076} // namespace CPP_VERSION
Kevin Rocardd4de2882018-02-28 14:33:38 -080077} // namespace android
78
Kevin Rocarddf9b4202018-05-10 19:56:08 -070079#endif // ANDROID_HARDWARE_EFFECT_BUFFER_HAL_HIDL_H