17a544b44b7872b300f50e16fef480f76e9145fbbEric Laurent/* 27a544b44b7872b300f50e16fef480f76e9145fbbEric Laurent * Copyright (C) 2016 The Android Open Source Project 37a544b44b7872b300f50e16fef480f76e9145fbbEric Laurent * 47a544b44b7872b300f50e16fef480f76e9145fbbEric Laurent * Licensed under the Apache License, Version 2.0 (the "License"); 57a544b44b7872b300f50e16fef480f76e9145fbbEric Laurent * you may not use this file except in compliance with the License. 67a544b44b7872b300f50e16fef480f76e9145fbbEric Laurent * You may obtain a copy of the License at 77a544b44b7872b300f50e16fef480f76e9145fbbEric Laurent * 87a544b44b7872b300f50e16fef480f76e9145fbbEric Laurent * http://www.apache.org/licenses/LICENSE-2.0 97a544b44b7872b300f50e16fef480f76e9145fbbEric Laurent * 107a544b44b7872b300f50e16fef480f76e9145fbbEric Laurent * Unless required by applicable law or agreed to in writing, software 117a544b44b7872b300f50e16fef480f76e9145fbbEric Laurent * distributed under the License is distributed on an "AS IS" BASIS, 127a544b44b7872b300f50e16fef480f76e9145fbbEric Laurent * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 137a544b44b7872b300f50e16fef480f76e9145fbbEric Laurent * See the License for the specific language governing permissions and 147a544b44b7872b300f50e16fef480f76e9145fbbEric Laurent * limitations under the License. 157a544b44b7872b300f50e16fef480f76e9145fbbEric Laurent */ 167a544b44b7872b300f50e16fef480f76e9145fbbEric Laurent 177a544b44b7872b300f50e16fef480f76e9145fbbEric Laurent#ifndef ANDROID_HARDWARE_SOUNDTRIGGER_HAL_LEGACY_H 187a544b44b7872b300f50e16fef480f76e9145fbbEric Laurent#define ANDROID_HARDWARE_SOUNDTRIGGER_HAL_LEGACY_H 197a544b44b7872b300f50e16fef480f76e9145fbbEric Laurent 207a544b44b7872b300f50e16fef480f76e9145fbbEric Laurent#include "SoundTriggerHalInterface.h" 217a544b44b7872b300f50e16fef480f76e9145fbbEric Laurent 227a544b44b7872b300f50e16fef480f76e9145fbbEric Laurentnamespace android { 237a544b44b7872b300f50e16fef480f76e9145fbbEric Laurent 247a544b44b7872b300f50e16fef480f76e9145fbbEric Laurentclass SoundTriggerHalLegacy : public SoundTriggerHalInterface 257a544b44b7872b300f50e16fef480f76e9145fbbEric Laurent 267a544b44b7872b300f50e16fef480f76e9145fbbEric Laurent{ 277a544b44b7872b300f50e16fef480f76e9145fbbEric Laurentpublic: 287a544b44b7872b300f50e16fef480f76e9145fbbEric Laurent virtual ~SoundTriggerHalLegacy(); 297a544b44b7872b300f50e16fef480f76e9145fbbEric Laurent 307a544b44b7872b300f50e16fef480f76e9145fbbEric Laurent virtual int getProperties(struct sound_trigger_properties *properties); 317a544b44b7872b300f50e16fef480f76e9145fbbEric Laurent 327a544b44b7872b300f50e16fef480f76e9145fbbEric Laurent /* 337a544b44b7872b300f50e16fef480f76e9145fbbEric Laurent * Load a sound model. Once loaded, recognition of this model can be started and stopped. 347a544b44b7872b300f50e16fef480f76e9145fbbEric Laurent * Only one active recognition per model at a time. The SoundTrigger service will handle 357a544b44b7872b300f50e16fef480f76e9145fbbEric Laurent * concurrent recognition requests by different users/applications on the same model. 367a544b44b7872b300f50e16fef480f76e9145fbbEric Laurent * The implementation returns a unique handle used by other functions (unload_sound_model(), 377a544b44b7872b300f50e16fef480f76e9145fbbEric Laurent * start_recognition(), etc... 387a544b44b7872b300f50e16fef480f76e9145fbbEric Laurent */ 397a544b44b7872b300f50e16fef480f76e9145fbbEric Laurent virtual int loadSoundModel(struct sound_trigger_sound_model *sound_model, 407a544b44b7872b300f50e16fef480f76e9145fbbEric Laurent sound_model_callback_t callback, 417a544b44b7872b300f50e16fef480f76e9145fbbEric Laurent void *cookie, 427a544b44b7872b300f50e16fef480f76e9145fbbEric Laurent sound_model_handle_t *handle); 437a544b44b7872b300f50e16fef480f76e9145fbbEric Laurent 447a544b44b7872b300f50e16fef480f76e9145fbbEric Laurent /* 457a544b44b7872b300f50e16fef480f76e9145fbbEric Laurent * Unload a sound model. A sound model can be unloaded to make room for a new one to overcome 467a544b44b7872b300f50e16fef480f76e9145fbbEric Laurent * implementation limitations. 477a544b44b7872b300f50e16fef480f76e9145fbbEric Laurent */ 487a544b44b7872b300f50e16fef480f76e9145fbbEric Laurent virtual int unloadSoundModel(sound_model_handle_t handle); 497a544b44b7872b300f50e16fef480f76e9145fbbEric Laurent 507a544b44b7872b300f50e16fef480f76e9145fbbEric Laurent /* Start recognition on a given model. Only one recognition active at a time per model. 517a544b44b7872b300f50e16fef480f76e9145fbbEric Laurent * Once recognition succeeds of fails, the callback is called. 527a544b44b7872b300f50e16fef480f76e9145fbbEric Laurent * TODO: group recognition configuration parameters into one struct and add key phrase options. 537a544b44b7872b300f50e16fef480f76e9145fbbEric Laurent */ 547a544b44b7872b300f50e16fef480f76e9145fbbEric Laurent virtual int startRecognition(sound_model_handle_t handle, 557a544b44b7872b300f50e16fef480f76e9145fbbEric Laurent const struct sound_trigger_recognition_config *config, 567a544b44b7872b300f50e16fef480f76e9145fbbEric Laurent recognition_callback_t callback, 577a544b44b7872b300f50e16fef480f76e9145fbbEric Laurent void *cookie); 587a544b44b7872b300f50e16fef480f76e9145fbbEric Laurent 597a544b44b7872b300f50e16fef480f76e9145fbbEric Laurent /* Stop recognition on a given model. 607a544b44b7872b300f50e16fef480f76e9145fbbEric Laurent * The implementation does not have to call the callback when stopped via this method. 617a544b44b7872b300f50e16fef480f76e9145fbbEric Laurent */ 627a544b44b7872b300f50e16fef480f76e9145fbbEric Laurent virtual int stopRecognition(sound_model_handle_t handle); 637a544b44b7872b300f50e16fef480f76e9145fbbEric Laurent 647a544b44b7872b300f50e16fef480f76e9145fbbEric Laurent /* Stop recognition on all models. 657a544b44b7872b300f50e16fef480f76e9145fbbEric Laurent * Only supported for device api versions SOUND_TRIGGER_DEVICE_API_VERSION_1_1 or above. 667a544b44b7872b300f50e16fef480f76e9145fbbEric Laurent * If no implementation is provided, stop_recognition will be called for each running model. 677a544b44b7872b300f50e16fef480f76e9145fbbEric Laurent */ 687a544b44b7872b300f50e16fef480f76e9145fbbEric Laurent int stopAllRecognitions(); 697a544b44b7872b300f50e16fef480f76e9145fbbEric Laurent 707a544b44b7872b300f50e16fef480f76e9145fbbEric Laurent // RefBase 717a544b44b7872b300f50e16fef480f76e9145fbbEric Laurent virtual void onFirstRef(); 727a544b44b7872b300f50e16fef480f76e9145fbbEric Laurent 737a544b44b7872b300f50e16fef480f76e9145fbbEric Laurentprivate: 747a544b44b7872b300f50e16fef480f76e9145fbbEric Laurent 757a544b44b7872b300f50e16fef480f76e9145fbbEric Laurent friend class SoundTriggerHalInterface; 767a544b44b7872b300f50e16fef480f76e9145fbbEric Laurent 777a544b44b7872b300f50e16fef480f76e9145fbbEric Laurent explicit SoundTriggerHalLegacy(const char *moduleName = NULL); 787a544b44b7872b300f50e16fef480f76e9145fbbEric Laurent 797a544b44b7872b300f50e16fef480f76e9145fbbEric Laurent const char *mModuleName; 807a544b44b7872b300f50e16fef480f76e9145fbbEric Laurent struct sound_trigger_hw_device* mHwDevice; 817a544b44b7872b300f50e16fef480f76e9145fbbEric Laurent}; 827a544b44b7872b300f50e16fef480f76e9145fbbEric Laurent 837a544b44b7872b300f50e16fef480f76e9145fbbEric Laurent} // namespace android 847a544b44b7872b300f50e16fef480f76e9145fbbEric Laurent 857a544b44b7872b300f50e16fef480f76e9145fbbEric Laurent#endif // ANDROID_HARDWARE_SOUNDTRIGGER_HAL_LEGACY_H 86