diff options
author | Eric Laurent <elaurent@google.com> | 2019-04-05 14:20:05 -0700 |
---|---|---|
committer | Eric Laurent <elaurent@google.com> | 2019-04-05 14:20:05 -0700 |
commit | cccbc765d39c2f017d6626b4c83758d853d156ea (patch) | |
tree | 75081f9ca82641ea9d514508e04e96d2c54bf26d /services/audioflinger/Threads.cpp | |
parent | 0e5a1b3bb64d9a5d38903770e018379856401efd (diff) | |
download | frameworks_av-cccbc765d39c2f017d6626b4c83758d853d156ea.tar.gz frameworks_av-cccbc765d39c2f017d6626b4c83758d853d156ea.tar.bz2 frameworks_av-cccbc765d39c2f017d6626b4c83758d853d156ea.zip |
audio flinger: fix cross deadlock in RecordThread loop
Fix a cross deadlock between thread and effect chain mutex introduced by
commit 446f4df5.
Bug: 130044136
Test: start/stop audio capture for voice communication in 2 different apps
Change-Id: I23bdbd203476d2bc0b3d8d87ab66e1a9c00f7bcd
Diffstat (limited to 'services/audioflinger/Threads.cpp')
-rw-r--r-- | services/audioflinger/Threads.cpp | 35 |
1 files changed, 17 insertions, 18 deletions
diff --git a/services/audioflinger/Threads.cpp b/services/audioflinger/Threads.cpp index 04d62fac4c..0b203c42f6 100644 --- a/services/audioflinger/Threads.cpp +++ b/services/audioflinger/Threads.cpp @@ -7125,24 +7125,6 @@ reacquire_wakelock: ALOG_ASSERT(framesRead > 0); mFramesRead += framesRead; - if (audio_has_proportional_frames(mFormat) - && loopCount == lastLoopCountRead + 1) { - const int64_t readPeriodNs = lastIoEndNs - mLastIoEndNs; - const double jitterMs = - TimestampVerifier<int64_t, int64_t>::computeJitterMs( - {framesRead, readPeriodNs}, - {0, 0} /* lastTimestamp */, mSampleRate); - const double processMs = (lastIoBeginNs - mLastIoEndNs) * 1e-6; - - Mutex::Autolock _l(mLock); - mIoJitterMs.add(jitterMs); - mProcessTimeMs.add(processMs); - } - // update timing info. - mLastIoBeginNs = lastIoBeginNs; - mLastIoEndNs = lastIoEndNs; - lastLoopCountRead = loopCount; - #ifdef TEE_SINK (void)mTee.write((uint8_t*)mRsmpInBuffer + rear * mFrameSize, framesRead); #endif @@ -7302,6 +7284,23 @@ unlock: // enable changes in effect chain unlockEffectChains(effectChains); // effectChains doesn't need to be cleared, since it is cleared by destructor at scope end + if (audio_has_proportional_frames(mFormat) + && loopCount == lastLoopCountRead + 1) { + const int64_t readPeriodNs = lastIoEndNs - mLastIoEndNs; + const double jitterMs = + TimestampVerifier<int64_t, int64_t>::computeJitterMs( + {framesRead, readPeriodNs}, + {0, 0} /* lastTimestamp */, mSampleRate); + const double processMs = (lastIoBeginNs - mLastIoEndNs) * 1e-6; + + Mutex::Autolock _l(mLock); + mIoJitterMs.add(jitterMs); + mProcessTimeMs.add(processMs); + } + // update timing info. + mLastIoBeginNs = lastIoBeginNs; + mLastIoEndNs = lastIoEndNs; + lastLoopCountRead = loopCount; } standbyIfNotAlreadyInStandby(); |