Oboe is a native library written in C++ which uses the Android NDK. To move data from Java to C++ you can use JNI.
That said, if you are generating your audio in Java you'll get better performance using the Java AudioTrack class. This can be created with low latency using the AudioTrack.Builder method setPerformanceMode(AudioTrack.PERFORMANCE_MODE_LOW_LATENCY)
.
You can dynamically tune the latency of the stream just like in Oboe using setBufferSizeInFrames(int)
Also you can use blocking writes with the Java AudioTrack and still get a low latency stream. Oboe requires a callback to get a low latency stream and that does not work well with Java.
Note that AudioTrack.PERFORMANCE_MODE_LOW_LATENCY
was added in API 26, For API 24 or 25 use AudioAttributes.FLAG_LOW_LATENCY
. That was deprecated but will still work with later APIs.
Oboe only works with PCM data. It does not include any extraction or decoding classes. However, the RhythmGame sample includes extractors for both NDK and FFmpeg.
For more information on using FFmpeg in your app check out this article.
Start by ensuring that your project builds successfully. The main thing to do is ensure that the Oboe include paths are set correctly in your project's CMakeLists.txt
. Full instructions here.
If that doesn't fix it try the following:
$HOME/Library/Caches/AndroidStudio<version>
We have had several reports of this happening and are keen to understand the root cause. If this happens to you please file an issue with your Android Studio version and we'll investigate further.
PerformanceMode::LowLatency
, but didn't get it. Why not?Usually if you call builder.setPerformanceMode(PerformanceMode::LowLatency)
and don't specify other stream properties you will get a LowLatency
stream. The most common reasons for not receiving one are:
LowLatency
stream is not possible. To avoid the resampler on API 26 and below you can specify a default value for the sample rate as detailed here. Or you can use the new resampler in Oboe, which allows the lower level code to run at the optimal rate and provide lower latency.LowLatency
streams, for example Bluetooth.LowLatency
stream for both mono and stereo, however, there are a few exceptions, some of which are listed here.LowLatency
streams has been reached. This could be by your app, or by other apps. This is often caused by opening multiple playback streams for different "tracks". To avoid this open a single audio stream and perform your own mixing in the app.PerformanceMode::None
. The ability to query the performance mode of a stream was added in Android 7.1 (Nougat MR1). Low latency streams (aka FAST tracks) are available on Android 7.0 and below but there is no programmatic way of knowing whether yours is one. Question on StackOverflowPlease ask questions on Stack Overflow with the Oboe tag or in the GitHub Issues tab.