Fix possible deadlock in MelReporter
Test: cf_x86_64_phone-userdebug should cover this path
Bug: 263462151
Change-Id: Ib97f1568fa0f12f3af318705ec9ba9523a16a971
diff --git a/services/audioflinger/MelReporter.cpp b/services/audioflinger/MelReporter.cpp
index b185959..6c783ec 100644
--- a/services/audioflinger/MelReporter.cpp
+++ b/services/audioflinger/MelReporter.cpp
@@ -60,8 +60,6 @@
return false;
}
- std::lock_guard _l(mLock);
- mUseHalSoundDoseInterface = true;
stopInternalMelComputation();
return true;
}
@@ -77,12 +75,6 @@
}
mSoundDoseManager->setHalSoundDoseInterface(nullptr);
-
- for (const auto& activePatches : mActiveMelPatches) {
- for (const auto& deviceId : activePatches.second.deviceHandles) {
- startMelComputationForNewPatch(activePatches.second.streamHandle, deviceId);
- }
- }
}
void AudioFlinger::MelReporter::onFirstRef() {
@@ -205,16 +197,9 @@
void AudioFlinger::MelReporter::stopInternalMelComputation() {
ALOGV("%s", __func__);
- std::unordered_map<audio_patch_handle_t, ActiveMelPatch> activePatchesCopy;
- {
- std::lock_guard _l(mLock);
- activePatchesCopy = mActiveMelPatches;
- mActiveMelPatches.clear();
- }
-
- for (const auto& activePatch : activePatchesCopy) {
- stopInternalMelComputationForStream(activePatch.second.streamHandle);
- }
+ std::lock_guard _l(mLock);
+ mActiveMelPatches.clear();
+ mUseHalSoundDoseInterface = true;
}
void AudioFlinger::MelReporter::stopInternalMelComputationForStream(audio_io_handle_t streamId) {