Version
menu

Wwise SDK 2025.1.0
Controlling Latency on Android

Android audio latency has always been an issue for all applications. Some devices exhibit up to 150 ms of latency, although the usual latency is below 100 ms.

Over the years, Google introduced the several "paths" through which audio can flow from an app to the device's audio hardware:

  • A "fast track", or "fast path", which is available for both OpenSL ES and AAudio APIs.
  • An AAudio-only "MMap mode", where memory-mapped buffers are shared directly between the application and the ALSA device mixer.
  • An AAudio-only "MMap-Exclusive" mode, where memory-mapped buffers are shared between the application and the ALSA driver.

When supported, these paths bypass various levels of internal processing to reduce the latency between the app and the hardware. Overall latency can be reduced to a few dozen milliseconds. It is important to note that it is not mandatory for the hardware manufacturers to implement these paths; many do not. Furthermore, some devices can report a fast path without it actually being implemented. Therefore, a game cannot rely on the existence of fast audio paths on the end-user's devices. If your game is for a wide target market, you should design your game audio without using this feature.

Generally, a lower latency will incur a higher CPU cost. The processing of RTPC updates, game object positions, and other game inputs is done on a per-frame basis. Therefore, with a smaller frame, this is processed more often. The balance between latency and CPU usage can only be found through experimentation. There is no hard rule.

Wwise Initialization Settings Controlling Latency

A few settings will control the latency of audio in the Wwise SDK:

Default Settings, One-size-fits-all Latency

The default settings returned by AK::SoundEngine::GetDefaultSettings() and AK::SoundEngine::GetDefaultPlatformInitSettings() are "safe" settings for most devices in most conditions. Using those will set:

  • uSampleRate to the hardware preferred rate. This is usually 48 kHz or 44.1 kHz.
  • uNumSamplesPerFrame to 512.
  • uNumRefillsInVoice to 4.
  • AkPlatformInitSettings::eAudioPath to AkAudioPath_LowLatency.

Advantages: This setup will select an appropriately low-latency audio path on devices that support it. There are also many fewer constraints on the CPU usage of the audio design.
Disadvantages: Four frames of audio are pre-processed to allow some room in CPU variation, which can cause higher latency on devices that may not need the headroom.

Lowest Latency Settings

To initialize Wwise with the lowest latency, call AK::SoundEngine::GetDefaultSettings() and AK::SoundEngine::GetDefaultPlatformSettings(), then apply the following changes:

Advantages: Lowest latency possible.
Disadvantages: Available CPU is limited. The time allotted to rendering audio is very short and can be easily disturbed by other events on the system. CPU overhead of audio designs (such as RTPCs, Switches, Positioning, and containers) is a concern and needs to be monitored carefully. Also, device compatibility is reduced. Only devices running Android 8.1 and above will have audio.

What happens when uNumRefillsInVoice is set too low ?

When the time required to process an audio frame is lower than what the CPU can handle, audio starvation occurs. At this point, users may hear audible pops and glitches if the game is not outputting silence.

If this glitching is unacceptable, you may opt out of this behavior by making sure to set uNumRefillsInVoice to an initial value large enough to never cause starvation. uNumRefillsInVoice will need to be set to at least 3, usually 4 in most games, to have some headroom for CPU usage variations.

The Bluetooth exception

Many Bluetooth devices cannot be low latency or use a fast audio path. In fact, to have glitchless audio with a Bluetooth device, the buffering must be a lot higher. Wwise will detect the usage of a high-latency Bluetooth headset and automatically override AkPlatformInitSettings::uNumRefillsInVoice to reach a latency of 170 ms.


Cette page a-t-elle été utile ?

Besoin d'aide ?

Des questions ? Des problèmes ? Besoin de plus d'informations ? Contactez-nous, nous pouvons vous aider !

Visitez notre page d'Aide

Décrivez-nous de votre projet. Nous sommes là pour vous aider.

Enregistrez votre projet et nous vous aiderons à démarrer sans aucune obligation !

Partir du bon pied avec Wwise