PatchPanel: fix deadlock when releasing a patch am: 34e55a460c
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/av/+/22813518
Change-Id: I0dae493c2cd994563c48aeb2e79efa0c631f8063
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
diff --git a/services/audioflinger/PatchPanel.cpp b/services/audioflinger/PatchPanel.cpp
index d25d46f..d0feba5 100644
--- a/services/audioflinger/PatchPanel.cpp
+++ b/services/audioflinger/PatchPanel.cpp
@@ -735,7 +735,11 @@
/* Disconnect a patch */
status_t AudioFlinger::PatchPanel::releaseAudioPatch(audio_patch_handle_t handle)
-{
+ //unlocks AudioFlinger::mLock when calling ThreadBase::sendReleaseAudioPatchConfigEvent
+ //to avoid deadlocks if the thread loop needs to acquire AudioFlinger::mLock
+ //before processing the release patch request.
+ NO_THREAD_SAFETY_ANALYSIS
+ {
ALOGV("%s handle %d", __func__, handle);
status_t status = NO_ERROR;
@@ -772,7 +776,9 @@
break;
}
}
+ mAudioFlinger.unlock();
status = thread->sendReleaseAudioPatchConfigEvent(removedPatch.mHalHandle);
+ mAudioFlinger.lock();
} else {
status = hwDevice->releaseAudioPatch(removedPatch.mHalHandle);
}
@@ -793,7 +799,9 @@
break;
}
}
+ mAudioFlinger.unlock();
status = thread->sendReleaseAudioPatchConfigEvent(removedPatch.mHalHandle);
+ mAudioFlinger.lock();
} break;
default:
status = BAD_VALUE;