Why Samsung Professional Audio SDK is not the best solution for low latency Android audio
As of this writing, Android’s audio latency is still not at parity with iOS. Samsung has made valiant efforts in solving Android’s low latency challenges by porting the JACK audio connection kit to Android, making use of a separate audio path that bypasses Android’s media server.
While we acknowledge and appreciate Samsung’s efforts in reducing Android audio latency, we respectfully opine that the Samsung Professional Audio SDK (“SAPA”) is ultimately not good solution to the problem.
Here is why.
The following article may be a tad too technical for many readers, so here is a quick summary:
To support Samsung Professional Audio SDK, Android app developers need to entirely re-architect the audio portions of their apps to run on a sub-set of Galaxy device models. A sub-set of devices that isn’t clearly defined, and worse yet is the lack of clarity with regard to which devices support audio input feature availability.
SAPA provides no significant audio latency benefit over Google’s latest efforts in Android Lollipop, and as such, we suggest that Samsung consider a change of technical direction.
Incomplete Audio Input Feature
Samsung released the first version of the SAPA SDK in 2013, but it’s still not clear which devices are supported. According to the documentation:
- Samsung Galaxy S series and Samsung Galaxy Note series support Professional Audio.
- Android 4.1 (JellyBean API 16) or above support Professional Audio.
Based on our extensive testing, this does not appear to be accurate for older Galaxy devices such as the first Note or S models.
Furthermore, audio input (such as the microphone!) is not supported on many models that ostensibly benefit from SAPA, however, the documentation includes no warning or wording about this severe limitation.
Unfortunately, app developers are unable to detect audio input’s availability on the device with code. On one of our test device, a Samsung Note 3, for example, it happily reports that all audio features are functioning and available, JACK returns with no error, but all input provides is digital silence.
While we at Superpowered have fully implemented support for the Samsung Professional Audio SDK in our round-trip audio latency measurement test app for Android, the lack of audio input support prevented us from being able to use that SAPA audio input in our code.
We’ve contacted the Samsung developer who ported JACK to Galaxy devices directly on his GitHub account, and he forwarded us to the Samsung Developer Community. While he was aware of the problem, no thorough response is in evidence.
Browsing through the related topics reveals that official responses are rare. The low number of the topics suggests that, at this point in time, there is not a critical mass of developers creating apps with the Samsung Professional Audio SDK, which leads to the next problem.
Update: please check Samsung's response at the end of the post.
Far Too Complex
First, the low(er) latency native audio features accessible in the Android Native Development Kit are quite challenging for many developers. The OpenSL ES API is outmoded and hard to understand, requiring developers to write lots of spaghetti code to make use of the most basic features. The communication between your app’s main part in Java (Android SDK) and native code (Android NDK) is complex, tedious and ugly too, because it’s how the Java Native Interface (JNI) was designed.
Believe me, most developers run screaming away from JNI + OpenSL ES. And the Samsung Professional Audio SDK increases app development complexity by an order of magnitude.
While JACK is easy to program for a C++ developer, the Samsung port communicates using the Binder inter-process communication system (IPC).
IPC was developed at Be Inc. and then Palm Inc. in an entirely different era of personal computing. As technologists, you are probably familiar with the term ‘path-dependency’ -- it turns out that many of the audio challenges on Android we face today are path dependency problems of yesterday.
Trust us, implementing the binder interfaces is not a pleasant experience for even the most experienced of developers, and it leads to an even bigger problem:
The audio part of a program implemented with the Samsung Professional Audio SDK does not run inside the actual program.
It doesn’t simply run on a different thread, but runs on an entirely different process. This is akin to designing a car that pulls it’s own engine on a trailer.
Meaning that app developers are effectively required to fully re-architect the audio part of their software just for the Samsung Professional Audio SDK, with a very different and unusual approach.
If software needs to run on devices without the SAPA SDK, developers need to maintain two different audio sub-programs, one for Samsung Galaxy, and one for everything else.
Certainly, some code can be shared between the two, but at bare minimum, communication between the main application body (in Java) and audio will be entirely different.
Currently, not significantly better than Google’s efforts
Google has been diligently working on fixing the Android media server (Audio Flinger) since 2011, with improvements every year. They appear to be hitting a wall currently, but that’s a different story we’ll write about later.
We’ve extensively explored both Google’s low latency media server path (“Fast Mixer”) and the Samsung Professional Audio SDK. The output latency difference is just a few ms compared to the best (current) Google Nexus 9 tablet, and still does not compare to iOS.
The current state of Android audio latency
The Superpowered Mobile Audio Latency Test App for Android and iOS is the only extensive census available for audio round-trip latency measurement of mobile devices. To date, we have collected over 15,000 measurements on over 350 different mobile device builds/models, and you can compare the performance of these devices.
We at Superpowered are especially fans of all kinds of music related applications. Apart from a few, presumably Samsung supported applications like Soundcamp or Thumbjam, we don’t see the Samsung Professional Audio SDK attaining significant traction.
Our suggestions for Samsung
Our data shows that enabling Google’s latency improvements (the so-called “Fast Mixer”) on Galaxy devices provides good results compared to other Android devices. Maintaining a too-complex and not complete workaround (the Samsung Professional Audio SDK) does not lend itself to become an easily adopted technical solution.
In the meantime, supporting Google’s “Fast Mixer” and optimizing on it seems to be the optimal way for the future, beneficial for both Samsung and the Android developer community.
Update: Samsung's response
We received a kind email from Samsung with very interesting information. We can share some:
Direct support on the Samsung Developer Community website is not provided currently. Developers should write to email@example.com.
Samsung Professional Audio SDK 2.0 is available on the Galaxy Note 3, Galaxy Note 4, Note Edge, S5 (Lollipop), S6 and S6 Edge models (as of 04.2015).
Audio input works on the Galaxy Note 3 with Android Lollipop.
Samsung is continuously working on the SAPA API to make it easier for developers.