blob: b79bee02932e5eeef8efae8c41b1a9c8f0527ec0 [file] [log] [blame]
Mikhail Naganovf558e022016-11-14 17:45:17 -08001/*
2 * Copyright (C) 2016 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_HAL_HIDL_H
18#define ANDROID_HARDWARE_EFFECT_HAL_HIDL_H
19
20#include <android/hardware/audio/effect/2.0/IEffect.h>
21#include <media/audiohal/EffectHalInterface.h>
22#include <system/audio_effect.h>
23
24using ::android::hardware::audio::effect::V2_0::EffectDescriptor;
25using ::android::hardware::audio::effect::V2_0::IEffect;
26
27namespace android {
28
29class EffectHalHidl : public EffectHalInterface
30{
31 public:
32 // Effect process function. Takes input samples as specified
33 // in input buffer descriptor and output processed samples as specified
34 // in output buffer descriptor.
35 virtual status_t process(audio_buffer_t *inBuffer, audio_buffer_t *outBuffer);
36
37 // Process reverse stream function. This function is used to pass
38 // a reference stream to the effect engine.
39 virtual status_t processReverse(audio_buffer_t *inBuffer, audio_buffer_t *outBuffer);
40
41 // Send a command and receive a response to/from effect engine.
42 virtual status_t command(uint32_t cmdCode, uint32_t cmdSize, void *pCmdData,
43 uint32_t *replySize, void *pReplyData);
44
45 // Returns the effect descriptor.
46 virtual status_t getDescriptor(effect_descriptor_t *pDescriptor);
47
48 uint64_t effectId() const { return mEffectId; }
49
50 static void effectDescriptorToHal(
51 const EffectDescriptor& descriptor, effect_descriptor_t* halDescriptor);
52
53 private:
54 friend class EffectsFactoryHalHidl;
55 sp<IEffect> mEffect;
56 const uint64_t mEffectId;
57
58 static status_t analyzeResult(const hardware::audio::effect::V2_0::Result& result);
59
60 // Can not be constructed directly by clients.
61 EffectHalHidl(const sp<IEffect>& effect, uint64_t effectId);
62
63 // The destructor automatically releases the effect.
64 virtual ~EffectHalHidl();
65};
66
67} // namespace android
68
69#endif // ANDROID_HARDWARE_EFFECT_HAL_HIDL_H