blob: 7db54db94191dec3269773636db9819430687a49 [file] [log] [blame]
mike dooley0320d562018-09-21 09:07:37 +02001/*
2 * Copyright (C) 2018 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_SOUNDTRIGGER_V2_2_SOUNDTRIGGERHW_H
18#define ANDROID_HARDWARE_SOUNDTRIGGER_V2_2_SOUNDTRIGGERHW_H
19
20#include <SoundTriggerHalImpl.h>
21#include <android/hardware/soundtrigger/2.1/ISoundTriggerHw.h>
22#include <android/hardware/soundtrigger/2.2/ISoundTriggerHw.h>
23#include <hidl/Status.h>
24
25namespace android {
26namespace hardware {
27namespace soundtrigger {
28namespace V2_2 {
29namespace implementation {
30
31using ::android::sp;
32using ::android::hardware::Return;
33
34struct SoundTriggerHw : public V2_1::implementation::SoundTriggerHw {
35 SoundTriggerHw() = default;
36 ISoundTriggerHw* getInterface() { return new TrampolineSoundTriggerHw_2_2(this); }
37
38 protected:
39 virtual ~SoundTriggerHw() = default;
40
41 Return<sp<struct sound_trigger_recognition_event>> getModelState_2_2(
42 V2_0::SoundModelHandle modelHandle modelHandle);
43
44 private:
45 struct TrampolineSoundTriggerHw_2_2 : public ISoundTriggerHw {
46 explicit TrampolineSoundTriggerHw_2_2(sp<SoundTriggerHw> impl) : mImpl(impl) {}
47
48 // Methods from ::android::hardware::soundtrigger::V2_0::ISoundTriggerHw follow.
49 Return<void> getProperties(getProperties_cb _hidl_cb) override {
50 return mImpl->getProperties(_hidl_cb);
51 }
52 Return<void> loadSoundModel(const V2_0::ISoundTriggerHw::SoundModel& soundModel,
53 const sp<V2_0::ISoundTriggerHwCallback>& callback,
54 int32_t cookie, loadSoundModel_cb _hidl_cb) override {
55 return mImpl->loadSoundModel(soundModel, callback, cookie, _hidl_cb);
56 }
57 Return<void> loadPhraseSoundModel(const V2_0::ISoundTriggerHw::PhraseSoundModel& soundModel,
58 const sp<V2_0::ISoundTriggerHwCallback>& callback,
59 int32_t cookie,
60 loadPhraseSoundModel_cb _hidl_cb) override {
61 return mImpl->loadPhraseSoundModel(soundModel, callback, cookie, _hidl_cb);
62 }
63 Return<int32_t> unloadSoundModel(V2_0::SoundModelHandle modelHandle) override {
64 return mImpl->unloadSoundModel(modelHandle);
65 }
66 Return<int32_t> startRecognition(int32_t modelHandle,
67 const V2_0::ISoundTriggerHw::RecognitionConfig& config,
68 const sp<V2_0::ISoundTriggerHwCallback>& /*callback*/,
69 int32_t /*cookie*/) override {
70 return mImpl->startRecognition(modelHandle, config);
71 }
72 Return<int32_t> stopRecognition(V2_0::SoundModelHandle modelHandle) override {
73 return mImpl->stopRecognition(modelHandle);
74 }
75 Return<int32_t> stopAllRecognitions() override { return mImpl->stopAllRecognitions(); }
76
77 // Methods from V2_1::ISoundTriggerHw follow.
78 Return<void> loadSoundModel_2_1(const V2_1::ISoundTriggerHw::SoundModel& soundModel,
79 const sp<V2_1::ISoundTriggerHwCallback>& callback,
80 int32_t cookie, loadSoundModel_2_1_cb _hidl_cb) override {
81 return mImpl->loadSoundModel_2_1(soundModel, callback, cookie, _hidl_cb);
82 }
83 Return<void> loadPhraseSoundModel_2_1(
84 const V2_1::ISoundTriggerHw::PhraseSoundModel& soundModel,
85 const sp<V2_1::ISoundTriggerHwCallback>& callback, int32_t cookie,
86 loadPhraseSoundModel_2_1_cb _hidl_cb) override {
87 return mImpl->loadPhraseSoundModel_2_1(soundModel, callback, cookie, _hidl_cb);
88 }
89 Return<int32_t> startRecognition_2_1(int32_t modelHandle,
90 const V2_1::ISoundTriggerHw::RecognitionConfig& config,
91 const sp<V2_1::ISoundTriggerHwCallback>& /*callback*/,
92 int32_t /*cookie*/) override {
93 return mImpl->startRecognition_2_1(modelHandle, config);
94 }
95
96 // Methods from V2_2::ISoundTriggerHw follow.
97 Return<void> getModelState(int32_t modelHandle, getModelState_cb hidl_cb) override {
98 return mImpl->getModelState_2_2(modelHandle, hidl_cb);
99 }
100
101 private:
102 sp<SoundTriggerHw> mImpl;
103 };
104};
105
106extern "C" ISoundTriggerHw* HIDL_FETCH_ISoundTriggerHw(const char* name);
107
108} // namespace implementation
109} // namespace V2_2
110} // namespace soundtrigger
111} // namespace hardware
112} // namespace android
113
114#endif // ANDROID_HARDWARE_SOUNDTRIGGER_V2_2_SOUNDTRIGGERHW_H