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