After upgrading our Android application to JUCE 6 we noticed that the latency increased. It is an instrument sampler application triggered by incoming midi notes. The processing time of the JUCE 5 version of the application is considerably faster.
To investigate I ran JUCE 5 & 6 based DemoRunners to find out that the minimum buffer sizes increased in JUCE 6. This seems to be tied to the use of Oboe in JUCE 6.
After I forced the build to use OpenSLES the old buffer sizes where available again.
-
Is there any good reason to not use OpenSLES?
-
Why are the Oboe buffer sizes bigger than the OpenSLES buffer sizes?
-
Is there a way to get smaller buffer sizes when using Oboe?
When looking int the logs of the Android device I noticed some entries about the AUDIO_OUTPUT_FLAG_FAST
(AAudio) being denied:
AudioTrack: AUDIO_OUTPUT_FLAG_FAST denied by client, not shared buffer and transfer = TRANSFER_SYNC
I’m aware of the general audio performance of Android devices.
Thanks!
EDIT: A warning following the one mentioned above tells me that the performance mode is not optimal:
W/AudioStreamTrack: open() perfMode changed from 12 to 10
Which basically means that the performance mode is set back to None
instead of LowLatency
.
BTW: This also reveals that the logging JUCE produces is inaccurate because JUCE outputs the textual representation of the oboe::PerformanceMode::LowLatency
mode without getting the actual performance mode of the stream first.
EDIT: For the sake of completeness:
2020-10-20 16:21:28.650 12860-12860/com.company.androidapp I/JUCE: Preparing Oboe stream with params:
AAudio supported = 1
API = Unspecified
DeviceId = 0
Direction = Output
SharingMode = Exclusive
ChannelCount = 2
Format = Float
SampleRate = 48000
PerformanceMode = LowLatency
2020-10-20 16:21:28.650 12860-12860/com.company.androidapp I/OboeAudio: openStream() OUTPUT -------- OboeVersion1.4.2 --------
2020-10-20 16:21:28.650 12860-12860/com.company.androidapp D/AAudio: AAudioStreamBuilder_openStream() called ----------------------------------------
2020-10-20 16:21:28.650 12860-12860/com.company.androidapp D/AudioStreamBuilder: build() EXCLUSIVE sharing mode not supported. Use SHARED.
2020-10-20 16:21:28.651 12860-12860/com.company.androidapp I/AAudioStream: open() rate = 48000, channels = 2, format = 0, sharing = SH, dir = OUTPUT
2020-10-20 16:21:28.651 12860-12860/com.company.androidapp I/AAudioStream: open() device = 0, sessionId = 0, perfMode = 12, callback: OFF with frames = 0
2020-10-20 16:21:28.651 12860-12860/com.company.androidapp I/AAudioStream: open() usage = 1, contentType = 2, inputPreset = 6
2020-10-20 16:21:28.651 12860-12860/com.company.androidapp D/AudioStreamTrack: open(), request notificationFrames = 0, frameCount = 0
2020-10-20 16:21:28.651 12860-12860/com.company.androidapp W/AudioTrack: AUDIO_OUTPUT_FLAG_FAST denied by client, not shared buffer and transfer = TRANSFER_SYNC
2020-10-20 16:21:28.656 12860-12860/com.company.androidapp W/AudioStreamTrack: open() flags changed from 0x00000104 to 0x00000100
2020-10-20 16:21:28.656 12860-12860/com.company.androidapp W/AudioStreamTrack: open() perfMode changed from 12 to 10
2020-10-20 16:21:28.656 12860-12860/com.company.androidapp D/AAudio: AAudioStreamBuilder_openStream() returns 0 = AAUDIO_OK for (0x7d65bfc900) ----------------
2020-10-20 16:21:28.658 12860-12860/com.company.androidapp D/OboeAudio: AudioStreamAAudio.open() format=2, sampleRate=48000, capacity = 1924
2020-10-20 16:21:28.658 12860-12860/com.company.androidapp D/OboeAudio: AudioStreamAAudio.open: AAudioStream_Open() returned AAUDIO_OK
2020-10-20 16:21:28.658 12860-12860/com.company.androidapp I/JUCE: Building Oboe stream with result: OK
Stream state = Open
2020-10-20 16:21:28.658 12860-12860/com.company.androidapp I/JUCE: Setting the bufferSizeInFrames to 192
2020-10-20 16:21:28.658 12860-12860/com.company.androidapp I/JUCE: Stream details:
Uses AAudio = 1
DeviceId = 3
Direction = Output
SharingMode = Shared
ChannelCount = 2
Format = Float
SampleRate = 48000
BufferSizeInFrames = 962
BufferCapacityInFrames = 1924
FramesPerBurst = 962
FramesPerCallback = 0
BytesPerFrame = 8
BytesPerSample = 4
PerformanceMode = None
EDIT: We’re seeing this problem on Nokia 5 and Xiaomi Redmi 8