summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCarter Hsu <carterhsu@google.com>2019-06-12 21:36:14 +0800
committerCarter Hsu <carterhsu@google.com>2019-06-13 09:47:10 +0800
commit968d681ff5dea0f360c94474bdaf014fdd982dc8 (patch)
tree79a090807abb33f1215f4b3de3415f13daa2190e
parent3ff768954a8d1ac1effc3a745f842b231f58a93c (diff)
downloadandroid_hardware_qcom_audio-968d681ff5dea0f360c94474bdaf014fdd982dc8.tar.gz
android_hardware_qcom_audio-968d681ff5dea0f360c94474bdaf014fdd982dc8.tar.bz2
android_hardware_qcom_audio-968d681ff5dea0f360c94474bdaf014fdd982dc8.zip
audio: set hotword input for soundtrigger only
The sound_trigger session might have been paused while soundtrigger client starts to record. In this corner case, this input won't be detected as soundtrigger input in audio HAL since the st_session handle has been removed because the st_session is in pause state. Then soundtrigger input will try to open pcm driver and act as normal audio record, it will cause race condition on pcm node. To fix this, set the input with AUDIO_INPUT_FLAG_HW_HOTWORD flag to be always soundtrigger input. Bug: 135059114 Test: hotword/music detection works Change-Id: I4475bfb1d3e2c9b998c583e9244c0aa4f07b2134 Signed-off-by: Carter Hsu <carterhsu@google.com>
-rw-r--r--hal/audio_hw.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/hal/audio_hw.c b/hal/audio_hw.c
index 5d611c6b..34fafe7c 100644
--- a/hal/audio_hw.c
+++ b/hal/audio_hw.c
@@ -4107,7 +4107,7 @@ static int in_standby(struct audio_stream *stream)
lock_input_stream(in);
- if (!in->standby && in->is_st_session) {
+ if (!in->standby && (in->flags & AUDIO_INPUT_FLAG_HW_HOTWORD)) {
ALOGV("%s: sound trigger pcm stop lab", __func__);
audio_extn_sound_trigger_stop_lab(in);
in->standby = true;
@@ -4347,7 +4347,7 @@ static ssize_t in_read(struct audio_stream_in *stream, void *buffer,
const size_t frame_size = audio_stream_in_frame_size(stream);
const size_t frames = bytes / frame_size;
- if (in->is_st_session) {
+ if (in->flags & AUDIO_INPUT_FLAG_HW_HOTWORD) {
ALOGVV(" %s: reading on st session bytes=%zu", __func__, bytes);
/* Read from sound trigger HAL */
audio_extn_sound_trigger_read(in, buffer, bytes);
@@ -4460,7 +4460,7 @@ static int in_get_capture_position(const struct audio_stream_in *stream,
// on standby. Therefore, we may return an error even though the
// pcm stream is still opened.
if (in->standby) {
- ALOGE_IF(in->pcm != NULL && !in->is_st_session,
+ ALOGE_IF(in->pcm != NULL && !(in->flags & AUDIO_INPUT_FLAG_HW_HOTWORD),
"%s stream in standby but pcm not NULL for non ST session", __func__);
goto exit;
}
@@ -6077,6 +6077,9 @@ static int adev_open_input_stream(struct audio_hw_device *dev,
get sound trigger pcm if present */
audio_extn_sound_trigger_check_and_get_session(in);
+ if (in->is_st_session)
+ in->flags |= AUDIO_INPUT_FLAG_HW_HOTWORD;
+
lock_input_stream(in);
audio_extn_snd_mon_register_listener(in, in_snd_mon_cb);
pthread_mutex_lock(&adev->lock);