AudioFlinger: Ensure RecordTrack dtor called outside lock
Test: atest AudioRecordTest
Bug: 329604636
Merged-In: I424459debe8fef4bdb5e112ff71d5383d4ff555f
Change-Id: I424459debe8fef4bdb5e112ff71d5383d4ff555f
diff --git a/services/audioflinger/Threads.cpp b/services/audioflinger/Threads.cpp
index 9bbddf6..dc90ef5 100644
--- a/services/audioflinger/Threads.cpp
+++ b/services/audioflinger/Threads.cpp
@@ -8194,6 +8194,7 @@
for (int64_t loopCount = 0;; ++loopCount) { // loopCount used for statistics tracking
// Note: these sp<> are released at the end of the for loop outside of the mutex() lock.
sp<IAfRecordTrack> activeTrack;
+ std::vector<sp<IAfRecordTrack>> oldActiveTracks;
Vector<sp<IAfEffectChain>> effectChains;
// activeTracks accumulates a copy of a subset of mActiveTracks
@@ -8243,7 +8244,9 @@
bool doBroadcast = false;
bool allStopped = true;
for (size_t i = 0; i < size; ) {
-
+ if (activeTrack) { // ensure track release is outside lock.
+ oldActiveTracks.emplace_back(std::move(activeTrack));
+ }
activeTrack = mActiveTracks[i];
if (activeTrack->isTerminated()) {
if (activeTrack->isFastTrack()) {