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 32 using namespace ::android::hardware::audio::effect::CPP_VERSION; 33 34 class 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 getSize()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 hidlBuffer()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 76 } // namespace effect 77 } // namespace android 78 79 #endif // ANDROID_HARDWARE_EFFECT_BUFFER_HAL_HIDL_H 80