google / oboe

Oboe is a C++ library that makes it easy to build high-performance audio apps on Android.
Apache License 2.0
3.64k stars 553 forks source link

Very high latency when more than 2 audio channels are used #942

Open apleton opened 4 years ago

apleton commented 4 years ago

Android version(s): 9/10 Android device(s): Pixel 3a, Samsung Galaxy s10 Oboe version: 1.4.2 App name used for testing: Hello Oboe

Short description On some devices the latency is very high when more than 2 channels are used.

Steps to reproduce

Expected behavior

Actual behavior

Any additional context

dturner commented 4 years ago

Thanks for letting us know about this. It sounds like on some devices when requesting a stream with 2 or less channels a low latency stream is provided, otherwise a normal (100+ ms latency) stream is provided.

What's the latency on the Moto G5 when using 4 channels? I ask because it might be that the device is not providing a low latency stream for any channel counts.

@philburk Do you know what the performance mode policy is for streams with >2 channels?

apleton commented 4 years ago

With Hello Oboe app running on Moto G5, I get 22 ms latency in 2 and 4 channels configuration.

In our app, Moto G5 runs in PerformanceMode::LowLatency mode with 2 and 4 channels. I set the buffer size to 256 frames for both 2 and 4 channels configuration and it runs fine.

Note : the moto G5 runs android 8.1.

dturner commented 3 years ago

I don't have an S10 to test on but I do have an S9 running Android 10 and a Pioneer DDJ-WEGO3. I tried reproducing this issue on that hardware and I found that that I cannot get a low latency stream. Even with 2 channels the latency remains at around 80ms. Changing to 4 channels didn't affect this. Neither did switching to a Pixel USB headset adapter. It appears the S9 just doesn't support low latency streams over USB audio devices.

dturner commented 3 years ago

I have filed an issue with Samsung (b/168790057) so will close this here and update when there is any progress.

philburk commented 3 years ago

Pixel 3a on RQ1A with 4 channels on Vantec USB interface got 1920 framesPerBurst at 96000 Hz. PerfMode=NONE

Pixel 4a 5G on S master with 4 channels on Vantec USB interface got 252 framesPerBurst at 96000 Hz. Performance mode is LOW_LATENCY but the measured round-trip latency is 93 msec. For stereo the latency is 19 msec at 48000 Hz.

robertwu1 commented 2 years ago

Pixel 6 on T with 4 channels doesn't use MMAP and ends up with a burst of 960 and a tap to tone latency of 114ms. @philburk can add more than 2 channels to AAudio?