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

Commit e76d8b2a authored by Phil Burk's avatar Phil Burk Committed by android-build-merger
Browse files

Merge "aaudio: fix IsochronousClockModel drift calculation" into qt-r1-dev am: 03395f20

am: 3aa98489

Change-Id: I884fca298a02873f7891aa9059f8759c251a187b
parents 9663a5f4 3aa98489
Loading
Loading
Loading
Loading
+15 −8
Original line number Diff line number Diff line
@@ -108,17 +108,24 @@ void IsochronousClockModel::processTimestamp(int64_t framePosition, int64_t nano
    case STATE_RUNNING:
        if (nanosDelta < expectedNanosDelta) {
            // Earlier than expected timestamp.
            // This data is probably more accurate so use it.
            // or we may be drifting due to a slow HW clock.
//            ALOGD("processTimestamp() - STATE_RUNNING - %d < %d micros - EARLY",
//                 (int) (nanosDelta / 1000), (int)(expectedNanosDelta / 1000));
            // This data is probably more accurate, so use it.
            // Or we may be drifting due to a fast HW clock.
//            int microsDelta = (int) (nanosDelta / 1000);
//            int expectedMicrosDelta = (int) (expectedNanosDelta / 1000);
//            ALOGD("processTimestamp() - STATE_RUNNING - %7d < %7d so %4d micros EARLY",
//                 microsDelta, expectedMicrosDelta, (expectedMicrosDelta - microsDelta));

            setPositionAndTime(framePosition, nanoTime);
        } else if (nanosDelta > (expectedNanosDelta + mMaxLatenessInNanos)) {
            // Later than expected timestamp.
//            ALOGD("processTimestamp() - STATE_RUNNING - %d > %d + %d micros - LATE",
//                 (int) (nanosDelta / 1000), (int)(expectedNanosDelta / 1000),
//                 (int) (mMaxLatenessInNanos / 1000));
            setPositionAndTime(framePosition - mFramesPerBurst,  nanoTime - mMaxLatenessInNanos);
//            int microsDelta = (int) (nanosDelta / 1000);
//            int expectedMicrosDeadline = (int) ((expectedNanosDelta + mMaxLatenessInNanos) / 1000);
//            ALOGD("processTimestamp() - STATE_RUNNING - %7d > %7d so %4d micros LATE",
//                  microsDelta, expectedMicrosDeadline, (microsDelta - expectedMicrosDeadline));

            // When we are late it may be because of preemption in the kernel or
            //  we may be drifting due to a slow HW clock.
            setPositionAndTime(framePosition,  nanoTime - mMaxLatenessInNanos);
        }
        break;
    default: