diff options
author | Andy Hung <hunga@google.com> | 2014-09-08 11:47:24 -0700 |
---|---|---|
committer | Andy Hung <hunga@google.com> | 2014-09-08 13:37:06 -0700 |
commit | b445375f50a1a619b2d7518d32387d5ea77ceb70 (patch) | |
tree | 011f7b4e9ce5ee17d4265ed0fceebc484db3cee9 /media/libmedia/AudioSystem.cpp | |
parent | 2e97b01cecec65e690ac7da5df9433c52ff75bd8 (diff) | |
download | frameworks_av-b445375f50a1a619b2d7518d32387d5ea77ceb70.zip frameworks_av-b445375f50a1a619b2d7518d32387d5ea77ceb70.tar.gz frameworks_av-b445375f50a1a619b2d7518d32387d5ea77ceb70.tar.bz2 |
Fix potential deadlock between AudioPolicyService and AudioSystem
Bug: 17109761
Change-Id: I315c1c5066f62b05e1c13b04fae1272b5fbce977
Diffstat (limited to 'media/libmedia/AudioSystem.cpp')
-rw-r--r-- | media/libmedia/AudioSystem.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/media/libmedia/AudioSystem.cpp b/media/libmedia/AudioSystem.cpp index 3486d21..1742fbe 100644 --- a/media/libmedia/AudioSystem.cpp +++ b/media/libmedia/AudioSystem.cpp @@ -582,9 +582,13 @@ const sp<IAudioPolicyService>& AudioSystem::get_audio_policy_service() } binder->linkToDeath(gAudioPolicyServiceClient); gAudioPolicyService = interface_cast<IAudioPolicyService>(binder); - gAudioPolicyService->registerClient(gAudioPolicyServiceClient); gLock.unlock(); + // Registering the client takes the AudioPolicyService lock. + // Don't hold the AudioSystem lock at the same time. + gAudioPolicyService->registerClient(gAudioPolicyServiceClient); } else { + // There exists a benign race condition where gAudioPolicyService + // is set, but gAudioPolicyServiceClient is not yet registered. gLock.unlock(); } return gAudioPolicyService; |