-
As a Google Android audio developer pointed out long ago, OpenSL ES is always the correct choice over AudioTrack.
-
As the developer above said, matching buffer size is really important to achieve low-latency and to avoid a bug on Android M.
-
Google announced AAudio to replace the outdated OpenSL ES, and they are encouraging developers to use it.
But in reality, in 2019, not only doesn’t Unity support AAudio, but Unity is still struggling to support OpenSL.
Your link says :
“Android: Use OpenSL instead of AudioTrack on more devices. This reduces audio input and output latency.”
What do you mean by MORE here?
It had to be ALL.
In the beginning, there’s no performance benefit just by using OpenSL ES, but starting Android 4.1,
OpenSL ES got better and better.
Unity once used to support old Android devices, so AudioTrack was useful back then, but now Unity only supports Android 4.1 and up.
So why Unity still uses AudioTrack on some devices in 2019?
Really don’t get it.
Many third-party libraries including FMOD Studio API always use OpenSL ES on Android 4.1 and newer.
Also, it doesn’t seem like Unity sets the output buffer size properly, at least on my Samsung Galaxy S7 Edge.
(I’m not talking about the DSP Buffer Size settings in the Project Settings menu here. I’m talking about OpenSL ES settings.)
When I use audio libraries written by me or third parties on my S7 Edge, I could achieve very low latency compared to Unity’s built-in audio feature.
I added “AT LEAST” above, because, on my S10 Plus, Unity’s built-in audio worked almost the same as mine.
As for AAudio, it first came out two years ago, and now almost all audio libraries from third-parties already support it.
Even FMOD Studio API added it about two months ago.
(I know Unity uses the older version, FMOD Ex, internally.)
AAudio is just like Vulkan for audio on Android, and it came out to replace the old OpenSL ES,
so the Unity team really needs to support this.
Imagine Unity without Vulkan. How ridiculous. The same thing is happening with your audio feature.
As you may know, Android’s audio latency issue is really serious.
We can’t develop high-quality audio related apps and games for Android forever using Unity if this is not fixed by you.
Not all Unity users know well about the Android platform like me.
I know you, developers there, are really busy doing super cool creative things, but I think if you really care about Android users, you can partner with the Google Android audio team.
Because they are really willing to improve their user experience, they are working hard educating app developers and already partnered with many audio app and hardware companies to solve their problems.
Unity is the world’s best development engine especially for Android, so Google will help you if you just ask them.
I hope Unity will bring good news soon.
NOTE : You don’t want to use AAudio on Android 8.0. AAudio should be used on Android 8.1 and later, because Android 8.0’s AAudio has a bug related to a race condition with the Java garbage collector.
Otherwise, the app will likely crash.