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

Commit 50279dfc authored by Mikhail Naganov's avatar Mikhail Naganov Committed by android-build-merger
Browse files

Merge "PassthruPatchRecord: fix null timeOut case in obtainBuffer" am: 17437eb4 am: 55a5ece7

am: 5dbd7022

Change-Id: Ic852d7dff3c5577296f8366a440245a7bfbcf3b7
parents 4960fb8a 5dbd7022
Loading
Loading
Loading
Loading
+5 −5
Original line number Diff line number Diff line
@@ -2523,7 +2523,6 @@ status_t AudioFlinger::RecordThread::PassthruPatchRecord::obtainBuffer(
    if (!stream) return NO_INIT;  // If there is no stream, RecordThread is not reading.

    status_t result = NO_ERROR;
    struct timespec newTimeOut = *timeOut;
    size_t bytesRead = 0;
    {
        ATRACE_NAME("read");
@@ -2546,15 +2545,16 @@ status_t AudioFlinger::RecordThread::PassthruPatchRecord::obtainBuffer(
    ALOGW_IF(buffer->mFrameCount < bytesRead / mFrameSize,
            "Lost %zu frames obtained from HAL", bytesRead / mFrameSize - buffer->mFrameCount);
    mUnconsumedFrames = buffer->mFrameCount;
    // Correct newTimeOut by elapsed time.
    struct timespec newTimeOut;
    if (startTimeNs) {
        nsecs_t newTimeOutNs =
                audio_utils_ns_from_timespec(&newTimeOut) - (systemTime() - startTimeNs);
        // Correct the timeout by elapsed time.
        nsecs_t newTimeOutNs = audio_utils_ns_from_timespec(timeOut) - (systemTime() - startTimeNs);
        if (newTimeOutNs < 0) newTimeOutNs = 0;
        newTimeOut.tv_sec = newTimeOutNs / NANOS_PER_SECOND;
        newTimeOut.tv_nsec = newTimeOutNs - newTimeOut.tv_sec * NANOS_PER_SECOND;
        timeOut = &newTimeOut;
    }
    return PatchRecord::obtainBuffer(buffer, &newTimeOut);
    return PatchRecord::obtainBuffer(buffer, timeOut);

stream_error:
    stream->standby();