title: How to use AudioTrack.getTimestamp() on Android to calculate latency?
body: <p>I see many resources recommending that <code>AudioTrack.getTimestamp()</code> be used on modern Android versions to calculate audio latency for audio/video sync. </p>
  
  <p>For instance:</p>
  
  <p><a href="https://stackoverflow.com/a/37625791/332798">https://stackoverflow.com/a/37625791/332798</a></p>
  
  <p><a href="https://developer.amazon.com/docs/fire-tv/audio-video-synchronization.html#section1-1" rel="nofollow noreferrer">https://developer.amazon.com/docs/fire-tv/audio-video-synchronization.html#section1-1</a></p>
  
  <p><a href="https://groups.google.com/forum/#!topic/android-platform/PoHfyNK54ps" rel="nofollow noreferrer">https://groups.google.com/forum/#!topic/android-platform/PoHfyNK54ps</a></p>
  
  <p>However, none of these explain <strong>how</strong> to use the timestamp to calculate the latency? I'm struggling to figure what to do with the timestamp's framePosition/nanoTime to come up with a latency number.</p>