Merge "st-hal: add asound.h for STHAL to export macros"
diff --git a/sound_trigger_hw.c b/sound_trigger_hw.c
index 1eb7f40..16eded7 100644
--- a/sound_trigger_hw.c
+++ b/sound_trigger_hw.c
@@ -838,7 +838,7 @@
* by audio capture usecase, so need to do session pause->resume
* to resume tx path.
*/
- if (!conc_allowed && stdev->session_allowed) {
+ if (!conc_allowed) {
list_for_each(p_ses_node, &stdev->sound_model_list) {
p_ses = node_to_item(p_ses_node, st_session_t, list_node);
st_session_pause(p_ses);
@@ -2558,7 +2558,8 @@
static int stdev_close(hw_device_t *device)
{
- struct sound_trigger_device *stdev = (struct sound_trigger_device *)device;
+ struct sound_trigger_device *st_device =
+ (struct sound_trigger_device *)device;
st_session_t *st_session = NULL;
struct listnode *node = NULL, *tmp_node = NULL;
int status = 0;
@@ -2567,18 +2568,18 @@
ATRACE_BEGIN("sthal: stdev_close");
pthread_mutex_lock(&stdev_init_lock);
- if (!stdev || (--stdev_ref_cnt != 0)) {
+ if (!st_device || (--stdev_ref_cnt != 0)) {
goto exit;
}
- pthread_mutex_lock(&stdev->lock);
+ pthread_mutex_lock(&st_device->lock);
sthw_extn_lpma_deinit();
- platform_stdev_deinit(stdev->platform);
- free(stdev->arm_pcm_use_cases);
- free(stdev->ape_pcm_use_cases);
- free(stdev->dev_ref_cnt);
- free(stdev->dev_enable_cnt);
- list_for_each_safe(node, tmp_node, &stdev->sound_model_list) {
+ platform_stdev_deinit(st_device->platform);
+ free(st_device->arm_pcm_use_cases);
+ free(st_device->ape_pcm_use_cases);
+ free(st_device->dev_ref_cnt);
+ free(st_device->dev_enable_cnt);
+ list_for_each_safe(node, tmp_node, &st_device->sound_model_list) {
st_session = node_to_item(node, st_session_t, list_node);
list_remove(node);
st_session_stop_lab(st_session);
@@ -2591,28 +2592,29 @@
free(st_session);
}
- pthread_mutex_unlock(&stdev->lock);
+ pthread_mutex_unlock(&st_device->lock);
hw_session_notifier_deinit();
- if (stdev->transit_to_adsp_on_playback ||
- stdev->transit_to_adsp_on_battery_charging) {
- stdev->stop_transitions_thread_loop = true;
- pthread_cond_signal(&stdev->transitions_cond);
- status = pthread_join(stdev->transitions_thread, NULL);
+ if (st_device->transit_to_adsp_on_playback ||
+ st_device->transit_to_adsp_on_battery_charging) {
+ st_device->stop_transitions_thread_loop = true;
+ pthread_cond_signal(&st_device->transitions_cond);
+ status = pthread_join(st_device->transitions_thread, NULL);
if (status)
ALOGE("%s: Error joining transitions thread. status = %d",
__func__, status);
}
- pthread_mutex_destroy(&stdev->lock);
- pthread_mutex_destroy(&stdev->ref_cnt_lock);
+ pthread_mutex_destroy(&st_device->lock);
+ pthread_mutex_destroy(&st_device->ref_cnt_lock);
free(device);
stdev = NULL;
exit:
pthread_mutex_unlock(&stdev_init_lock);
ATRACE_END();
- ALOGD("%s: Exit device=%p cnt=%d ", __func__, stdev, stdev_ref_cnt);
+ ALOGD("%s: Exit device=%p cnt=%d ", __func__, st_device,
+ stdev_ref_cnt);
return 0;
}
@@ -2854,8 +2856,11 @@
st_exec_mode_t exec_mode = 0;
sound_model_handle_t sm_handle = 0;
- if (!stdev)
+ pthread_mutex_lock(&stdev_init_lock);
+ if (!stdev) {
+ pthread_mutex_unlock(&stdev_init_lock);
return -ENODEV;
+ }
switch (event) {
case AUDIO_EVENT_PLAYBACK_STREAM_INACTIVE:
@@ -3091,6 +3096,7 @@
break;
}
+ pthread_mutex_unlock(&stdev_init_lock);
return ret;
}
diff --git a/sound_trigger_platform.c b/sound_trigger_platform.c
index f6e5374..8441659 100644
--- a/sound_trigger_platform.c
+++ b/sound_trigger_platform.c
@@ -4694,9 +4694,12 @@
num_sessions > stdev->rx_conc_max_st_ses)
concurrency_ses_allowed = false;
}
- if (concurrency_ses_allowed && stdev->conc_capture_supported) {
- if ((!stdev->conc_voice_call_supported && stdev->conc_voice_active) ||
- (!stdev->conc_voip_call_supported && stdev->conc_voip_active))
+ if (concurrency_ses_allowed) {
+ if ((!stdev->conc_capture_supported &&
+ stdev->tx_concurrency_active > 0) ||
+ (stdev->conc_capture_supported &&
+ ((!stdev->conc_voice_call_supported && stdev->conc_voice_active) ||
+ (!stdev->conc_voip_call_supported && stdev->conc_voip_active))))
concurrency_ses_allowed = false;
}
} else {
diff --git a/st_hw_common.c b/st_hw_common.c
index 3c31a2c..e0dab3d 100644
--- a/st_hw_common.c
+++ b/st_hw_common.c
@@ -3,7 +3,7 @@
* This file contains common functionality between
* sound trigger hw and sound trigger extension interface.
*
- * Copyright (c) 2016, 2018-2019, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2016, 2018-2020, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -414,27 +414,24 @@
hist_buf = (struct st_hist_buffer_info *) payload_buf;
hist_buf->version = DEFAULT_CUSTOM_CONFIG_MINOR_VERSION;
+ hist_buf->pre_roll_duration_msec = p_ses->sthw_cfg.client_req_preroll;
+
+ if (p_ses->is_generic_event &&
+ p_ses->sthw_cfg.client_req_preroll < PREROLL_LEN_WARNING)
+ ALOGW("%s: Client requested small preroll length %dms",
+ __func__, p_ses->sthw_cfg.client_req_preroll);
+
if (p_ses->sthw_cfg.client_req_hist_buf > 0) {
hist_buf->hist_buffer_duration_msec =
p_ses->sthw_cfg.client_req_hist_buf;
- hist_buf->pre_roll_duration_msec = p_ses->sthw_cfg.client_req_preroll;
- if (p_ses->is_generic_event) {
- if (p_ses->sthw_cfg.client_req_hist_buf <=
- (p_ses->sthw_cfg.client_req_preroll + KW_LEN_WARNING))
- ALOGW("%s: Client hist buf and preroll lens leave only"
- "%dms for keyword", __func__,
- (p_ses->sthw_cfg.client_req_hist_buf -
- p_ses->sthw_cfg.client_req_preroll));
-
- if (p_ses->sthw_cfg.client_req_preroll < PREROLL_LEN_WARNING)
- ALOGW("%s: Client requested small preroll length %dms",
- __func__, p_ses->sthw_cfg.client_req_preroll);
- }
+ if (p_ses->is_generic_event &&
+ p_ses->sthw_cfg.client_req_hist_buf <= KW_LEN_WARNING)
+ ALOGW("%s: Client requested small hist buf length %dms",
+ __func__, p_ses->sthw_cfg.client_req_hist_buf);
} else {
hist_buf->hist_buffer_duration_msec =
p_ses->vendor_uuid_info->kw_duration;
- hist_buf->pre_roll_duration_msec = 0;
}
ALOGD("%s: history buf duration %d, preroll %d", __func__,
hist_buf->hist_buffer_duration_msec,
diff --git a/st_session.c b/st_session.c
index a32b71d..4f6af7c 100644
--- a/st_session.c
+++ b/st_session.c
@@ -5189,17 +5189,10 @@
st_ses->sm_handle);
/*
* Device switch will not wait for buffering to finish. It will instead
- * interrupt and stop the buffering and transition to the loaded state.
- * The loaded state will then take care of the device switch.
+ * interrupt and stop the buffering and transition to the active state.
*/
hw_ses->fptrs->stop_buffering(hw_ses);
- status = stop_session(st_ses, hw_ses, false);
- if (status && !st_ses->stdev->ssr_offline_received) {
- ALOGE("%s:[%d] failed to stop session, err %d", __func__,
- st_ses->sm_handle, status);
- break;
- }
- STATE_TRANSITION(st_ses, loaded_state_fn);
+ STATE_TRANSITION(st_ses, active_state_fn);
DISPATCH_EVENT(st_ses, *ev, status);
/*
@@ -5214,7 +5207,7 @@
ST_SES_EV_DEFERRED_STOP);
stc_ses->pending_stop = false;
}
- st_ses->det_stc_ses->state = ST_STATE_LOADED;
+ st_ses->det_stc_ses->state = ST_STATE_ACTIVE;
break;
case ST_SES_EV_START: