diff options
author | Eric Laurent <elaurent@google.com> | 2016-05-18 17:04:12 -0700 |
---|---|---|
committer | Eric Laurent <elaurent@google.com> | 2016-05-18 17:04:12 -0700 |
commit | 44670b3920c87cc3c0391febe39fb14f9d4b4b00 (patch) | |
tree | 8496598719e074df0d6018e896cf7be9af3ccc5b | |
parent | 697c02d4308a230db9b292306e3c4a1ba2d68383 (diff) | |
download | flounder-44670b3920c87cc3c0391febe39fb14f9d4b4b00.tar.gz |
sound trigger HAL: fix callback locking
Do not hold a mutex when calling recognition callback
Bug: 28823662
Change-Id: I66b7b9c997b6b06c6ae13e39d44803e749ffbae9
-rw-r--r-- | audio/soundtrigger/sound_trigger_hw.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/audio/soundtrigger/sound_trigger_hw.c b/audio/soundtrigger/sound_trigger_hw.c index 26fe22f..b885822 100644 --- a/audio/soundtrigger/sound_trigger_hw.c +++ b/audio/soundtrigger/sound_trigger_hw.c @@ -306,11 +306,17 @@ static void *callback_thread_loop(void *context) event = (struct sound_trigger_phrase_recognition_event *) sound_trigger_event_alloc(stdev); if (event) { + recognition_callback_t callback = stdev->recognition_callback; + void *cookie = stdev->recognition_cookie; + stdev->is_streaming = 1; ALOGI("%s send callback model %d", __func__, stdev->model_handle); - stdev->recognition_callback(&event->common, - stdev->recognition_cookie); + pthread_mutex_unlock(&stdev->lock); + if (callback != NULL) { + callback(&event->common, cookie); + } + pthread_mutex_lock(&stdev->lock); free(event); // Start reading data from the DSP while the upper levels do their thing. if (stdev->config && stdev->config->capture_requested) { |