AudioSystem: fix cross deadlock
Do not hold gLockAPS when calling
AudioPolicyService::registerClient() in get_audio_policy_service().
registerClient() will need to acquire the AudioPolicyService mutex and
if at the same time a method called from AudioPolicyService
(with mutex held) calls back into AudioSystem and get_audio_policy_service()
a cross deadlock occurs.
Same preventive fix for get_audio_flinger().
Use a separate mutex for notification client list in AudioPolicyService.
This prevents deadlocking if registerClient() is called as a consequence of
AudioFlinger calling back into AudioPolicyManager while executing a method
with AudioPolicyService locked
Bug: 18403952.
Bug: 18450065.
Change-Id: Ia832e41aede8bc6c843fc615508fbdd74e0863b5
diff --git a/include/media/AudioSystem.h b/include/media/AudioSystem.h
index d54eca7..1614525 100644
--- a/include/media/AudioSystem.h
+++ b/include/media/AudioSystem.h
@@ -90,7 +90,7 @@
static void setErrorCallback(audio_error_callback cb);
// helper function to obtain AudioFlinger service handle
- static const sp<IAudioFlinger>& get_audio_flinger();
+ static const sp<IAudioFlinger> get_audio_flinger();
static float linearToLog(int volume);
static int logToLinear(float volume);
@@ -270,7 +270,7 @@
// and output configuration cache (gOutputs)
static void clearAudioConfigCache();
- static const sp<IAudioPolicyService>& get_audio_policy_service();
+ static const sp<IAudioPolicyService> get_audio_policy_service();
// helpers for android.media.AudioManager.getProperty(), see description there for meaning
static uint32_t getPrimaryOutputSamplingRate();