au.SpoofFailedStreamChunkLoad

au.SpoofFailedStreamChunkLoad

#Overview

name: au.SpoofFailedStreamChunkLoad

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.SpoofFailedStreamChunkLoad is to simulate failed loading of streamed audio chunks in Unreal Engine’s audio streaming system. This setting variable is primarily used for testing and debugging purposes within the audio streaming module.

This setting variable is utilized by the Unreal Engine’s audio streaming subsystem, specifically within the Engine module. It is referenced in the AudioStreaming.cpp file, which is part of the core audio streaming implementation.

The value of this variable is set through the Unreal Engine’s console variable system. It is initialized as a static integer and exposed as a console variable using FAutoConsoleVariableRef. This allows developers to modify its value at runtime through the console or configuration files.

The associated variable SpoofFailedStreamChunkLoad directly interacts with au.SpoofFailedStreamChunkLoad. They share the same value, with SpoofFailedStreamChunkLoad being the actual integer used in the code logic, while au.SpoofFailedStreamChunkLoad is the console-accessible name.

Developers must be aware that enabling this variable (setting it to 1) will force all attempts to load streamed audio chunks to fail. This can significantly impact the game’s audio performance and should only be used for testing and debugging purposes.

Best practices when using this variable include:

  1. Only enable it in non-production builds or during specific debugging sessions.
  2. Remember to disable it (set to 0) after testing to restore normal audio streaming behavior.
  3. Use it in conjunction with other audio debugging tools to isolate and identify issues in the audio streaming system.
  4. Document its usage clearly in any testing procedures or debugging guides for the development team.

Regarding the associated variable SpoofFailedStreamChunkLoad:

This is the actual integer variable used in the code logic to control the spoofing behavior. It is checked in the FLegacyAudioStreamingManager::GetLoadedChunk function to determine whether to simulate a failed chunk load.

When SpoofFailedStreamChunkLoad is greater than 0, the function will return an empty FAudioChunkHandle, effectively simulating a failed load of the audio chunk.

Developers should be aware that this variable directly affects the behavior of the GetLoadedChunk function, which is a critical part of the audio streaming system. Any code that relies on successful chunk loading may be affected when this variable is enabled.

Best practices for using SpoofFailedStreamChunkLoad include:

  1. Use it in controlled testing environments where the impact of failed audio chunk loads can be properly evaluated.
  2. Implement proper error handling and fallback mechanisms in the audio system to gracefully handle failed chunk loads, as this variable can help test those scenarios.
  3. Consider adding logging or telemetry when this variable is enabled to track its usage and impact during testing sessions.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/AudioStreaming.cpp:15

Scope: file

Source code excerpt:

static int32 SpoofFailedStreamChunkLoad = 0;
FAutoConsoleVariableRef CVarSpoofFailedStreamChunkLoad(
	TEXT("au.SpoofFailedStreamChunkLoad"),
	SpoofFailedStreamChunkLoad,
	TEXT("Forces failing to load streamed chunks.\n")
	TEXT("0: Not Enabled, 1: Enabled"),
	ECVF_Default);

static int32 MaxConcurrentStreamsCvar = 0;

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/AudioStreaming.cpp:13

Scope: file

Source code excerpt:

#include "AudioDecompress.h"

static int32 SpoofFailedStreamChunkLoad = 0;
FAutoConsoleVariableRef CVarSpoofFailedStreamChunkLoad(
	TEXT("au.SpoofFailedStreamChunkLoad"),
	SpoofFailedStreamChunkLoad,
	TEXT("Forces failing to load streamed chunks.\n")
	TEXT("0: Not Enabled, 1: Enabled"),
	ECVF_Default);

static int32 MaxConcurrentStreamsCvar = 0;
FAutoConsoleVariableRef CVarMaxConcurrentStreams(

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/AudioStreaming.cpp:910

Scope (from outer to inner):

file
function     FAudioChunkHandle FLegacyAudioStreamingManager::GetLoadedChunk

Source code excerpt:

{
	// Check for the spoof of failing to load a stream chunk
	if (ensure(SoundWave.IsValid()) && SpoofFailedStreamChunkLoad > 0)
	{
		return FAudioChunkHandle();
	}

	// If we fail at getting the critical section here, early out. 
	if (!CriticalSection.TryLock())