st-hal: Always reset EC ref as part of the disable usecase sequence
The reference count for echo reference is being handled in driver
layer, so in sthal each session can set and reset echo reference
independently. The issue was seen when 2 VA sessions were active
while playback was active on bluetooth headset. When a wired
headset was connected, the echo reference had to switch paths.
Previously the echo reference could only be reset from sthal once,
so the driver reference count never got back to 0 during the switch
which caused an error.
Change-Id: I45228ef4cb8aedea4c78bd349efb6931886bdc6b
diff --git a/sound_trigger_platform.c b/sound_trigger_platform.c
index 5ccdd71..1f16826 100644
--- a/sound_trigger_platform.c
+++ b/sound_trigger_platform.c
@@ -402,7 +402,6 @@
char backend_port[ST_BACKEND_PORT_NAME_MAX_SIZE];
st_codec_backend_cfg_t codec_backend_cfg;
- bool ec_ref_enabled;
char ec_ref_mixer_path[ST_MAX_LENGTH_MIXER_CONTROL];
int bad_mic_channel_index;
@@ -746,7 +745,6 @@
platform->cpe_fe_to_be_fixed = true;
platform->bad_mic_channel_index = 0;
- platform->ec_ref_enabled = false;
platform->be_dai_name_table = NULL;
platform->max_be_dai_names = 0;
platform->lpma_cfg.num_bb_ids = 0;
@@ -5472,13 +5470,12 @@
{
struct platform_data *my_data = (struct platform_data *)platform;
sound_trigger_device_t *stdev = my_data->stdev;
- struct sound_trigger_event_info event_info;
+ struct sound_trigger_event_info event_info = {{0}, 0};
if (is_ec_profile(profile_type)) {
event_info.st_ec_ref_enabled = enable;
if (enable) {
stdev->audio_hal_cb(ST_EVENT_UPDATE_ECHO_REF, &event_info);
- my_data->ec_ref_enabled = enable;
strlcpy(my_data->ec_ref_mixer_path, "echo-reference",
sizeof(my_data->ec_ref_mixer_path));
@@ -5493,15 +5490,10 @@
stdev->audio_hal_cb(ST_EVENT_UPDATE_ECHO_REF, &event_info);
/* avoid disabling echo if audio hal has enabled echo ref */
if (!stdev->audio_ec_enabled) {
- if (my_data->ec_ref_enabled) {
- ALOGD("%s: reset echo ref %s", __func__,
- my_data->ec_ref_mixer_path);
- audio_route_reset_and_update_path(stdev->audio_route,
- my_data->ec_ref_mixer_path);
- my_data->ec_ref_enabled = enable;
- } else {
- ALOGD("%s: EC Reference is already disabled", __func__);
- }
+ ALOGD("%s: reset echo ref %s", __func__,
+ my_data->ec_ref_mixer_path);
+ audio_route_reset_and_update_path(stdev->audio_route,
+ my_data->ec_ref_mixer_path);
} else {
ALOGD("%s: audio hal has already enabled EC", __func__);
}