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

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

aaudio: fix detection of input overflows

Was incorrectly looking at the buffer size instead of the buffer
capacity.

Test: OboeTester ECHO INPUT to OUTPUT
Test: set Input margin to 4
Test: XRun# for input should stay at zero
Bug: 141700208
Change-Id: I21ecdac19f5361a1b33f4dc2aaec170de9e28fc6
parent 3b93ca58
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -106,9 +106,10 @@ aaudio_result_t AudioStreamInternalCapture::processDataNow(void *buffer, int32_t
        mNeedCatchUp.acknowledge();
    }

    // If the write index passed the read index then consider it an overrun.
    // If the capture buffer is full beyond capacity then consider it an overrun.
    // For shared streams, the xRunCount is passed up from the service.
    if (mAudioEndpoint.isFreeRunning() && mAudioEndpoint.getEmptyFramesAvailable() < 0) {
    if (mAudioEndpoint.isFreeRunning()
        && mAudioEndpoint.getFullFramesAvailable() > mAudioEndpoint.getBufferCapacityInFrames()) {
        mXRunCount++;
        if (ATRACE_ENABLED()) {
            ATRACE_INT("aaOverRuns", mXRunCount);