Eric Laurent | 7a544b4 | 2016-08-05 19:01:13 -0700 | [diff] [blame] | 1 | /* |
| 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_SOUNDTRIGGER_HAL_LEGACY_H |
| 18 | #define ANDROID_HARDWARE_SOUNDTRIGGER_HAL_LEGACY_H |
| 19 | |
| 20 | #include "SoundTriggerHalInterface.h" |
| 21 | |
| 22 | namespace android { |
| 23 | |
| 24 | class SoundTriggerHalLegacy : public SoundTriggerHalInterface |
| 25 | |
| 26 | { |
| 27 | public: |
| 28 | virtual ~SoundTriggerHalLegacy(); |
| 29 | |
| 30 | virtual int getProperties(struct sound_trigger_properties *properties); |
| 31 | |
| 32 | /* |
| 33 | * Load a sound model. Once loaded, recognition of this model can be started and stopped. |
| 34 | * Only one active recognition per model at a time. The SoundTrigger service will handle |
| 35 | * concurrent recognition requests by different users/applications on the same model. |
| 36 | * The implementation returns a unique handle used by other functions (unload_sound_model(), |
| 37 | * start_recognition(), etc... |
| 38 | */ |
| 39 | virtual int loadSoundModel(struct sound_trigger_sound_model *sound_model, |
| 40 | sound_model_callback_t callback, |
| 41 | void *cookie, |
| 42 | sound_model_handle_t *handle); |
| 43 | |
| 44 | /* |
| 45 | * Unload a sound model. A sound model can be unloaded to make room for a new one to overcome |
| 46 | * implementation limitations. |
| 47 | */ |
| 48 | virtual int unloadSoundModel(sound_model_handle_t handle); |
| 49 | |
| 50 | /* Start recognition on a given model. Only one recognition active at a time per model. |
| 51 | * Once recognition succeeds of fails, the callback is called. |
| 52 | * TODO: group recognition configuration parameters into one struct and add key phrase options. |
| 53 | */ |
| 54 | virtual int startRecognition(sound_model_handle_t handle, |
| 55 | const struct sound_trigger_recognition_config *config, |
| 56 | recognition_callback_t callback, |
| 57 | void *cookie); |
| 58 | |
| 59 | /* Stop recognition on a given model. |
| 60 | * The implementation does not have to call the callback when stopped via this method. |
| 61 | */ |
| 62 | virtual int stopRecognition(sound_model_handle_t handle); |
| 63 | |
| 64 | /* Stop recognition on all models. |
| 65 | * Only supported for device api versions SOUND_TRIGGER_DEVICE_API_VERSION_1_1 or above. |
| 66 | * If no implementation is provided, stop_recognition will be called for each running model. |
| 67 | */ |
| 68 | int stopAllRecognitions(); |
| 69 | |
| 70 | // RefBase |
| 71 | virtual void onFirstRef(); |
| 72 | |
| 73 | private: |
| 74 | |
| 75 | friend class SoundTriggerHalInterface; |
| 76 | |
| 77 | explicit SoundTriggerHalLegacy(const char *moduleName = NULL); |
| 78 | |
| 79 | const char *mModuleName; |
| 80 | struct sound_trigger_hw_device* mHwDevice; |
| 81 | }; |
| 82 | |
| 83 | } // namespace android |
| 84 | |
| 85 | #endif // ANDROID_HARDWARE_SOUNDTRIGGER_HAL_LEGACY_H |