How can I get latency info from Android's AudioTrack class?
I've noticed that the C++ classes underlying the AudioTrack
and AudioRecord
APIs in Android both have a latency()
method that is not exposed via JNI. As far as I can see, the latency()
method in AudioRecord
still does not take into account the hardware latency (they have a TODO comment for that), but the latency()
method in AudioTrack
does add in the hardware latency.
I absolutely need to get this latency value from AudioTrack
. Is there any possible way I can do this? I don't care what kind of crazy hack is needed as long as it doesn't require a rooted phone (the resulting code must still be packa开发者_如何转开发ged as an app on the market).
There is a method on AudioTrack
called getLatency()
that you can invoke via reflection. For an example, look at Exoplayer or https://developer.amazon.com/docs/fire-tv/audio-video-synchronization.html#section1-2
Sorry but do you need the real buffer + hardwre latency? Unfortunately it seems you won´t be able to get this value unless you use some hacks not recommended by google and which can turn into creases in new Android versions.
精彩评论