summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndy Hung <hunga@google.com>2015-09-24 16:36:56 -0700
committerAndy Hung <hunga@google.com>2015-09-24 16:49:57 -0700
commit8c987fa71326eb0cc504959a5ebb440410d73180 (patch)
tree5d7b75a17bf736d15f95880a06b564f03cd03ee1
parenta8f90d57f5b3ad4ef7194501aa20f0a0bd903e8f (diff)
downloadframeworks_av-8c987fa71326eb0cc504959a5ebb440410d73180.zip
frameworks_av-8c987fa71326eb0cc504959a5ebb440410d73180.tar.gz
frameworks_av-8c987fa71326eb0cc504959a5ebb440410d73180.tar.bz2
DO NOT MERGE - AudioFlinger: Clear record buffers when starting RecordThread
Bug: 24211743 Bug: 24267152 Change-Id: I58c55e56b85067b71e4e300f947b4dfc159637ba
-rw-r--r--services/audioflinger/FastCapture.cpp1
-rw-r--r--services/audioflinger/Threads.cpp4
2 files changed, 4 insertions, 1 deletions
diff --git a/services/audioflinger/FastCapture.cpp b/services/audioflinger/FastCapture.cpp
index 0c9b976..9613e26 100644
--- a/services/audioflinger/FastCapture.cpp
+++ b/services/audioflinger/FastCapture.cpp
@@ -134,6 +134,7 @@ void FastCapture::onStateChange()
unsigned channelCount = Format_channelCount(format);
// FIXME frameSize
readBuffer = new short[frameCount * channelCount];
+ memset(readBuffer, 0, frameCount * channelCount * sizeof(readBuffer[0]));
periodNs = (frameCount * 1000000000LL) / sampleRate; // 1.00
underrunNs = (frameCount * 1750000000LL) / sampleRate; // 1.75
overrunNs = (frameCount * 500000000LL) / sampleRate; // 0.50
diff --git a/services/audioflinger/Threads.cpp b/services/audioflinger/Threads.cpp
index b429cc2..63feeaa 100644
--- a/services/audioflinger/Threads.cpp
+++ b/services/audioflinger/Threads.cpp
@@ -6136,7 +6136,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
- mRsmpInBuffer = new int16_t[(mRsmpInFramesP2 + mFrameCount - 1) * mChannelCount];
+ size_t bufferSizeInShorts = (mRsmpInFramesP2 + mFrameCount - 1) * mChannelCount;
+ mRsmpInBuffer = new int16_t[bufferSizeInShorts];
+ memset(mRsmpInBuffer, 0, bufferSizeInShorts * sizeof(mRsmpInBuffer[0]));
// 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?