/** * Accepts the timestamp last polled in {@link #maybePollTimestamp(long)}. If the instance is in * the error state, it will begin to poll timestamps frequently again. */ public void acceptTimestamp() { if (state == STATE_ERROR) { reset(); } }
/** Starts position tracking. Must be called immediately before {@link AudioTrack#play()}. */ public void start() { Assertions.checkNotNull(audioTimestampPoller).reset(); }
/** * Creates a new audio timestamp poller. * * @param audioTrack The audio track that will provide timestamps, if the platform supports it. */ public AudioTimestampPoller(AudioTrack audioTrack) { if (Util.SDK_INT >= 19) { audioTimestamp = new AudioTimestampV19(audioTrack); reset(); } else { audioTimestamp = null; updateState(STATE_NO_TIMESTAMP); } }
/** * Pauses the audio track position tracker, returning whether the audio track needs to be paused * to cause playback to pause. If {@code false} is returned the audio track will pause without * further interaction, as the end of stream has been handled. */ public boolean pause() { resetSyncParams(); if (stopTimestampUs == C.TIME_UNSET) { // The audio track is going to be paused, so reset the timestamp poller to ensure it doesn't // supply an advancing position. Assertions.checkNotNull(audioTimestampPoller).reset(); return true; } // We've handled the end of the stream already, so there's no need to pause the track. return false; }