diff options
author | Eric Laurent <elaurent@google.com> | 2014-07-27 18:39:40 -0700 |
---|---|---|
committer | Eric Laurent <elaurent@google.com> | 2014-08-05 12:10:27 -0700 |
commit | df3dc7e2fe6c639529b70e3f3a7d2bf0f4c6e871 (patch) | |
tree | e54724362f700e3e72fc72604a3b5f568d8cee7b /soundtrigger | |
parent | d0fded31e473e909c018f534d3019fb5168bdcd6 (diff) | |
download | frameworks_av-df3dc7e2fe6c639529b70e3f3a7d2bf0f4c6e871.zip frameworks_av-df3dc7e2fe6c639529b70e3f3a7d2bf0f4c6e871.tar.gz frameworks_av-df3dc7e2fe6c639529b70e3f3a7d2bf0f4c6e871.tar.bz2 |
Add sound trigger control by audio policy
Audio policy:
- Added active capture indication to sound trigger service:
recognition stops if concurrent capture is not supported.
- Added generation of reserved I/O handle and session ID for
utterance capture.
Sound trigger service
- Added sound model update callback handling.
- Added service state callback
- Simplified callback shared memory allocation.
Bug: 12378680.
Change-Id: Ib0292c2733e6df90fdae480633dd9953d0016ef1
Diffstat (limited to 'soundtrigger')
-rw-r--r-- | soundtrigger/ISoundTriggerClient.cpp | 35 | ||||
-rw-r--r-- | soundtrigger/ISoundTriggerHwService.cpp | 20 | ||||
-rw-r--r-- | soundtrigger/SoundTrigger.cpp | 35 |
3 files changed, 90 insertions, 0 deletions
diff --git a/soundtrigger/ISoundTriggerClient.cpp b/soundtrigger/ISoundTriggerClient.cpp index 1d0c0ec..b0b4428 100644 --- a/soundtrigger/ISoundTriggerClient.cpp +++ b/soundtrigger/ISoundTriggerClient.cpp @@ -27,6 +27,8 @@ namespace android { enum { ON_RECOGNITION_EVENT = IBinder::FIRST_CALL_TRANSACTION, + ON_SOUNDMODEL_EVENT, + ON_SERVICE_STATE_CHANGE }; class BpSoundTriggerClient: public BpInterface<ISoundTriggerClient> @@ -47,6 +49,25 @@ public: data, &reply); } + + virtual void onSoundModelEvent(const sp<IMemory>& eventMemory) + { + Parcel data, reply; + data.writeInterfaceToken(ISoundTriggerClient::getInterfaceDescriptor()); + data.writeStrongBinder(eventMemory->asBinder()); + remote()->transact(ON_SOUNDMODEL_EVENT, + data, + &reply); + } + virtual void onServiceStateChange(const sp<IMemory>& eventMemory) + { + Parcel data, reply; + data.writeInterfaceToken(ISoundTriggerClient::getInterfaceDescriptor()); + data.writeStrongBinder(eventMemory->asBinder()); + remote()->transact(ON_SERVICE_STATE_CHANGE, + data, + &reply); + } }; IMPLEMENT_META_INTERFACE(SoundTriggerClient, @@ -65,6 +86,20 @@ status_t BnSoundTriggerClient::onTransact( onRecognitionEvent(eventMemory); return NO_ERROR; } break; + case ON_SOUNDMODEL_EVENT: { + CHECK_INTERFACE(ISoundTriggerClient, data, reply); + sp<IMemory> eventMemory = interface_cast<IMemory>( + data.readStrongBinder()); + onSoundModelEvent(eventMemory); + return NO_ERROR; + } break; + case ON_SERVICE_STATE_CHANGE: { + CHECK_INTERFACE(ISoundTriggerClient, data, reply); + sp<IMemory> eventMemory = interface_cast<IMemory>( + data.readStrongBinder()); + onServiceStateChange(eventMemory); + return NO_ERROR; + } break; default: return BBinder::onTransact(code, data, reply, flags); } diff --git a/soundtrigger/ISoundTriggerHwService.cpp b/soundtrigger/ISoundTriggerHwService.cpp index c9a0c24..05728e9 100644 --- a/soundtrigger/ISoundTriggerHwService.cpp +++ b/soundtrigger/ISoundTriggerHwService.cpp @@ -37,6 +37,7 @@ namespace android { enum { LIST_MODULES = IBinder::FIRST_CALL_TRANSACTION, ATTACH, + SET_CAPTURE_STATE, }; class BpSoundTriggerHwService: public BpInterface<ISoundTriggerHwService> @@ -90,6 +91,18 @@ public: return status; } + virtual status_t setCaptureState(bool active) + { + Parcel data, reply; + data.writeInterfaceToken(ISoundTriggerHwService::getInterfaceDescriptor()); + data.writeInt32(active); + status_t status = remote()->transact(SET_CAPTURE_STATE, data, &reply); + if (status == NO_ERROR) { + status = reply.readInt32(); + } + return status; + } + }; IMPLEMENT_META_INTERFACE(SoundTriggerHwService, "android.hardware.ISoundTriggerHwService"); @@ -140,6 +153,13 @@ status_t BnSoundTriggerHwService::onTransact( } return NO_ERROR; } break; + + case SET_CAPTURE_STATE: { + CHECK_INTERFACE(ISoundTriggerHwService, data, reply); + reply->writeInt32(setCaptureState((bool)data.readInt32())); + return NO_ERROR; + } break; + default: return BBinder::onTransact(code, data, reply, flags); } diff --git a/soundtrigger/SoundTrigger.cpp b/soundtrigger/SoundTrigger.cpp index e43acd0..0015c30 100644 --- a/soundtrigger/SoundTrigger.cpp +++ b/soundtrigger/SoundTrigger.cpp @@ -113,6 +113,16 @@ sp<SoundTrigger> SoundTrigger::attach(const sound_trigger_module_handle_t module } +status_t SoundTrigger::setCaptureState(bool active) +{ + ALOGV("setCaptureState(%d)", active); + const sp<ISoundTriggerHwService>& service = getSoundTriggerHwService(); + if (service == 0) { + return NO_INIT; + } + return service->setCaptureState(active); +} + // SoundTrigger SoundTrigger::SoundTrigger(sound_trigger_module_handle_t module, const sp<SoundTriggerCallback>& callback) @@ -192,6 +202,31 @@ void SoundTrigger::onRecognitionEvent(const sp<IMemory>& eventMemory) } } +void SoundTrigger::onSoundModelEvent(const sp<IMemory>& eventMemory) +{ + Mutex::Autolock _l(mLock); + if (eventMemory == 0 || eventMemory->pointer() == NULL) { + return; + } + + if (mCallback != 0) { + mCallback->onSoundModelEvent( + (struct sound_trigger_model_event *)eventMemory->pointer()); + } +} + +void SoundTrigger::onServiceStateChange(const sp<IMemory>& eventMemory) +{ + Mutex::Autolock _l(mLock); + if (eventMemory == 0 || eventMemory->pointer() == NULL) { + return; + } + + if (mCallback != 0) { + mCallback->onServiceStateChange( + *((sound_trigger_service_state_t *)eventMemory->pointer())); + } +} //IBinder::DeathRecipient void SoundTrigger::binderDied(const wp<IBinder>& who __unused) { |