GNOME Bugzilla – Bug 783991
openslessink: Unable to use native sample rate(48000) for low latency audio playback on most Android devices
Last modified: 2018-11-03 14:09:56 UTC
To obtain the lowest output latency on android (~20 ms), you must supply audio data that matches the device's optimal sample rate and buffer size. Otherwise output latency is 100 - 200 ms, which for some projects is a big deal. openslessink should be able to accept all provided sample rates (including 48000 Hz) and have a parameter for setting optimal buffer size. More on this: https://developer.android.com/ndk/guides/audio/audio-latency.html#output-latency
In earlier versions of Android at least, rates other than 48000 didn't work and there was no API to query the supported rates. Is there something for that now at the OpenSL ES level, or only at the Java layer? Would you like to provide a patch?
It is definitely possible to get supported rates from Java layer, but there is also a change that it is possible to get it from OpenSL ES level. We will do more research and update you on issue and probably provide a patch.
Created attachment 363291 [details] [review] 48000 Hz sample rate support added to sink element Fix has been that we use in our company internally. It basically only adds 48000 Hz as supported sample rate. In previous commit this sample rate was omitted because of downsampling to this rate issues, but we never encountered them and low audio latency was more important for us. To obtain the lowest output latency (25 - 40 ms) on Android, you must supply data that matches the device's optimal sample rate. In most cases on new devices it is 48000 Hz. Optimal sample rate uses android's fast mixer path to reduce latency. Optimal sample rate can only be retrieved in JAVA. Reference: https://developer.android.com/ndk/guides/audio/audio-latency.html
-- GitLab Migration Automatic Message -- This bug has been migrated to freedesktop.org's GitLab instance and has been closed from further activity. You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/issues/572.