au.FlushAudioRenderThreadOnGC
au.FlushAudioRenderThreadOnGC
#Overview
name: au.FlushAudioRenderThreadOnGC
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
When set to 1, every time the GC runs, we flush all pending audio render thread commands.\n
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of au.FlushAudioRenderThreadOnGC is to control the behavior of flushing audio render thread commands during garbage collection in Unreal Engine’s audio system.
This setting variable is primarily used in the audio subsystem of Unreal Engine, specifically within the FAudioDevice class. It is part of the Engine module, as evidenced by its location in the AudioDevice.cpp file within the Engine/Source/Runtime/Engine directory.
The value of this variable is set through a console variable (CVar) system. It is initialized to 0 and can be changed at runtime using console commands or through configuration files.
The associated variable FlushAudioRenderThreadOnGCCVar directly interacts with au.FlushAudioRenderThreadOnGC. They share the same value, with FlushAudioRenderThreadOnGCCVar being the actual integer variable used in the code.
Developers must be aware that when this variable is set to 1, it will cause all pending audio render thread commands to be flushed every time the garbage collector runs. This can have performance implications, as it may introduce additional processing overhead during garbage collection.
Best practices when using this variable include:
- Leave it at the default value (0) unless there’s a specific need to flush audio commands during GC.
- Consider the performance impact when enabling this feature, especially in performance-critical scenarios.
- Use it for debugging or troubleshooting audio-related issues that may be caused by pending render thread commands during garbage collection.
Regarding the associated variable FlushAudioRenderThreadOnGCCVar:
The purpose of FlushAudioRenderThreadOnGCCVar is to serve as the actual storage for the au.FlushAudioRenderThreadOnGC setting within the C++ code.
This variable is used directly in the FAudioDevice::OnPreGarbageCollect() function to determine whether to flush audio rendering commands before garbage collection occurs.
The value of FlushAudioRenderThreadOnGCCVar is set through the console variable system, specifically by the au.FlushAudioRenderThreadOnGC CVar.
FlushAudioRenderThreadOnGCCVar interacts directly with the au.FlushAudioRenderThreadOnGC CVar, serving as its backing storage.
Developers should be aware that modifying FlushAudioRenderThreadOnGCCVar directly in code is not recommended. Instead, they should use the console variable system to change its value.
Best practices for FlushAudioRenderThreadOnGCCVar include:
- Treat it as a read-only variable in most code contexts.
- Use the console variable system (au.FlushAudioRenderThreadOnGC) to modify its value rather than changing it directly.
- When reading its value in code, be aware that it may change at runtime due to console commands or configuration 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:156
Scope: file
Source code excerpt:
static int32 FlushAudioRenderThreadOnGCCVar = 0;
FAutoConsoleVariableRef CVarFlushAudioRenderThreadOnGC(
TEXT("au.FlushAudioRenderThreadOnGC"),
FlushAudioRenderThreadOnGCCVar,
TEXT("When set to 1, every time the GC runs, we flush all pending audio render thread commands.\n"),
ECVF_Default);
static float MaxWorldDistanceCVar = UE_OLD_WORLD_MAX;
FAutoConsoleVariableRef CVarSetAudioMaxDistance(
#Associated Variable and Callsites
This variable is associated with another variable named FlushAudioRenderThreadOnGCCVar
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/AudioDevice.cpp:154
Scope: file
Source code excerpt:
ECVF_Default);
static int32 FlushAudioRenderThreadOnGCCVar = 0;
FAutoConsoleVariableRef CVarFlushAudioRenderThreadOnGC(
TEXT("au.FlushAudioRenderThreadOnGC"),
FlushAudioRenderThreadOnGCCVar,
TEXT("When set to 1, every time the GC runs, we flush all pending audio render thread commands.\n"),
ECVF_Default);
static float MaxWorldDistanceCVar = UE_OLD_WORLD_MAX;
FAutoConsoleVariableRef CVarSetAudioMaxDistance(
TEXT("au.MaxWorldDistance"),
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/AudioDevice.cpp:696
Scope (from outer to inner):
file
function void FAudioDevice::OnPreGarbageCollect
Source code excerpt:
void FAudioDevice::OnPreGarbageCollect()
{
if (FlushAudioRenderThreadOnGCCVar)
{
FlushAudioRenderingCommands();
}
}
float FAudioDevice::GetLowPassFilterResonance() const