Audio Latency Measurement

Audio output latency as measured by WALT is the time that passes from the moment an application decides to output a tone until it can be detected via the headphone jack. Microphone latency is defined similarly.

Low latency audio IO on Android can be achieved via JNI C/C++ code. Documentation and sample code can be found on the High Performance Audio website.

Reported values

We are trying to stick to the following (overlapping) principles

  1. Timestamp events as close to hardware as possible. Most events up the stack can be easily timed with software alone.
  2. Measure time intervals that are likely to have low variability.
Playback

In order to avoid warm up latency during audio playback it is recommended to constantly enqueue buffers containing silence. WALT app follows this pattern.

The audio data buffers are enqueued in the player callback and the latency reported by WALT app is the time from the Enqueue() call until there is a detectable signal on the wire. Note that this does not include the time between the moment the app decided to output a tone until the Enqueue() call. This is somewhat counterintuitive but this time is deliberately omitted. In case of the WALT app code this time is likely be uniformly distributed between 0 and the length of the buffer (5 ms in case of Nexus 5) and therefore would contribute considerable variance but little interesting information if included in the reported latency.

Recording

The reported latency is the time from the moment the last frame in a buffer was recorded until the recorder callback receiving that buffer is executed.

TODO: Is the round trip latency expected to be Recording latency + Playback latency + one buffer length?

Sample measurements

DeviceOS versionBufferPlayback [ms]Recording* [ms]
Nexus 5M4B30Z (6.0.1)240 frames @ 48 kHz = 5 ms27.62.5
Nexus 5XNRD91P (7.0)192 frames @ 48 kHz = 4 ms14.93.5
Nexus 7LMY47Q (5.1)240 frames @ 48 kHz = 5 ms32.116.3
Nexus 9MMB29K (6.0.1)128 frames @ 48 kHz = 2.6 ms9.81.0
Nexus 6PMHC19I (6.0.1)192 frames @ 48 kHz = 4 ms15.31.6
PixelNDE63P (7.1)192 frames @ 48 kHz = 4 ms8.91.7
Pixel XLNDE63H (7.1)192 frames @ 48 kHz = 4 ms9.11.6

* WALT clock synchronization accuracy is about 1 ms hence the relative error for recording latency can be fairly high.

Published round trip measurements

Superpowered Inc. maintains an open source app for measuring round trip audio latency - Superpowered Latency App.

Hardware

Audio signal for measuring microphone latency is generated as a square wave using the Teensy tone() function (currently at 5 kHz). The signal is attenuated by a simple circuit similar to the ChromeOS/Android audio loopback dongle.

Audio output signal from the phone is detected when audio line voltage crosses a predefined threshold (currently about 65 mV).