From 4c6288cb9b32ef4718294dc672e0617c47d8a5e7 Mon Sep 17 00:00:00 2001 From: Terry Cheong Date: Wed, 25 Sep 2024 17:33:31 +0800 Subject: [PATCH] floop: close output iodev when no stream attached Remember to close the floop internal device when all streams are removed. BUG=b:362679648 TEST=stop audio stream when recording from floop device \ output floop device should be closed Change-Id: Ia3bf98e5a17278e859bb51589f9380301431eeca Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/adhd/+/5890787 Reviewed-by: Yu-Hsuan Hsu Commit-Queue: Terry Cheong Tested-by: chromeos-cop-builder@chromeos-cop.iam.gserviceaccount.com Reviewed-by: Li-Yu Yu --- cras/src/server/cras_iodev_list.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/cras/src/server/cras_iodev_list.c b/cras/src/server/cras_iodev_list.c index 61897dabb..642ec52b0 100644 --- a/cras/src/server/cras_iodev_list.c +++ b/cras/src/server/cras_iodev_list.c @@ -1435,6 +1435,17 @@ static int possibly_close_enabled_devs(enum CRAS_STREAM_DIRECTION dir) { idle_dev_check(NULL, NULL); } + // Flexible loopback (internal) devices are not enabled + // and should not have pinned streams. + if (dir == CRAS_STREAM_OUTPUT) { + struct cras_floop_pair* fpair; + DL_FOREACH (floop_pair_list, fpair) { + if (cras_iodev_is_open(&fpair->output)) { + cras_iodev_list_disable_floop_pair(fpair); + } + } + } + return 0; }