question: private void maybeSampleSyncParams ( ) { long playbackPositionUs = audioTrackUtil . getPlaybackHeadPositionUs ( ) ; if ( playbackPositionUs == 0 ) { return ; } long systemClockUs = System . nanoTime ( ) / 1000 ; if ( systemClockUs - lastPlayheadSampleTimeUs >= MIN_PLAYHEAD_OFFSET_SAMPLE_INTERVAL_US ) { playheadOffsets [ nextPlayheadOffsetIndex ] = playbackPositionUs - systemClockUs ; nextPlayheadOffsetIndex = ( nextPlayheadOffsetIndex + 1 ) % MAX_PLAYHEAD_OFFSET_COUNT ; if ( playheadOffsetCount < MAX_PLAYHEAD_OFFSET_COUNT ) { playheadOffsetCount ++ ; } lastPlayheadSampleTimeUs = systemClockUs ; smoothedPlayheadOffsetUs = 0 ; for ( int i = 0 ; i < playheadOffsetCount ; i ++ ) { smoothedPlayheadOffsetUs += playheadOffsets [ i ] / playheadOffsetCount ; } } if ( ! isPassthrough ( ) && systemClockUs - lastTimestampSampleTimeUs >= MIN_TIMESTAMP_SAMPLE_INTERVAL_US ) { audioTimestampSet = audioTrackUtil . updateTimestamp ( ) ; if ( audioTimestampSet ) { long audioTimestampUs = audioTrackUtil . getTimestampNanoTime ( ) / 1000 ; long audioTimestampFramePosition = audioTrackUtil . getTimestampFramePosition ( ) ; if ( audioTimestampUs < resumeSystemTimeUs ) { audioTimestampSet = false ; } else if ( Math . abs ( audioTimestampUs - systemClockUs ) > MAX_AUDIO_TIMESTAMP_OFFSET_US ) { String message = "Spurious audio timestamp (system clock mismatch): " + audioTimestampFramePosition + ", " + audioTimestampUs + ", " + systemClockUs + ", " + playbackPositionUs ; if ( failOnSpuriousAudioTimestamp ) { throw new InvalidAudioTrackTimestampException ( message ) ; } Log . w ( TAG , message ) ; audioTimestampSet = false ; } else if ( Math . abs ( framesToDurationUs ( audioTimestampFramePosition ) - playbackPositionUs ) > MAX_AUDIO_TIMESTAMP_OFFSET_US ) { String message = "Spurious audio timestamp (frame position mismatch): " + audioTimestampFramePosition + ", " + audioTimestampUs + ", " + systemClockUs + ", " + playbackPositionUs ; if ( failOnSpuriousAudioTimestamp ) { throw new InvalidAudioTrackTimestampException ( message ) ; } Log . w ( TAG , message ) ; audioTimestampSet = false ; } } if ( getLatencyMethod != null ) { try { latencyUs = ( Integer ) getLatencyMethod . invoke ( audioTrack , ( Object [ ] ) null ) * 1000L - framesToDurationUs ( bytesToFrames ( bufferSize ) ) ; latencyUs = Math . max ( latencyUs , 0 ) ; if ( latencyUs > MAX_LATENCY_US ) { Log . w ( TAG , "Ignoring impossibly large audio latency: " + latencyUs ) ; latencyUs = 0 ; } } catch ( Exception e ) { getLatencyMethod = null ; } } lastTimestampSampleTimeUs = systemClockUs ; } }
target:  Updates the audio track latency and playback position parameters.