Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit eddcf369 authored by Phil Burk's avatar Phil Burk
Browse files

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
parent 95c86600
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -166,6 +166,10 @@ aaudio_result_t AudioEndpoint::configure(const EndpointDescriptor *pEndpointDesc
                                  ? &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,