CRAS: apm_list - Make echo ref tracking more reliable
Below changes are made to ensure the echo ref tracking is reliable
in apm_list regardless of how the device enable/disable events
come from cras_iodev_list.
- If APM rmod already tracking the same iodev as echo ref, don't
bother configure it again.
- If APM rmod was tracking another iodev, configure its dsp pipeline
so it no longer points back to APM rmod.
BUG=chromium:970165
TEST=Use appr.tc with BT headset.
Change-Id: If6d4af247d5d8b1450cc861bcc97e264e5e5c013
Reviewed-on: https://chromium-review.googlesource.com/1647215
Commit-Ready: Hsinyu Chao <hychao@chromium.org>
Tested-by: Hsinyu Chao <hychao@chromium.org>
Legacy-Commit-Queue: Commit Bot <commit-bot@chromium.org>
Reviewed-by: Cheng-Yi Chiang <cychiang@chromium.org>
diff --git a/cras/src/server/cras_apm_list.c b/cras/src/server/cras_apm_list.c
index f24172b..ce62edc 100644
--- a/cras/src/server/cras_apm_list.c
+++ b/cras/src/server/cras_apm_list.c
@@ -356,6 +356,17 @@
return;
echo_ref = get_echo_reference_target(iodev);
+
+ /* If rmodule is already tracking echo_ref, do nothing. */
+ if (rmodule->odev == echo_ref)
+ return;
+
+ /* Detach from the old iodev that rmodule was tracking. */
+ if (rmodule->odev) {
+ cras_iodev_set_ext_dsp_module(rmodule->odev, NULL);
+ rmodule->odev = NULL;
+ }
+
rmodule->odev = echo_ref;
cras_iodev_set_ext_dsp_module(echo_ref, &rmodule->ext);
}