AudioSystem: Add mutex for output cache
Fix cross deadlock with AudioFlinger by adding
a dedicated mutex to protect access to cached output list
and parameters.
Bug: 18410728.
Change-Id: Ia31283b1972d8865a46e84e63695173c187eb781
diff --git a/include/media/AudioSystem.h b/include/media/AudioSystem.h
index f3b7fbb..d54eca7 100644
--- a/include/media/AudioSystem.h
+++ b/include/media/AudioSystem.h
@@ -373,10 +373,11 @@
friend class AudioFlingerClient;
friend class AudioPolicyServiceClient;
- static Mutex gLock; // protects all members except gAudioPolicyService,
- // gAudioPolicyServiceClient, and gAudioPortCallback
- static Mutex gLockAPS; // protects gAudioPolicyService and gAudioPolicyServiceClient
- static Mutex gLockAPC; // protects gAudioPortCallback
+ static Mutex gLock; // protects gAudioFlinger and gAudioErrorCallback,
+ static Mutex gLockCache; // protects gOutputs, gPrevInSamplingRate, gPrevInFormat,
+ // gPrevInChannelMask and gInBuffSize
+ static Mutex gLockAPS; // protects gAudioPolicyService and gAudioPolicyServiceClient
+ static Mutex gLockAPC; // protects gAudioPortCallback
static sp<IAudioFlinger> gAudioFlinger;
static audio_error_callback gAudioErrorCallback;