aaudio: clear data buffer before use
Just in case the HAL did not clear it.
This can prevent initial glitches on devices where the HAL
does not clear the buffer.
Bug: 186302619
Test: atest CtsNativeMediaAAudioTestCases
Change-Id: I2f437628adc81bcf8673494bc26d28a4dc5a03a0
diff --git a/media/libaaudio/src/client/AudioEndpoint.cpp b/media/libaaudio/src/client/AudioEndpoint.cpp
index 0a19d17..ebc9f2b 100644
--- a/media/libaaudio/src/client/AudioEndpoint.cpp
+++ b/media/libaaudio/src/client/AudioEndpoint.cpp
@@ -166,6 +166,10 @@
? &mDataWriteCounter
: descriptor->writeCounterAddress;
+ // Clear buffer to avoid an initial glitch on some devices.
+ size_t bufferSizeBytes = descriptor->capacityInFrames * descriptor->bytesPerFrame;
+ memset(descriptor->dataAddress, 0, bufferSizeBytes);
+
mDataQueue = std::make_unique<FifoBufferIndirect>(
descriptor->bytesPerFrame,
descriptor->capacityInFrames,