Move AudioSystem errorCallback call out from gLock

Since the error callback ends up calling into Java,
there is a potential for a deadlock with Java code
that takes AudioSystem.class lock and calls into
native code that takes gLock in its own turn.

Bug: 152819012
Test: use audio on a phone, also
      killing native audioserver while watching YT,
      also while making cellular calls
Change-Id: Ib288ba96ae2f7b5ab36c1b0a1db4adde487d6a49
gugelfrei
Mikhail Naganov 4 years ago
parent 95ec1b8ea4
commit 69330d4c9c

@ -55,6 +55,7 @@ const sp<IAudioFlinger> AudioSystem::get_audio_flinger()
{
sp<IAudioFlinger> af;
sp<AudioFlingerClient> afc;
bool reportNoError = false;
{
Mutex::Autolock _l(gLock);
if (gAudioFlinger == 0) {
@ -70,7 +71,7 @@ const sp<IAudioFlinger> AudioSystem::get_audio_flinger()
if (gAudioFlingerClient == NULL) {
gAudioFlingerClient = new AudioFlingerClient();
} else {
reportError(NO_ERROR);
reportNoError = true;
}
binder->linkToDeath(gAudioFlingerClient);
gAudioFlinger = interface_cast<IAudioFlinger>(binder);
@ -86,6 +87,7 @@ const sp<IAudioFlinger> AudioSystem::get_audio_flinger()
af->registerClient(afc);
IPCThreadState::self()->restoreCallingIdentity(token);
}
if (reportNoError) reportError(NO_ERROR);
return af;
}

Loading…
Cancel
Save