au.MinLogTimeBetweenUnderrunWarnings

au.MinLogTimeBetweenUnderrunWarnings

#Overview

name: au.MinLogTimeBetweenUnderrunWarnings

This variable is created as a Console Variable (cvar).

It is referenced in 3 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of au.MinLogTimeBetweenUnderrunWarnings is to control the frequency of audio buffer underrun warnings in the Unreal Engine’s audio system. It sets the minimum time interval between consecutive underrun warning log messages.

This setting variable is primarily used by the Audio Mixer subsystem of Unreal Engine 5. It’s part of the AudioMixerCore module, which is responsible for handling low-level audio mixing operations.

The value of this variable is set using the FAutoConsoleVariableRef system, which allows it to be modified at runtime through console commands. It’s initialized with a default value of 10 seconds (10000 milliseconds).

The associated variable MinTimeBetweenUnderrunWarningsMs directly interacts with au.MinLogTimeBetweenUnderrunWarnings. They share the same value, with MinTimeBetweenUnderrunWarningsMs being the actual float variable used in the code.

Developers should be aware that this variable affects the frequency of audio underrun warning logs. Setting it too low might flood the log with warnings, while setting it too high might cause important underrun issues to go unnoticed for longer periods.

Best practices when using this variable include:

  1. Keeping it at a reasonable value (default is 10 seconds) to balance between getting timely warnings and avoiding log spam.
  2. Temporarily reducing the value when debugging audio performance issues to get more frequent feedback.
  3. Increasing the value in shipping builds to reduce potential log spam if minor underruns are expected and acceptable.

Regarding the associated variable MinTimeBetweenUnderrunWarningsMs:

The purpose of MinTimeBetweenUnderrunWarningsMs is to store the actual float value used in the audio mixer code to determine when to log underrun warnings.

This variable is used directly in the IAudioMixerPlatformInterface::ReadNextBuffer function to check if enough time has elapsed since the last warning before logging a new one.

The value of MinTimeBetweenUnderrunWarningsMs is set through the au.MinLogTimeBetweenUnderrunWarnings console variable.

Developers should be aware that modifying MinTimeBetweenUnderrunWarningsMs directly in code won’t have any effect, as its value is controlled by the console variable.

Best practices for MinTimeBetweenUnderrunWarningsMs include:

  1. Always use the console variable au.MinLogTimeBetweenUnderrunWarnings to modify its value.
  2. Consider the implications on log verbosity and performance monitoring when changing this value.
  3. Use this variable in conjunction with other audio debugging tools to diagnose and resolve underrun issues in the audio system.

#References in C++ code

#Callsites

This variable is referenced in the following C++ source code:

#Loc: <Workspace>/Engine/Source/Runtime/AudioMixerCore/Private/AudioMixer.cpp:40

Scope: file

Source code excerpt:

static float MinTimeBetweenUnderrunWarningsMs = 1000.f*10.f;
FAutoConsoleVariableRef CVarMinTimeBetweenUnderrunWarningsMs(
	TEXT("au.MinLogTimeBetweenUnderrunWarnings"),
	MinTimeBetweenUnderrunWarningsMs,
	TEXT("Min time between underrun warnings (globally) in MS\n")
	TEXT("Set the time between each subsequent underrun log warning globaly (defaults to 10secs)"),
	ECVF_Default);

// Command for setting the audio render thread priority.

#Associated Variable and Callsites

This variable is associated with another variable named MinTimeBetweenUnderrunWarningsMs. They share the same value. See the following C++ source code.

#Loc: <Workspace>/Engine/Source/Runtime/AudioMixerCore/Private/AudioMixer.cpp:38

Scope: file

Source code excerpt:

	ECVF_Default);

static float MinTimeBetweenUnderrunWarningsMs = 1000.f*10.f;
FAutoConsoleVariableRef CVarMinTimeBetweenUnderrunWarningsMs(
	TEXT("au.MinLogTimeBetweenUnderrunWarnings"),
	MinTimeBetweenUnderrunWarningsMs,
	TEXT("Min time between underrun warnings (globally) in MS\n")
	TEXT("Set the time between each subsequent underrun log warning globaly (defaults to 10secs)"),
	ECVF_Default);

// Command for setting the audio render thread priority.
static int32 SetRenderThreadPriorityCVar = (int32)TPri_Highest;

#Loc: <Workspace>/Engine/Source/Runtime/AudioMixerCore/Private/AudioMixer.cpp:586

Scope (from outer to inner):

file
namespace    Audio
function     void IAudioMixerPlatformInterface::ReadNextBuffer

Source code excerpt:

			{
				float ElapsedTimeInMs = static_cast<float>(FPlatformTime::ToMilliseconds64(FPlatformTime::Cycles64() - TimeLastWarningCycles));
				if( ElapsedTimeInMs > MinTimeBetweenUnderrunWarningsMs )
				{
					// Underrun/Starvation:
					// Things to try: Increase # output buffers, ensure audio-render thread has time to run (affinity and priority), debug your mix and reduce # sounds playing.

					UE_LOG(LogAudioMixer, Display, TEXT("Audio Buffer Underrun (starvation) detected. InstanceID=%d"), InstanceID);
					bWarnedBufferUnderrun = true;