Skip to content

Commit

Permalink
CRAS: ensure node deactivation in |switch_profile|
Browse files Browse the repository at this point in the history
In previous commit CL:5029139 we noticed that |update_active_node| may
not be called by the main thread, and that may cause issues when there
is a profile-switch.

In this CL, we ensure that the nodes are deactivated after the iodevs
are closed in |profile_switch|.

BUG=b:309536124,b:307228349
TEST=profile-switch 257 times

Cq-Depend: chromium:5029139
Change-Id: Ib1c223d8aa383ea0827b0e363da38cccf987ee9e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/adhd/+/5075268
Commit-Queue: Jeremy Wu <jrwu@google.com>
Reviewed-by: Hsinyu Chao <hychao@chromium.org>
Tested-by: chromeos-cop-builder@chromeos-cop.iam.gserviceaccount.com <chromeos-cop-builder@chromeos-cop.iam.gserviceaccount.com>
  • Loading branch information
Jeremy Wu authored and Chromeos LUCI committed Dec 1, 2023
1 parent f5a49ed commit befac12
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions cras/src/server/cras_bt_policy.c
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,10 @@ static void switch_profile(struct bt_io_manager* mgr) {
cras_iodev_list_suspend_dev(iodev->info.idx);
}

// |is_profile_switching| is critical and has several implications worth
// noting: Before this toggle, close/suspend btio won't trigger an unexpected
// profile switch request. After this toggle, btio update_active_node would
// trigger the reroute to desired profile dev.
mgr->is_profile_switching = false;

for (dir = 0; dir < CRAS_NUM_DIRECTIONS; dir++) {
Expand All @@ -138,6 +142,8 @@ static void switch_profile(struct bt_io_manager* mgr) {
continue;
}

iodev->update_active_node(iodev, 0, 0);

/* If the iodev was active or this profile switching is
* triggered at opening iodev, add it to active dev list.
* However for the output iodev, adding it back to active dev
Expand Down

0 comments on commit befac12

Please sign in to comment.