• 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_INTERFACE_H
18 #define ANDROID_HARDWARE_EFFECT_BUFFER_HAL_INTERFACE_H
19 
20 #include <system/audio_effect.h>
21 #include <utils/Errors.h>
22 #include <utils/RefBase.h>
23 
24 namespace android {
25 
26 // Abstraction for an audio buffer. It may be a "mirror" for
27 // a buffer that the effect chain doesn't own, or a buffer owned by
28 // the effect chain.
29 // Buffers are created from EffectsFactoryHalInterface
30 class EffectBufferHalInterface : public RefBase
31 {
32   public:
33     virtual audio_buffer_t* audioBuffer() = 0;
34     virtual void* externalData() const = 0;
35     // To be used when interacting with the code that doesn't know about
36     // "mirrored" buffers.
ptr()37     virtual void* ptr() {
38         return externalData() != nullptr ? externalData() : audioBuffer()->raw;
39     }
40 
41     virtual size_t getSize() const = 0;
42 
43     virtual void setExternalData(void* external) = 0;
44     virtual void setFrameCount(size_t frameCount) = 0;
45     virtual bool checkFrameCountChange() = 0;  // returns whether frame count has been updated
46                                                // since the last call to this method
47 
48     virtual void update() = 0;  // copies data from the external buffer, noop for allocated buffers
49     virtual void commit() = 0;  // copies data to the external buffer, noop for allocated buffers
50     virtual void update(size_t size) = 0;  // copies partial data from external buffer
51     virtual void commit(size_t size) = 0;  // copies partial data to external buffer
52 
53   protected:
54     // Subclasses can not be constructed directly by clients.
EffectBufferHalInterface()55     EffectBufferHalInterface() {}
56 
~EffectBufferHalInterface()57     virtual ~EffectBufferHalInterface() {}
58 };
59 
60 } // namespace android
61 
62 #endif // ANDROID_HARDWARE_EFFECT_BUFFER_HAL_INTERFACE_H
63