hal: Read hotword data from sound trigger hal
If the input stream is reading the hotword data, get it from sound trigger hal. Change-Id: Iebbc0bf60be3bb12d752a1c905f71e9ea14fbf46
This commit is contained in:
parent
b0d612f7f6
commit
76d2089ea9
|
@ -224,6 +224,7 @@ void audio_extn_listen_set_parameters(struct audio_device *adev,
|
|||
#define audio_extn_sound_trigger_set_parameters(adev, parms) (0)
|
||||
#define audio_extn_sound_trigger_check_and_get_session(in) (0)
|
||||
#define audio_extn_sound_trigger_stop_lab(in) (0)
|
||||
#define audio_extn_sound_trigger_read(in, buffer, bytes) (0)
|
||||
#else
|
||||
|
||||
enum st_event_type {
|
||||
|
@ -244,6 +245,8 @@ void audio_extn_sound_trigger_set_parameters(struct audio_device *adev,
|
|||
struct str_parms *parms);
|
||||
void audio_extn_sound_trigger_check_and_get_session(struct stream_in *in);
|
||||
void audio_extn_sound_trigger_stop_lab(struct stream_in *in);
|
||||
int audio_extn_sound_trigger_read(struct stream_in *in, void *buffer,
|
||||
size_t bytes);
|
||||
#endif
|
||||
|
||||
#ifndef AUXPCM_BT_ENABLED
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
/* #define LOG_NDEBUG 0 */
|
||||
#define LOG_NDDEBUG 0
|
||||
|
||||
#include <errno.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdlib.h>
|
||||
#include <dlfcn.h>
|
||||
|
@ -64,7 +65,7 @@ get_sound_trigger_info(int capture_handle)
|
|||
{
|
||||
struct sound_trigger_info *st_ses_info = NULL;
|
||||
struct listnode *node;
|
||||
ALOGD("%s: list %d capture_handle %d", __func__,
|
||||
ALOGV("%s: list empty %d capture_handle %d", __func__,
|
||||
list_empty(&st_dev->st_ses_list), capture_handle);
|
||||
list_for_each(node, &st_dev->st_ses_list) {
|
||||
st_ses_info = node_to_item(node, struct sound_trigger_info , list);
|
||||
|
@ -128,6 +129,45 @@ int audio_hw_call_back(sound_trigger_event_type_t event,
|
|||
return status;
|
||||
}
|
||||
|
||||
int audio_extn_sound_trigger_read(struct stream_in *in, void *buffer,
|
||||
size_t bytes)
|
||||
{
|
||||
int ret = -1;
|
||||
struct sound_trigger_info *st_info = NULL;
|
||||
audio_event_info_t event;
|
||||
|
||||
if (!st_dev)
|
||||
return ret;
|
||||
|
||||
if (!in->is_st_session_active) {
|
||||
ALOGE(" %s: Sound trigger is not active", __func__);
|
||||
goto exit;
|
||||
}
|
||||
if(in->standby)
|
||||
in->standby = false;
|
||||
|
||||
pthread_mutex_lock(&st_dev->lock);
|
||||
st_info = get_sound_trigger_info(in->capture_handle);
|
||||
pthread_mutex_unlock(&st_dev->lock);
|
||||
if (st_info) {
|
||||
event.u.aud_info.ses_info = &st_info->st_ses;
|
||||
event.u.aud_info.buf = buffer;
|
||||
event.u.aud_info.num_bytes = bytes;
|
||||
ret = st_dev->st_callback(AUDIO_EVENT_READ_SAMPLES, &event);
|
||||
}
|
||||
|
||||
exit:
|
||||
if (ret) {
|
||||
if (-ENETRESET == ret)
|
||||
in->is_st_session_active = false;
|
||||
memset(buffer, 0, bytes);
|
||||
ALOGV("%s: read failed status %d - sleep", __func__, ret);
|
||||
usleep((bytes * 1000000) / (audio_stream_in_frame_size((struct audio_stream_in *)in) *
|
||||
in->config.rate));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
void audio_extn_sound_trigger_stop_lab(struct stream_in *in)
|
||||
{
|
||||
int status = 0;
|
||||
|
|
|
@ -2603,22 +2603,21 @@ static ssize_t in_read(struct audio_stream_in *stream, void *buffer,
|
|||
|
||||
pthread_mutex_lock(&in->lock);
|
||||
|
||||
if (in->pcm) {
|
||||
if(SND_CARD_STATE_OFFLINE == snd_scard_state) {
|
||||
if (in->is_st_session) {
|
||||
ALOGVV(" %s: reading on st session bytes=%zu", __func__, bytes);
|
||||
/* Read from sound trigger HAL */
|
||||
audio_extn_sound_trigger_read(in, buffer, bytes);
|
||||
pthread_mutex_unlock(&in->lock);
|
||||
return bytes;
|
||||
}
|
||||
|
||||
if (in->pcm && (SND_CARD_STATE_OFFLINE == snd_scard_state)) {
|
||||
ALOGD(" %s: sound card is not active/SSR state", __func__);
|
||||
ret= -EIO;;
|
||||
goto exit;
|
||||
} else {
|
||||
if (in->is_st_session && !in->is_st_session_active) {
|
||||
ALOGD(" %s: Sound trigger is not active/SSR", __func__);
|
||||
ret= -EIO;;
|
||||
goto exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (in->standby) {
|
||||
if (!in->is_st_session) {
|
||||
pthread_mutex_lock(&adev->lock);
|
||||
if (in->usecase == USECASE_COMPRESS_VOIP_CALL)
|
||||
ret = voice_extn_compress_voip_start_input_stream(in);
|
||||
|
@ -2628,7 +2627,6 @@ static ssize_t in_read(struct audio_stream_in *stream, void *buffer,
|
|||
if (ret != 0) {
|
||||
goto exit;
|
||||
}
|
||||
}
|
||||
in->standby = 0;
|
||||
}
|
||||
|
||||
|
@ -2657,17 +2655,9 @@ static ssize_t in_read(struct audio_stream_in *stream, void *buffer,
|
|||
exit:
|
||||
/* ToDo: There may be a corner case when SSR happens back to back during
|
||||
start/stop. Need to post different error to handle that. */
|
||||
if (-ENETRESET == ret) {
|
||||
/* CPE SSR results in kernel returning ENETRESET for sound trigger
|
||||
session reading on LAB data. In this case do not set sound card state
|
||||
offline, instead mark this sound trigger session inactive to avoid
|
||||
further reading of LAB data from CPE driver. Marking the session
|
||||
inactive handles both CPE and ADSP SSR for sound trigger session */
|
||||
if (!in->is_st_session)
|
||||
if (-ENETRESET == ret)
|
||||
set_snd_card_state(adev,SND_CARD_STATE_OFFLINE);
|
||||
else
|
||||
in->is_st_session_active = false;
|
||||
}
|
||||
|
||||
pthread_mutex_unlock(&in->lock);
|
||||
|
||||
if (ret != 0) {
|
||||
|
@ -3382,7 +3372,7 @@ static size_t adev_get_input_buffer_size(const struct audio_hw_device *dev __unu
|
|||
}
|
||||
|
||||
static int adev_open_input_stream(struct audio_hw_device *dev,
|
||||
audio_io_handle_t handle __unused,
|
||||
audio_io_handle_t handle,
|
||||
audio_devices_t devices,
|
||||
struct audio_config *config,
|
||||
struct audio_stream_in **stream_in,
|
||||
|
|
Loading…
Reference in New Issue