Update audio cvars from legacy to AZ_CVARs (#2182)

* Upgrade s_AudioLoggingOptions to AZ_CVAR

Removes this legacy CVar and reimplements it as an AZ_CVAR with similar
functionality of setting flags using alpha characters.

Signed-off-by: amzn-phist <52085794+amzn-phist@users.noreply.github.com>

* Upgrade s_DrawAudioDebug to AZ_CVAR

Removes the legacy CVar and reimplements it as an AZ_CVAR with similar
functionality and options.

Additional updates to the logging options CVar to fix up flag enums.

Signed-off-by: amzn-phist <52085794+amzn-phist@users.noreply.github.com>

* Upgrade s_FileCacheManagerDebugFilter to AZ_CVAR

Removes the legacy CVar and reimplements it as an AZ_CVAR with similar
functionality.

Signed-off-by: amzn-phist <52085794+amzn-phist@users.noreply.github.com>

* Removal of legacy IConsole dependencies from Audio

Moves a g_languageAudio cvar from CrySystem to AudioSystem.
Convert all cvar commands to AZ_CONSOLEFREEFUNC's.
Remove IConsole.h includes from source files.
Removes the CSoundCVars class.

Signed-off-by: amzn-phist <52085794+amzn-phist@users.noreply.github.com>

* Minor update to cvar comments etc.

Signed-off-by: amzn-phist <52085794+amzn-phist@users.noreply.github.com>
This commit is contained in:
amzn-phist
2021-07-16 12:25:32 -05:00
committed by GitHub
parent 23e22dbb4c
commit 4407891740
14 changed files with 511 additions and 535 deletions
+12 -8
View File
@@ -19,7 +19,6 @@
#include <ATLAudioObject.h>
#include <IAudioSystemImplementation.h>
#include <IConsole.h>
#include <ISystem.h>
#include <IPhysics.h>
#include <IRenderAuxGeom.h>
@@ -1896,9 +1895,14 @@ namespace Audio
///////////////////////////////////////////////////////////////////////////////////////////////////
void CAudioTranslationLayer::SetImplLanguage()
{
if (ICVar* pCVar = gEnv->pConsole->GetCVar("g_languageAudio"))
if (auto console = AZ::Interface<AZ::IConsole>::Get(); console != nullptr)
{
AudioSystemImplementationRequestBus::Broadcast(&AudioSystemImplementationRequestBus::Events::SetLanguage, pCVar->GetString());
AZ::CVarFixedString languageAudio;
if (auto result = console->GetCvarValue("g_languageAudio", languageAudio); result == AZ::GetValueResult::Success)
{
AudioSystemImplementationRequestBus::Broadcast(
&AudioSystemImplementationRequestBus::Events::SetLanguage, languageAudio.data());
}
}
}
@@ -2014,7 +2018,7 @@ namespace Audio
AZ_PROFILE_FUNCTION(AZ::Debug::ProfileCategory::Audio);
// ToDo: Update to work with Atom? LYN-3677
/*if (g_audioCVars.m_nDrawAudioDebug > 0)
/*if (CVars::s_debugDrawOptions.GetRawFlags() != 0)
{
DrawAudioObjectDebugInfo(*pAuxGeom); // needs to be called first so that the rest of the labels are printed
// on top (Draw2dLabel doesn't provide a way set which labels are printed on top)
@@ -2112,23 +2116,23 @@ namespace Audio
{
m_oFileCacheMgr.DrawDebugInfo(auxGeom, fPosX, fPosY);
if ((g_audioCVars.m_nDrawAudioDebug & eADDF_SHOW_IMPL_MEMORY_POOL_USAGE) != 0)
if (CVars::s_debugDrawOptions.AreAllFlagsActive(DebugDraw::Options::MemoryInfo))
{
DrawImplMemoryPoolDebugInfo(auxGeom, fPosX, fPosY);
}
if ((g_audioCVars.m_nDrawAudioDebug & eADDF_SHOW_ACTIVE_OBJECTS) != 0)
if (CVars::s_debugDrawOptions.AreAllFlagsActive(DebugDraw::Options::ActiveObjects))
{
m_oAudioObjectMgr.DrawDebugInfo(auxGeom, fPosX, fPosY);
fPosX += 800.0f;
}
if ((g_audioCVars.m_nDrawAudioDebug & eADDF_SHOW_ACTIVE_EVENTS) != 0)
if (CVars::s_debugDrawOptions.AreAllFlagsActive(DebugDraw::Options::ActiveEvents))
{
m_oAudioEventMgr.DrawDebugInfo(auxGeom, fPosX, fPosY);
}
if ((g_audioCVars.m_nDrawAudioDebug & eADDF_DRAW_LISTENER_SPHERE) != 0)
if (CVars::s_debugDrawOptions.AreAllFlagsActive(DebugDraw::Options::DrawListener))
{
m_oAudioListenerMgr.DrawDebugInfo(auxGeom);
}
@@ -23,7 +23,6 @@
#include <IRenderer.h>
#include <IRenderAuxGeom.h>
#include <IConsole.h>
namespace Audio
{
@@ -850,7 +849,7 @@ namespace Audio
{
const float fDist = vPos.GetDistance(vListenerPos);
if ((g_audioCVars.m_nDrawAudioDebug & eADDF_DRAW_SPHERES) != 0)
if (CVars::s_debugDrawOptions.AreAllFlagsActive(DebugDraw::Options::DrawObjects))
{
const SAuxGeomRenderFlags nPreviousRenderFlags = auxGeom.GetRenderFlags();
SAuxGeomRenderFlags nNewRenderFlags(e_Def3DPublicRenderflags | e_AlphaBlended);
@@ -865,7 +864,7 @@ namespace Audio
const float fFontSize = 1.3f;
const float fLineHeight = 12.0f;
if ((g_audioCVars.m_nDrawAudioDebug & eADDF_SHOW_OBJECT_STATES) != 0)
if (CVars::s_debugDrawOptions.AreAllFlagsActive(DebugDraw::Options::ObjectStates))
{
AZ::Vector3 vSwitchPos(vScreenPos);
@@ -901,7 +900,7 @@ namespace Audio
const AZ::Color normalTextColor(0.75f, 0.75f, 0.75f, 1.f);
const AZ::Color dimmedTextColor(0.5f, 0.5f, 0.5f, 1.f);
if ((g_audioCVars.m_nDrawAudioDebug & eADDF_SHOW_OBJECT_LABEL) != 0)
if (CVars::s_debugDrawOptions.AreAllFlagsActive(DebugDraw::Options::ObjectLabels))
{
const TAudioObjectID nObjectID = GetID();
auxGeom.Draw2dLabel(
@@ -931,7 +930,7 @@ namespace Audio
);
}
if ((g_audioCVars.m_nDrawAudioDebug & eADDF_SHOW_OBJECT_TRIGGERS) != 0)
if (CVars::s_debugDrawOptions.AreAllFlagsActive(DebugDraw::Options::ObjectTriggers))
{
AZStd::string triggerStringFormatted;
@@ -963,7 +962,7 @@ namespace Audio
triggerStringFormatted.c_str());
}
if ((g_audioCVars.m_nDrawAudioDebug & eADDF_SHOW_OBJECT_RTPCS) != 0)
if (CVars::s_debugDrawOptions.AreAllFlagsActive(DebugDraw::Options::ObjectRtpcs))
{
AZ::Vector3 vRtpcPos(vScreenPos);
@@ -990,7 +989,7 @@ namespace Audio
}
}
if ((g_audioCVars.m_nDrawAudioDebug & eADDF_SHOW_OBJECT_ENVIRONMENTS) != 0)
if (CVars::s_debugDrawOptions.AreAllFlagsActive(DebugDraw::Options::ObjectEnvironments))
{
AZ::Vector3 vEnvPos(vScreenPos);
@@ -1041,8 +1040,8 @@ namespace Audio
newRenderFlags.SetCullMode(e_CullModeNone);
auxGeom.SetRenderFlags(newRenderFlags);
const bool drawRays = ((g_audioCVars.m_nDrawAudioDebug & eADDF_DRAW_OBSTRUCTION_RAYS) != 0);
const bool drawLabels = ((g_audioCVars.m_nDrawAudioDebug & eADDF_SHOW_OBSTRUCTION_RAY_LABELS) != 0);
const bool drawRays = CVars::s_debugDrawOptions.AreAllFlagsActive(DebugDraw::Options::DrawRays);
const bool drawLabels = CVars::s_debugDrawOptions.AreAllFlagsActive(DebugDraw::Options::RayLabels);
size_t numRays = m_obstOccType == eAOOCT_SINGLE_RAY ? 1 : s_maxRaysPerObject;
for (size_t rayIndex = 0; rayIndex < numRays; ++rayIndex)
@@ -29,7 +29,6 @@
#include <MathConversion.h>
#include <IRenderAuxGeom.h>
#include <IConsole.h>
namespace Audio
{
@@ -899,25 +899,38 @@ namespace Audio
///////////////////////////////////////////////////////////////////////////////////////////////////
#if !defined(AUDIO_RELEASE)
// Filter for drawing debug info to the screen
enum EAudioDebugDrawFilter : TATLEnumFlagsType
namespace DebugDraw
{
eADDF_NONE = 0,
eADDF_DRAW_SPHERES = AUDIO_BIT(6),// a
eADDF_SHOW_OBJECT_LABEL = AUDIO_BIT(7),// b
eADDF_SHOW_OBJECT_TRIGGERS = AUDIO_BIT(8),// c
eADDF_SHOW_OBJECT_STATES = AUDIO_BIT(9),// d
eADDF_SHOW_OBJECT_RTPCS = AUDIO_BIT(10),// e
eADDF_SHOW_OBJECT_ENVIRONMENTS = AUDIO_BIT(11),// f
eADDF_DRAW_OBSTRUCTION_RAYS = AUDIO_BIT(12),// g
eADDF_SHOW_OBSTRUCTION_RAY_LABELS = AUDIO_BIT(13),// h
eADDF_DRAW_LISTENER_SPHERE = AUDIO_BIT(14),// i
enum Options : AZ::u32
{
None = 0,
DrawObjects = (1 << 0),
ObjectLabels = (1 << 1),
ObjectTriggers = (1 << 2),
ObjectStates = (1 << 3),
ObjectRtpcs = (1 << 4),
ObjectEnvironments = (1 << 5),
DrawRays = (1 << 6),
RayLabels = (1 << 7),
DrawListener = (1 << 8),
ActiveEvents = (1 << 9),
ActiveObjects = (1 << 10),
FileCacheInfo = (1 << 11),
MemoryInfo = (1 << 12),
};
}
eADDF_SHOW_ACTIVE_EVENTS = AUDIO_BIT(27),// v
eADDF_SHOW_ACTIVE_OBJECTS = AUDIO_BIT(28),// w
eADDF_SHOW_FILECACHE_MANAGER_INFO = AUDIO_BIT(29),// x
eADDF_SHOW_IMPL_MEMORY_POOL_USAGE = AUDIO_BIT(30),// y
};
namespace FileCacheManagerDebugDraw
{
enum Options : AZ::u8
{
All = 0,
Global = (1 << 0),
LevelSpecific = (1 << 1),
UseCounted = (1 << 2),
Loaded = (1 << 3),
};
}
#endif // !AUDIO_RELEASE
} // namespace Audio
@@ -699,7 +699,7 @@ namespace Audio
{
AZ_Assert(gEnv->mMainThreadId == CryGetCurrentThreadId(), "AudioSystem::DrawAudioDebugData - called from non-Main thread!");
if (g_audioCVars.m_nDrawAudioDebug > 0)
if (CVars::s_debugDrawOptions.GetRawFlags() != 0)
{
SAudioRequest oRequest;
oRequest.nFlags = (eARF_PRIORITY_HIGH | eARF_EXECUTE_BLOCKING);
@@ -339,20 +339,17 @@ namespace Audio
///////////////////////////////////////////////////////////////////////////////////////////////
void CFileCacheManager::DrawDebugInfo(IRenderAuxGeom& auxGeom, const float posX, const float posY)
{
if ((g_audioCVars.m_nDrawAudioDebug & eADDF_SHOW_FILECACHE_MANAGER_INFO) != 0)
if (CVars::s_debugDrawOptions.AreAllFlagsActive(DebugDraw::Options::FileCacheInfo))
{
EATLDataScope dataScope = eADS_ALL;
if ((g_audioCVars.m_nFileCacheManagerDebugFilter & eAFCMDF_ALL) == 0)
if (CVars::s_fcmDrawOptions.AreAllFlagsActive(FileCacheManagerDebugDraw::Options::Global))
{
if ((g_audioCVars.m_nFileCacheManagerDebugFilter & eAFCMDF_GLOBALS) != 0)
{
dataScope = eADS_GLOBAL;
}
else if ((g_audioCVars.m_nFileCacheManagerDebugFilter & eAFCMDF_LEVEL_SPECIFICS) != 0)
{
dataScope = eADS_LEVEL_SPECIFIC;
}
dataScope = eADS_GLOBAL;
}
else if (CVars::s_fcmDrawOptions.AreAllFlagsActive(FileCacheManagerDebugDraw::Options::LevelSpecific))
{
dataScope = eADS_LEVEL_SPECIFIC;
}
const auto frameTime = AZStd::chrono::system_clock::now();
@@ -381,11 +378,11 @@ namespace Audio
"FileCacheManager (%zu of %zu KiB) [Entries: %zu]", m_currentByteTotal >> 10, m_maxByteTotal >> 10, m_audioFileEntries.size());
positionY += 15.0f;
bool displayAll = (g_audioCVars.m_nFileCacheManagerDebugFilter == eAFCMDF_ALL);
bool displayGlobals = ((g_audioCVars.m_nFileCacheManagerDebugFilter & eAFCMDF_GLOBALS) != 0);
bool displayLevels = ((g_audioCVars.m_nFileCacheManagerDebugFilter & eAFCMDF_LEVEL_SPECIFICS) != 0);
bool displayUseCounted = ((g_audioCVars.m_nFileCacheManagerDebugFilter & eAFCMDF_USE_COUNTED) != 0);
bool displayLoaded = ((g_audioCVars.m_nFileCacheManagerDebugFilter & eAFCMDF_LOADED) != 0);
const bool displayAll = CVars::s_fcmDrawOptions.GetRawFlags() == 0;
const bool displayGlobals = CVars::s_fcmDrawOptions.AreAllFlagsActive(FileCacheManagerDebugDraw::Options::Global);
const bool displayLevels = CVars::s_fcmDrawOptions.AreAllFlagsActive(FileCacheManagerDebugDraw::Options::LevelSpecific);
const bool displayUseCounted = CVars::s_fcmDrawOptions.AreAllFlagsActive(FileCacheManagerDebugDraw::Options::UseCounted);
const bool displayLoaded = CVars::s_fcmDrawOptions.AreAllFlagsActive(FileCacheManagerDebugDraw::Options::Loaded);
for (auto& audioFileEntryPair : m_audioFileEntries)
{
@@ -100,16 +100,4 @@ namespace Audio
size_t m_currentByteTotal;
size_t m_maxByteTotal;
};
///////////////////////////////////////////////////////////////////////////////////////////////
// Filter for drawing debug info to the screen
enum EAudioFileCacheManagerDebugFilter
{
eAFCMDF_ALL = 0,
eAFCMDF_GLOBALS = AUDIO_BIT(6), // a
eAFCMDF_LEVEL_SPECIFICS = AUDIO_BIT(7), // b
eAFCMDF_USE_COUNTED = AUDIO_BIT(8), // c
eAFCMDF_LOADED = AUDIO_BIT(9), // d
};
} // namespace Audio
File diff suppressed because it is too large Load Diff
@@ -8,14 +8,11 @@
#pragma once
#include <IAudioSystem.h>
#include <ATLUtils.h>
#include <AzCore/Console/IConsole.h>
struct IConsoleCmdArgs;
namespace Audio::CVars
{
///////////////////////////////////////////////////////////////////////////////////////////////////
AZ_CVAR_EXTERNED(AZ::u64, s_ATLMemorySize);
AZ_CVAR_EXTERNED(AZ::u64, s_FileCacheManagerMemorySize);
AZ_CVAR_EXTERNED(AZ::u64, s_AudioObjectPoolSize);
@@ -31,48 +28,18 @@ namespace Audio::CVars
AZ_CVAR_EXTERNED(float, s_VelocityTrackingThreshold);
AZ_CVAR_EXTERNED(AZ::u32, s_AudioProxiesInitType);
AZ_CVAR_EXTERNED(AZ::CVarFixedString, g_languageAudio);
#if !defined(AUDIO_RELEASE)
AZ_CVAR_EXTERNED(bool, s_IgnoreWindowFocus);
AZ_CVAR_EXTERNED(bool, s_ShowActiveAudioObjectsOnly);
AZ_CVAR_EXTERNED(AZ::CVarFixedString, s_AudioTriggersDebugFilter);
AZ_CVAR_EXTERNED(AZ::CVarFixedString, s_AudioObjectsDebugFilter);
AZ_CVAR_EXTERNED(AZ::CVarFixedString, s_AudioLoggingOptions);
AZ_CVAR_EXTERNED(AZ::CVarFixedString, s_DrawAudioDebug);
inline Audio::Flags<AZ::u32> s_debugDrawOptions;
AZ_CVAR_EXTERNED(AZ::CVarFixedString, s_FileCacheManagerDebugFilter);
inline Audio::Flags<AZ::u32> s_fcmDrawOptions;
#endif // !AUDIO_RELEASE
} // namespace Audio::CVars
namespace Audio
{
///////////////////////////////////////////////////////////////////////////////////////////////////
class CSoundCVars
{
public:
CSoundCVars();
~CSoundCVars() = default;
CSoundCVars(const CSoundCVars&) = delete; // Copy protection
CSoundCVars& operator=(const CSoundCVars&) = delete; // Copy protection
void RegisterVariables();
void UnregisterVariables();
#if !defined(AUDIO_RELEASE)
int m_nDrawAudioDebug;
int m_nFileCacheManagerDebugFilter;
int m_nAudioLoggingOptions;
private:
static void CmdExecuteTrigger(IConsoleCmdArgs* pCmdArgs);
static void CmdStopTrigger(IConsoleCmdArgs* pCmdArgs);
static void CmdSetRtpc(IConsoleCmdArgs* pCmdArgs);
static void CmdSetSwitchState(IConsoleCmdArgs* pCmdArgs);
static void CmdLoadPreload(IConsoleCmdArgs* pCmdArgs);
static void CmdUnloadPreload(IConsoleCmdArgs* pCmdArgs);
static void CmdPlayFile(IConsoleCmdArgs* pCmdArgs);
static void CmdMicrophone(IConsoleCmdArgs* pCmdArgs);
static void CmdPlayExternalSource(IConsoleCmdArgs* pCmdArgs);
static void CmdSetPanningMode(IConsoleCmdArgs* pCmdArgs);
#endif // !AUDIO_RELEASE
};
extern CSoundCVars g_audioCVars;
} // namespace Audio