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