For the lowest possible audio latency, we recommend you use Oboe.
Oboe uses native audio and is built
on AAudio for Android 8.1+ and OpenSL ES for older versions of Android. To achieve the lowest
possible latency for a device, set
See the Getting started guide,
and Full guide for more
information on Oboe. Refer to the Soundboard app
for a sample app using Oboe.
Note: If you use AudioTrack
for creating output audio streams in Java for latency sensitive applications, use the
To use Android native audio:
- Download and install the Android NDK.
- Follow the Getting started guide for Oboe.
setSharingMode(oboe::SharingMode::Exclusive)on the Oboe builder.
Use the recommended native buffer size and sample rate returned by
Note: The same buffer size and sample rate should also be used for input.
- Keep your callback handlers short, without bursty CPU usage or unbounded blocking. Avoid priority inversion.
- Consider using non-blocking algorithms to communicate between input and output callback handlers, and between the callback handlers and the rest of your application.
The site source.android.com is primarily designed for OEMs building Android devices, and the SoC vendors who supply components to these OEMs.
However, there is a wealth of useful information about latency at this site, so you may want to review it. See the articles at Audio latency.
If you have questions about how to use Android native audio, you can ask at the discussion group android-ndk.
Report bugs on Oboe
If you have issues using Oboe, you can file a bug.
- Getting started with Oboe
- Low Latency Audio - Because Your Ears Are Worth It
- Android Dev Summit 2018.
- Winning on Android - How to optimize an Android audio app
- Android Developer Challenge 2018.
- High performance audio on Android (Google I/O 2013)
- The whole video is about latency.
- Building great multi-media experiences on Android (Google I/O 2014)
- The first 14 minutes are about audio in general and input latency in particular.
- Audio latency: buffer sizes (100 Days of Google Dev)
- Describes the relationship between audio latency, buffer sizes, and task scheduling.