Audio latency for app developers

For the lowest possible audio latency, we recommend you use Oboe.

Oboe

Oboe uses native audio and is built on AAudio for Android 8.1 (API level 27) and higher and OpenSL ES. To achieve the lowest possible latency for a device, set setPerformanceMode(oboe::PerformanceMode::LowLatency) and setSharingMode(oboe::SharingMode::Exclusive). For more information about Oboe, see the Getting started guide, README.md, and Full guide. See the Soundboard app for a sample app using Oboe.

If you use AudioTrack to create output audio streams in Java for latency-sensitive apps, use the PERFORMANCE_MODE_LOW_LATENCY mode.

Implementation checklist

To use Android native audio:

  1. Download and install the Android NDK.
  2. Follow the Getting started guide for Oboe.
  3. Call setPerformanceMode(oboe::PerformanceMode::LowLatency) and setSharingMode(oboe::SharingMode::Exclusive) on the Oboe builder.
  4. Use the recommended native buffer size and sample rate returned by android.media.AudioManager.getProperty(java.lang.String).

  5. Keep your callback handlers short, without bursty CPU usage or unbounded blocking. Avoid priority inversion.

  6. Consider using non-blocking algorithms to communicate between input and output callback handlers, and between the callback handlers and the rest of your application.

android-ndk

If you have questions about how to use Android native audio, join the discussion group android-ndk.

Report bugs on Oboe

If you have issues using Oboe, file a bug.

Videos