au.Quartz.DecrementSlotIndexOnStarted

au.Quartz.DecrementSlotIndexOnStarted

#Overview

name: au.Quartz.DecrementSlotIndexOnStarted

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.Quartz.DecrementSlotIndexOnStarted is to control the behavior of delegate management in the Quartz audio system, specifically addressing a delegate leak issue.

This setting variable is primarily used in the Quartz subsystem of Unreal Engine’s audio module. It’s part of the engine’s sound system, particularly focusing on the management of audio-related delegates.

The value of this variable is set using a console variable (CVar) system. It’s initialized to 1 by default, which enables the delegate leak fix. Developers can change this value at runtime using console commands.

The associated variable DecrementSlotIndexOnStartedCvar directly interacts with au.Quartz.DecrementSlotIndexOnStarted. They share the same value, with DecrementSlotIndexOnStartedCvar being the actual integer variable used in the code logic.

Developers must be aware that this variable affects the behavior of delegate management in the Quartz system. When set to 1 (default), it enables a fix for a delegate leak issue. Setting it to 0 reverts to the pre-fix behavior.

Best practices when using this variable include:

  1. Generally, leave it at the default value (1) to benefit from the delegate leak fix.
  2. Only set it to 0 if you need to revert to the old behavior for compatibility reasons or if you encounter issues with the new behavior.
  3. Monitor delegate performance and memory usage when changing this value, especially in audio-heavy scenarios.

Regarding the associated variable DecrementSlotIndexOnStartedCvar:

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Classes/Sound/QuartzSubscription.cpp:7

Scope: file

Source code excerpt:

static int32 DecrementSlotIndexOnStartedCvar = 1;
FAutoConsoleVariableRef CVarDecrementSlotIndexOnStarted(
	TEXT("au.Quartz.DecrementSlotIndexOnStarted"),
	DecrementSlotIndexOnStartedCvar,
	TEXT("Defaults to 1 to enable the delegate leak fix.  Set to 0 to revert to pre-fix behavior.\n")
	TEXT("1: New Behavior, 0: Old Behavior"),
	ECVF_Default);

namespace Audio

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Classes/Sound/QuartzSubscription.cpp:5

Scope: file

Source code excerpt:



static int32 DecrementSlotIndexOnStartedCvar = 1;
FAutoConsoleVariableRef CVarDecrementSlotIndexOnStarted(
	TEXT("au.Quartz.DecrementSlotIndexOnStarted"),
	DecrementSlotIndexOnStartedCvar,
	TEXT("Defaults to 1 to enable the delegate leak fix.  Set to 0 to revert to pre-fix behavior.\n")
	TEXT("1: New Behavior, 0: Old Behavior"),
	ECVF_Default);

namespace Audio
{

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Classes/Sound/QuartzSubscription.cpp:113

Scope (from outer to inner):

file
function     void FQuartzTickableObject::ExecCommand

Source code excerpt:

		// (end of a command)
		bool bShouldDecrement = Data.DelegateSubType == EQuartzCommandDelegateSubType::CommandOnCanceled;
		bShouldDecrement |= (DecrementSlotIndexOnStartedCvar && Data.DelegateSubType == EQuartzCommandDelegateSubType::CommandOnStarted);
			
		// are all the commands for this delegate done?
		if (bShouldDecrement && (GameThreadEntry.RefCount.Decrement() <= 0))
		{
			// free up the slot for new subscriptions on this clock handle
			GameThreadEntry.MulticastDelegate.Clear();