Obtaining audio output latency

363 views
Skip to first unread message

Gil Fidel

unread,
Jun 22, 2015, 12:03:35 PM6/22/15
to android-...@googlegroups.com
Hello,

I have a need to get an estimate of the audio output latency in an android app.
I have noticed that this functionality was partially exposed in the following git commit:

Revision: 61dcdf3764b614c6f01e77cb4342d192e3101f8a
Author: Oliver Woodman <xx...@google.com>
Date: 6/26/2013 2:43:36 PM
Message:
Expose latency methods through AudioManager and AudioTrack.

There's a longer term plan to fix audio/video sync, but
this gets the Java level to parity with the native level,
and allows applications in Java to achieve sync in the
same way as the native media player. APIs are left as hidden
for now.

Change-Id: Iaf70baac1ffb50ef48e03355163158568fbd0fe9
----
Modified: core/jni/android_media_AudioSystem.cpp
Modified: core/jni/android_media_AudioTrack.cpp
Modified: media/java/android/media/AudioManager.java
Modified: media/java/android/media/AudioSystem.java
Modified: media/java/android/media/AudioTrack.java


Which makes the AudioManager.getOutputLatency api somewhat accessible (using reflection, since it's hidden).

So, my question is:
  1. Is the latency returned by getOutputLatency reliable?
  2. What can I do on android < 4.3 which does not expose this in java? Is there a way to call the AudioSystem::getLatency api from ndk?
  3. Is there some other way to get a reilable output latency estimate?


Thanks a lot,

Gil

Glenn Kasten

unread,
Jun 25, 2015, 12:27:00 PM6/25/15
to android-...@googlegroups.com, gil....@gmail.com
Please see the thread "How can I find the hardware audio playback latency of a certain device?"
at https://groups.google.com/forum/#!topic/android-platform/PoHfyNK54ps
I recommend the API mentioned at that other thread, over other APIs, as it is more accurate for on-device transducers.
Reply all
Reply to author
Forward
0 new messages