1 /* 2 * Copyright (C) 2022 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 #pragma once 18 19 #include <aidl/android/hardware/common/Ashmem.h> 20 21 #include <media/audiohal/EffectBufferHalInterface.h> 22 #include <system/audio_effect.h> 23 24 namespace android { 25 namespace effect { 26 27 class EffectBufferHalAidl : public EffectBufferHalInterface { 28 public: 29 static status_t allocate(size_t size, sp<EffectBufferHalInterface>* buffer); 30 static status_t mirror(void* external, size_t size, sp<EffectBufferHalInterface>* buffer); 31 32 audio_buffer_t* audioBuffer() override; 33 void* externalData() const override; 34 getSize()35 size_t getSize() const override { return mBufferSize; } 36 37 void setExternalData(void* external) override; 38 void setFrameCount(size_t frameCount) override; 39 bool checkFrameCountChange() override; 40 41 void update() override; 42 void commit() override; 43 void update(size_t size) override; 44 void commit(size_t size) override; 45 46 private: 47 friend class EffectBufferHalInterface; 48 49 // buffer size in bytes 50 const size_t mBufferSize; 51 bool mFrameCountChanged; 52 void* mExternalData; 53 audio_buffer_t mAudioBuffer; 54 55 // Can not be constructed directly by clients. 56 explicit EffectBufferHalAidl(size_t size); 57 58 ~EffectBufferHalAidl(); 59 void copy(void* dst, const void* src, size_t n) const; 60 status_t init(); 61 }; 62 63 } // namespace effect 64 } // namespace android 65