diff options
author | Andy Hung <hunga@google.com> | 2015-10-13 19:55:16 +0000 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2015-10-13 19:55:16 +0000 |
commit | 403bff76dbde57fdcfce84292a5e42fa33c37842 (patch) | |
tree | 2dd1dd0197746aa4e5d4dc8ce8d783d60c9100e1 /services | |
parent | 036b6593eec6ced2f34293e8407f1cb86ae1e75f (diff) | |
parent | 4c6e77ff8e18a1551320a6b42f6a45e19dcce748 (diff) | |
download | frameworks_av-403bff76dbde57fdcfce84292a5e42fa33c37842.zip frameworks_av-403bff76dbde57fdcfce84292a5e42fa33c37842.tar.gz frameworks_av-403bff76dbde57fdcfce84292a5e42fa33c37842.tar.bz2 |
am 4c6e77ff: AudioFlinger: Clear record buffers when starting RecordThread
* commit '4c6e77ff8e18a1551320a6b42f6a45e19dcce748':
AudioFlinger: Clear record buffers when starting RecordThread
Diffstat (limited to 'services')
-rw-r--r-- | services/audioflinger/FastCapture.cpp | 4 | ||||
-rw-r--r-- | services/audioflinger/Threads.cpp | 5 |
2 files changed, 7 insertions, 2 deletions
diff --git a/services/audioflinger/FastCapture.cpp b/services/audioflinger/FastCapture.cpp index 79ac12b..1bba5f6 100644 --- a/services/audioflinger/FastCapture.cpp +++ b/services/audioflinger/FastCapture.cpp @@ -131,7 +131,9 @@ void FastCapture::onStateChange() // FIXME new may block for unbounded time at internal mutex of the heap // implementation; it would be better to have normal capture thread allocate for // us to avoid blocking here and to prevent possible priority inversion - (void)posix_memalign(&mReadBuffer, 32, frameCount * Format_frameSize(mFormat)); + size_t bufferSize = frameCount * Format_frameSize(mFormat); + (void)posix_memalign(&mReadBuffer, 32, bufferSize); + memset(mReadBuffer, 0, bufferSize); // if posix_memalign fails, will segv here. mPeriodNs = (frameCount * 1000000000LL) / mSampleRate; // 1.00 mUnderrunNs = (frameCount * 1750000000LL) / mSampleRate; // 1.75 mOverrunNs = (frameCount * 500000000LL) / mSampleRate; // 0.50 diff --git a/services/audioflinger/Threads.cpp b/services/audioflinger/Threads.cpp index f586291..71fc498 100644 --- a/services/audioflinger/Threads.cpp +++ b/services/audioflinger/Threads.cpp @@ -6932,6 +6932,7 @@ void AudioFlinger::RecordThread::readInputParameters_l() mRsmpInFrames = mFrameCount * 7; mRsmpInFramesP2 = roundup(mRsmpInFrames); free(mRsmpInBuffer); + mRsmpInBuffer = NULL; // TODO optimize audio capture buffer sizes ... // Here we calculate the size of the sliding buffer used as a source @@ -6941,7 +6942,9 @@ void AudioFlinger::RecordThread::readInputParameters_l() // The current value is higher than necessary. However it should not add to latency. // Over-allocate beyond mRsmpInFramesP2 to permit a HAL read past end of buffer - (void)posix_memalign(&mRsmpInBuffer, 32, (mRsmpInFramesP2 + mFrameCount - 1) * mFrameSize); + size_t bufferSize = (mRsmpInFramesP2 + mFrameCount - 1) * mFrameSize; + (void)posix_memalign(&mRsmpInBuffer, 32, bufferSize); + memset(mRsmpInBuffer, 0, bufferSize); // if posix_memalign fails, will segv here. // AudioRecord mSampleRate and mChannelCount are constant due to AudioRecord API constraints. // But if thread's mSampleRate or mChannelCount changes, how will that affect active tracks? |