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

Commit ed61ffb1 authored by Andy Hung's avatar Andy Hung Committed by android-build-merger
Browse files

Merge \"Limit cached timestamp use if HW fails to provide them\" into nyc-dev

am: 0256917c

Change-Id: Ia0c7b61ec235f277f0266dac3320d25cdfeba4f0
parents b8ef3dc5 0256917c
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -2374,9 +2374,14 @@ status_t AudioTrack::getTimestamp(AudioTimestamp& timestamp)
                if (location == ExtendedTimestamp::LOCATION_SERVER) {
                    ALOGW_IF(mPreviousLocation == ExtendedTimestamp::LOCATION_KERNEL,
                            "getTimestamp() location moved from kernel to server");
                    // check that the last kernel OK time info exists and the positions
                    // are valid (if they predate the current track, the positions may
                    // be zero or negative).
                    const int64_t frames =
                            (ets.mTimeNs[ExtendedTimestamp::LOCATION_SERVER_LASTKERNELOK] < 0 ||
                            ets.mTimeNs[ExtendedTimestamp::LOCATION_KERNEL_LASTKERNELOK] < 0)
                            ets.mTimeNs[ExtendedTimestamp::LOCATION_KERNEL_LASTKERNELOK] < 0 ||
                            ets.mPosition[ExtendedTimestamp::LOCATION_SERVER_LASTKERNELOK] <= 0 ||
                            ets.mPosition[ExtendedTimestamp::LOCATION_KERNEL_LASTKERNELOK] <= 0)
                            ?
                            int64_t((double)mAfLatency * mSampleRate * mPlaybackRate.mSpeed
                                    / 1000)
+4 −2
Original line number Diff line number Diff line
@@ -482,8 +482,6 @@ void FastMixer::onWork()
            } else {
                // HAL reported that more frames were presented than were written
                mNativeFramesWrittenButNotPresented = 0;
                mTimestamp.mPosition[ExtendedTimestamp::LOCATION_KERNEL] = 0;
                mTimestamp.mTimeNs[ExtendedTimestamp::LOCATION_KERNEL] = -1;
                status = INVALID_OPERATION;
            }
        }
@@ -494,6 +492,10 @@ void FastMixer::onWork()
            // fetch server time if we can't get timestamp
            mTimestamp.mTimeNs[ExtendedTimestamp::LOCATION_SERVER] =
                    systemTime(SYSTEM_TIME_MONOTONIC);
            // clear out kernel cached position as this may get rapidly stale
            // if we never get a new valid timestamp
            mTimestamp.mPosition[ExtendedTimestamp::LOCATION_KERNEL] = 0;
            mTimestamp.mTimeNs[ExtendedTimestamp::LOCATION_KERNEL] = -1;
        }
    }
}