AudioFlinger: update error handling moveEffectChain_l
Remove effect from dstThread before restoring on srcThread.
Test: YT Music with effects, legacy USB Hal,
plug and unplug headset.
Bug: 202360137
Change-Id: Ib83dd838f177b3905b2ae29f2deea1c56bf85de0
diff --git a/services/audioflinger/AudioFlinger.cpp b/services/audioflinger/AudioFlinger.cpp
index 733fea4..148cfa6 100644
--- a/services/audioflinger/AudioFlinger.cpp
+++ b/services/audioflinger/AudioFlinger.cpp
@@ -4121,6 +4121,8 @@
size_t restored = 0;
if (status != NO_ERROR) {
for (const auto& effect : removed) {
+ dstThread->removeEffect_l(effect); // Note: Depending on error location, the last
+ // effect may not have been placed on dstThread.
if (srcThread->addEffect_l(effect) == NO_ERROR) {
++restored;
}