1 /* 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 PATH(android/hardware/audio/effect/FILE_VERSION/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 26 using android::hardware::hidl_memory; 27 using android::hidl::memory::V1_0::IMemory; 28 29 namespace android { 30 namespace effect { 31 namespace CPP_VERSION { 32 33 using namespace ::android::hardware::audio::effect::CPP_VERSION; 34 35 class EffectBufferHalHidl : public EffectBufferHalInterface 36 { 37 public: 38 static status_t allocate(size_t size, sp<EffectBufferHalInterface>* buffer); 39 static status_t mirror(void* external, size_t size, sp<EffectBufferHalInterface>* buffer); 40 41 virtual audio_buffer_t* audioBuffer(); 42 virtual void* externalData() const; 43 getSize()44 virtual size_t getSize() const override { return mBufferSize; } 45 46 virtual void setExternalData(void* external); 47 virtual void setFrameCount(size_t frameCount); 48 virtual bool checkFrameCountChange(); 49 50 virtual void update(); 51 virtual void commit(); 52 virtual void update(size_t size); 53 virtual void commit(size_t size); 54 hidlBuffer()55 const AudioBuffer& hidlBuffer() const { return mHidlBuffer; } 56 57 private: 58 friend class EffectBufferHalInterface; 59 60 static uint64_t makeUniqueId(); 61 62 const size_t mBufferSize; 63 bool mFrameCountChanged; 64 void* mExternalData; 65 AudioBuffer mHidlBuffer; 66 sp<IMemory> mMemory; 67 audio_buffer_t mAudioBuffer; 68 69 // Can not be constructed directly by clients. 70 explicit EffectBufferHalHidl(size_t size); 71 72 virtual ~EffectBufferHalHidl(); 73 74 status_t init(); 75 }; 76 77 } // namespace CPP_VERSION 78 } // namespace effect 79 } // namespace android 80 81 #endif // ANDROID_HARDWARE_EFFECT_BUFFER_HAL_HIDL_H 82