au.CommandBufferMaxSizeInMb

au.CommandBufferMaxSizeInMb

#Overview

name: au.CommandBufferMaxSizeInMb

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.CommandBufferMaxSizeInMb is to control the maximum size of the command buffer in the audio mixer system of Unreal Engine 5. It sets an upper limit on how large the command buffer can grow before the system starts ignoring additional commands.

This setting variable is primarily used in the audio mixer subsystem of Unreal Engine. Specifically, it’s utilized in the AudioMixer module, as evidenced by its location in the AudioMixerSourceManager.cpp file.

The value of this variable is set using an FAutoConsoleVariableRef, which allows it to be adjusted at runtime through console commands. The default value is set to 10 MB.

The au.CommandBufferMaxSizeInMb variable interacts directly with the CommandBufferMaxSizeInMbCvar variable. They share the same value, with CommandBufferMaxSizeInMbCvar being the actual integer storage for the setting.

Developers should be aware that this variable directly impacts the audio processing capabilities of the engine. If set too low, it might result in audio commands being ignored once the buffer is full, potentially leading to audio glitches or missing sounds. If set too high, it could consume unnecessary memory.

Best practices when using this variable include:

  1. Monitor the audio performance and adjust the value if audio glitches occur due to a full command buffer.
  2. Be cautious about setting it too high, as it could lead to excessive memory usage.
  3. Use in conjunction with profiling tools to find the optimal balance between performance and resource usage.

Regarding the associated variable CommandBufferMaxSizeInMbCvar:

The purpose of CommandBufferMaxSizeInMbCvar is to serve as the actual storage for the au.CommandBufferMaxSizeInMb setting. It’s an integer variable that holds the maximum size of the command buffer in megabytes.

This variable is used directly in the AudioMixer module, specifically in the FMixerSourceManager::AudioMixerThreadCommand function. Here, it’s used to calculate the maximum buffer size in bytes and check if the current buffer size has exceeded this limit.

The value of CommandBufferMaxSizeInMbCvar is set through the au.CommandBufferMaxSizeInMb console variable. It’s initialized with a default value of 10 MB.

CommandBufferMaxSizeInMbCvar interacts closely with au.CommandBufferMaxSizeInMb, as they represent the same setting. It’s also used in conjunction with other variables like CurrentBufferSizeInBytes to manage the command buffer size.

Developers should be aware that modifying CommandBufferMaxSizeInMbCvar directly won’t have the desired effect, as it’s controlled through the console variable system. Always use the au.CommandBufferMaxSizeInMb console variable to adjust this setting.

Best practices for CommandBufferMaxSizeInMbCvar include:

  1. Treat it as a read-only variable in code, modifying it only through the console variable system.
  2. When reading its value, be aware that it represents megabytes and may need to be converted to bytes for certain operations.
  3. Consider logging or alerting when the buffer size approaches or exceeds this limit to help with performance tuning.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/AudioMixer/Private/AudioMixerSourceManager.cpp:102

Scope: file

Source code excerpt:

static int32 CommandBufferMaxSizeInMbCvar = 10;
FAutoConsoleVariableRef CVarCommandBufferMaxSizeMb(
	TEXT("au.CommandBufferMaxSizeInMb"),
	CommandBufferMaxSizeInMbCvar,
	TEXT("How big to allow the command buffer to grow before ignoring more commands"),
	ECVF_Default);

static int32 CommandBufferInitialCapacityCvar = 500;
FAutoConsoleVariableRef CVarCommandBufferInitialCapacity(

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/AudioMixer/Private/AudioMixerSourceManager.cpp:100

Scope: file

Source code excerpt:

	ECVF_Default);

static int32 CommandBufferMaxSizeInMbCvar = 10;
FAutoConsoleVariableRef CVarCommandBufferMaxSizeMb(
	TEXT("au.CommandBufferMaxSizeInMb"),
	CommandBufferMaxSizeInMbCvar,
	TEXT("How big to allow the command buffer to grow before ignoring more commands"),
	ECVF_Default);

static int32 CommandBufferInitialCapacityCvar = 500;
FAutoConsoleVariableRef CVarCommandBufferInitialCapacity(
	TEXT("au.CommandBufferInitialCapacity"),

#Loc: <Workspace>/Engine/Source/Runtime/AudioMixer/Private/AudioMixerSourceManager.cpp:3423

Scope (from outer to inner):

file
namespace    Audio
function     void FMixerSourceManager::AudioMixerThreadCommand

Source code excerpt:

			
			// check that we haven't gone over the max size
			const SIZE_T MaxBufferSizeInBytes = ((SIZE_T)CommandBufferMaxSizeInMbCvar) << 20;
			if (CurrentBufferSizeInBytes >= MaxBufferSizeInBytes)
			{
				int32 NumTimesOvergrown = CommandBuffers[AudioThreadCommandIndex].NumTimesOvergrown.Increment();
				UE_LOG(LogAudioMixer, Error, TEXT("%d: Command buffer %d allocated size has grown to %umb! Likely cause the AudioRenderer has hung"),
					NumTimesOvergrown, AudioThreadCommandIndex, CurrentBufferSizeInBytes >> 20);
			}