8

So anybody worth their salt in the android development community knows about issue 3434 relating to low latency audio in Android. For those who don't, you can educate yourself here. http://code.google.com/p/android/issues/detail?id=3434

I'm looking for any sort of temporary workaround for my personal project. I've heard tell of exposing private interfaces to the NDK by rolling your own build of android and modifying the NDK.

All I need is a way to access the low level alsa drivers which are already packaged with the standard 2.2 build. I'd like to have the ability to send PCM directly to the audio hardware on my device. I don't care that the resulting app won't be distributable over the marketplace, and likely won't run with any other device than mine.

Anybody have any useful ideas?

-Griff

EDIT: I should mention, I know AudioTrack provides this functionality, but I'd like much lower latency -- AudioTrack sits around 300ms, I'd like somewhere around 20-30 ms.

3 Answers 3

7

Griff, that's just the problem, NDK wil not improve the known latency issue (that's even documented). The hardware abstraction layer in native code is currently adding to the latency, so it's not just about access to the low level drivers (btw you shouldn't rely on alsa drivers being there anyway).

3
  • 1
    Gah. I was hoping that wouldn't be the case. I actually had a chance to talk to the Android guys at GDC 2011, and apparently it isn't entirely a hardware issue, but instead an architecture issue that is not easy to resolve.
    – Griffin
    Apr 7, 2011 at 4:05
  • See @Ian Ni-Lewis's comment - things are getting better with 4.1 Sep 13, 2012 at 18:01
  • I predict that there will be no architectural resolution, as Google is unconcerned with actual performance of these data-mining devices that pose as smart phones. Apr 22, 2015 at 13:20
1

Android: sound API (deterministic, low latency) covers the tradeoffs pretty well. TL;DR: NDK gives you a minor benefit because the threads can run at higher priority, but this benefit is meaningless pre-Jellybean because the entire audio system is tuned for Java.

The Galaxy Nexus running 4.1 can get fairly close to 30ms of output latency.

1
  • Great, so a specific hardware device will work but only slightly better; this is becoming a zero-sum game. Apr 22, 2015 at 13:21
0

The latency situation on Android has changed significantly sine the original post. Now most flagship Android phones can achieve good low latency.

The AAudio API allows an app to write into an MMAP buffer that is read by the hardware. So that provides the lowest possible path. That is better than writing to ALSA directly.

There is a new checklist for enabling low latency on Android at: https://developer.android.com/games/sdk/oboe/low-latency-audio#oboe

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.