From 6cb07adcee5c818b1b1701618557487d13855974 Mon Sep 17 00:00:00 2001 From: andrewlewis Date: Tue, 27 Mar 2018 01:18:05 -0700 Subject: [PATCH] Fix handling of timestamps before play() If the AudioTimestamp was sampled before play() was called, it was incorrectly returned to the caller for sanity-checking. Fix this behavior by dropping the timestamp internally in the AudioTimestampPoller. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=190584412 --- .../exoplayer2/audio/AudioTimestampPoller.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/library/core/src/main/java/com/google/android/exoplayer2/audio/AudioTimestampPoller.java b/library/core/src/main/java/com/google/android/exoplayer2/audio/AudioTimestampPoller.java index b27ad6499b..47120e7375 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/audio/AudioTimestampPoller.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/audio/AudioTimestampPoller.java @@ -121,11 +121,15 @@ import java.lang.annotation.RetentionPolicy; boolean updatedTimestamp = audioTimestamp.maybeUpdateTimestamp(); switch (state) { case STATE_INITIALIZING: - if (updatedTimestamp - && audioTimestamp.getTimestampSystemTimeUs() >= initializeSystemTimeUs) { - // We have an initial timestamp, but don't know if it's advancing yet. - initialTimestampPositionFrames = audioTimestamp.getTimestampPositionFrames(); - updateState(STATE_TIMESTAMP); + if (updatedTimestamp) { + if (audioTimestamp.getTimestampSystemTimeUs() >= initializeSystemTimeUs) { + // We have an initial timestamp, but don't know if it's advancing yet. + initialTimestampPositionFrames = audioTimestamp.getTimestampPositionFrames(); + updateState(STATE_TIMESTAMP); + } else { + // Drop the timestamp, as it was sampled before the last reset. + updatedTimestamp = false; + } } else if (systemTimeUs - initializeSystemTimeUs > INITIALIZING_DURATION_US) { // We haven't received a timestamp for a while, so they probably aren't available for the // current audio route. Poll infrequently in case the route changes later.