summaryrefslogtreecommitdiffstats
path: root/services
diff options
context:
space:
mode:
authorEric Laurent <elaurent@google.com>2014-05-27 16:51:59 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2014-05-27 16:51:59 +0000
commit1a83b736737e7f625371093519ff7a10b05e0c63 (patch)
treeaee16dba2767384169737f82d07435dcf1bb6669 /services
parent5912117110ae6efadd862fcb0e395fdcd18aa00c (diff)
parentfe1a94e68e173fe4dfe7699112422a94eddacb4e (diff)
downloadframeworks_av-1a83b736737e7f625371093519ff7a10b05e0c63.zip
frameworks_av-1a83b736737e7f625371093519ff7a10b05e0c63.tar.gz
frameworks_av-1a83b736737e7f625371093519ff7a10b05e0c63.tar.bz2
Merge "audioflinger: fix deadlock upon AudioRecord creation error"
Diffstat (limited to 'services')
-rw-r--r--services/audioflinger/AudioFlinger.cpp23
1 files changed, 18 insertions, 5 deletions
diff --git a/services/audioflinger/AudioFlinger.cpp b/services/audioflinger/AudioFlinger.cpp
index 68fa553..9bd0e9b 100644
--- a/services/audioflinger/AudioFlinger.cpp
+++ b/services/audioflinger/AudioFlinger.cpp
@@ -635,8 +635,12 @@ sp<IAudioTrack> AudioFlinger::createTrack(
if (lStatus != NO_ERROR) {
// remove local strong reference to Client before deleting the Track so that the
// Client destructor is called by the TrackBase destructor with mClientLock held
- Mutex::Autolock _cl(mClientLock);
- client.clear();
+ // Don't hold mClientLock when releasing the reference on the track as the
+ // destructor will acquire it.
+ {
+ Mutex::Autolock _cl(mClientLock);
+ client.clear();
+ }
track.clear();
goto Exit;
}
@@ -1173,7 +1177,7 @@ void AudioFlinger::registerClient(const sp<IAudioFlingerClient>& client)
}
// mClientLock should not be held here because ThreadBase::sendIoConfigEvent() will lock the
- // ThreadBase mutex and teh locknig order is ThreadBase::mLock then AudioFlinger::mClientLock.
+ // ThreadBase mutex and the locking order is ThreadBase::mLock then AudioFlinger::mClientLock.
if (clientAdded) {
// the config change is always sent from playback or record threads to avoid deadlock
// with AudioSystem::gLock
@@ -1419,8 +1423,12 @@ sp<IAudioRecord> AudioFlinger::openRecord(
if (lStatus != NO_ERROR) {
// remove local strong reference to Client before deleting the RecordTrack so that the
// Client destructor is called by the TrackBase destructor with mClientLock held
- Mutex::Autolock _cl(mClientLock);
- client.clear();
+ // Don't hold mClientLock when releasing the reference on the track as the
+ // destructor will acquire it.
+ {
+ Mutex::Autolock _cl(mClientLock);
+ client.clear();
+ }
recordTrack.clear();
goto Exit;
}
@@ -2380,6 +2388,11 @@ sp<IEffect> AudioFlinger::createEffect(
if (handle != 0 && id != NULL) {
*id = handle->id();
}
+ if (handle == 0) {
+ // remove local strong reference to Client with mClientLock held
+ Mutex::Autolock _cl(mClientLock);
+ client.clear();
+ }
}
Exit: