Android: sound API (deterministic, low latency)

后端 未结 5 696
天涯浪人
天涯浪人 2020-12-04 13:07

I\'m reviewing all kinds of Android sound API and I\'d like to know which one I should use. My goal is to get low latency audio or, at least, deterministic behavior regardin

5条回答
  •  孤街浪徒
    2020-12-04 14:06

    IIRC, OpenSL is passed through the same interface as AudioTrack, so at best it will match AudioTrack. (FWIW, I'm currently using OpenSL for "low latency" output)

    The sad truth is there is no such thing as low latency audio on Android. There isn't even a proper way to flag and/or filter devices based on audio latency.

    What interface you'll want to use to minimize latency is going to depend on what you are trying to do. If you want to have an audio stream you'll be looking at either OpenSL or AudioTrack.

    If you want to trigger some static oneshots you may want to use SoundPool. For static oneshots SoundPool will have low latency as the samples are preloaded to the hardware. I think it's possible to preload oneshots using OpenSL as well, but I haven't tried.

提交回复
热议问题