DO NOT MERGE - AudioFlinger: Clear record buffers when starting RecordThread
Bug: 24211743
Bug: 24267152
Change-Id: I58c55e56b85067b71e4e300f947b4dfc159637ba
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 @@
// 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?