au.ForceRealtimeDecompression
au.ForceRealtimeDecompression
#Overview
name: au.ForceRealtimeDecompression
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
When set to 1, this deliberately ensures that all audio assets are decompressed as they play, rather than fully on load.\n0: Allow full decompression on load, 1: force realtime decompression.
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of au.ForceRealtimeDecompression is to control the decompression behavior of audio assets in Unreal Engine. It is primarily used in the audio system to determine whether audio should be decompressed in real-time during playback or fully decompressed on load.
This setting variable is primarily used by the Unreal Engine’s audio subsystem, specifically within the FAudioDevice class. It is part of the Engine module, as evident from its location in the AudioDevice.cpp file within the Engine/Source/Runtime/Engine/Private/ directory.
The value of this variable is set through a console variable (CVar) system. It’s initialized to 0 and can be changed at runtime through console commands or configuration files.
The au.ForceRealtimeDecompression variable interacts directly with the ForceRealtimeDecompressionCvar variable. They share the same value, with ForceRealtimeDecompressionCvar being the actual integer storage and au.ForceRealtimeDecompression being the console-accessible name.
Developers must be aware that setting this variable to 1 will force all audio assets to be decompressed in real-time as they play, rather than being fully decompressed on load. This can have performance implications, especially for larger audio files or on platforms with limited processing power.
Best practices when using this variable include:
- Keeping it at 0 (default) for most use cases to allow the engine to decide the best decompression method.
- Using it for debugging or testing purposes when you need to simulate real-time decompression for all audio assets.
- Being cautious about setting it to 1 in production builds, as it may impact performance.
Regarding the associated variable ForceRealtimeDecompressionCvar:
The purpose of ForceRealtimeDecompressionCvar is to serve as the actual storage for the au.ForceRealtimeDecompression setting. It’s an integer variable that directly controls the behavior of the audio decompression system.
This variable is used within the FAudioDevice class, specifically in the ShouldUseRealtimeDecompression function. It’s part of the decision-making process to determine whether a sound should be decompressed in real-time or not.
The value of ForceRealtimeDecompressionCvar is set through the console variable system, initialized to 0, and can be modified at runtime.
It interacts directly with au.ForceRealtimeDecompression, serving as its backing storage. It’s also used in conjunction with other variables like bDisableAudioCaching, SoundGroup.bAlwaysDecompressOnLoad, and RealtimeDecompressZeroDurationSoundsCvar to determine the decompression behavior.
Developers should be aware that this variable is used in boolean context, where any non-zero value will be treated as true. It’s part of a larger condition that determines real-time decompression, so its effects may be overridden by other settings.
Best practices for ForceRealtimeDecompressionCvar are similar to those for au.ForceRealtimeDecompression, as they are essentially the same setting. Developers should avoid directly manipulating this variable and instead use the console variable au.ForceRealtimeDecompression for any runtime changes.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/AudioDevice.cpp:64
Scope: file
Source code excerpt:
static int32 ForceRealtimeDecompressionCvar = 0;
FAutoConsoleVariableRef CVarForceRealtimeDecompression(
TEXT("au.ForceRealtimeDecompression"),
ForceRealtimeDecompressionCvar,
TEXT("When set to 1, this deliberately ensures that all audio assets are decompressed as they play, rather than fully on load.\n")
TEXT("0: Allow full decompression on load, 1: force realtime decompression."),
ECVF_Default);
static int32 DisableAppVolumeCvar = 0;
#Associated Variable and Callsites
This variable is associated with another variable named ForceRealtimeDecompressionCvar
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/AudioDevice.cpp:62
Scope: file
Source code excerpt:
ECVF_Default);
static int32 ForceRealtimeDecompressionCvar = 0;
FAutoConsoleVariableRef CVarForceRealtimeDecompression(
TEXT("au.ForceRealtimeDecompression"),
ForceRealtimeDecompressionCvar,
TEXT("When set to 1, this deliberately ensures that all audio assets are decompressed as they play, rather than fully on load.\n")
TEXT("0: Allow full decompression on load, 1: force realtime decompression."),
ECVF_Default);
static int32 DisableAppVolumeCvar = 0;
FAutoConsoleVariableRef CVarDisableAppVolume(
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/AudioDevice.cpp:6753
Scope (from outer to inner):
file
function bool FAudioDevice::ShouldUseRealtimeDecompression
Source code excerpt:
((bDisableAudioCaching || DisablePCMAudioCaching()) ||
(!SoundGroup.bAlwaysDecompressOnLoad &&
(ForceRealtimeDecompressionCvar || SoundWave->Duration > CompressedDurationThreshold || (RealtimeDecompressZeroDurationSoundsCvar && SoundWave->Duration <= 0.0f))));
}
void FAudioDevice::StopSourcesUsingBuffer(FSoundBuffer* SoundBuffer)
{
TRACE_CPUPROFILER_EVENT_SCOPE(FAudioDevice_StopSourcesUsingBuffer);