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

Commit 082afd2c authored by Glenn Kasten's avatar Glenn Kasten Committed by android-build-merger
Browse files

Merge "RecordThread: Immediate retry on audio read overrun" into pi-dev

am: 0f59472e

Change-Id: Ie8e8ae7c3b8081067b210a582532b2fe5ec2a3d1
parents 12649522 0f59472e
Loading
Loading
Loading
Loading
+11 −2
Original line number Diff line number Diff line
@@ -6603,8 +6603,17 @@ reacquire_wakelock:
        if (mPipeSource != 0) {
            size_t framesToRead = mBufferSize / mFrameSize;
            framesToRead = min(mRsmpInFramesOA - rear, mRsmpInFramesP2 / 2);

            // The audio fifo read() returns OVERRUN on overflow, and advances the read pointer
            // to the full buffer point (clearing the overflow condition).  Upon OVERRUN error,
            // we immediately retry the read() to get data and prevent another overflow.
            for (int retries = 0; retries <= 2; ++retries) {
                ALOGW_IF(retries > 0, "overrun on read from pipe, retry #%d", retries);
                framesRead = mPipeSource->read((uint8_t*)mRsmpInBuffer + rear * mFrameSize,
                        framesToRead);
                if (framesRead != OVERRUN) break;
            }

            // since pipe is non-blocking, simulate blocking input by waiting for 1/2 of
            // buffer size or at least for 20ms.
            size_t sleepFrames = max(