Navigation
API > API/Runtime > API/Runtime/Engine
Basic fixed-size LRU cache for retaining chunks of compressed audio data.
| Name | FAudioChunkCache |
| Type | class |
| Header File | /Engine/Source/Runtime/Engine/Public/AudioStreamingCache.h |
| Include Path | #include "AudioStreamingCache.h" |
Syntax
class FAudioChunkCache
Constructors
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
FAudioChunkCache
(
uint32 InMaxChunkSize, |
AudioStreamingCache.h |
Destructors
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
~FAudioChunkCache() |
AudioStreamingCache.h |
Structs
| Name | Remarks |
|---|---|
| FCacheElement | Struct containing a single element in our LRU Cache. |
| FCacheElementDebugInfo | This struct lets us breadcrumb debug information. |
| FCacheMissEntry | |
| FCacheMissInfo | This struct is used for logging cache misses. |
| FChunkKey | |
| FSoundWaveMemoryTracker |
Enums
Public
| Name | Remarks |
|---|---|
| EDebugDisplayElementTypes | This is for debugging purposes only. |
Variables
Public
| Name | Type | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|---|
| MaxChunkSize | const int32 | AudioStreamingCache.h |
Protected
| Name | Type | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|---|
| bLogCacheMisses | bool | This is set to true when BeginLoggingCacheMisses is called. | AudioStreamingCache.h | |
| CacheLookupIdMap | TMap< FChunkKey, uint64 > | Map that USoundWaves, FSoundWaveProxys, FChunkKeys, and FAudioChunkHandles can use to quickly lookup where their chunks are currently stored in the cache | AudioStreamingCache.h | |
| CacheMissQueue | TUniqueObj< TQueue< FCacheMissInfo > > | This queue is pushed to anytime GetChunk fails to get the chunk. and bLogCacheMisses is true. | AudioStreamingCache.h | |
| CacheMutationCriticalSection | TDontCopy< FCriticalSection > | Critical section: only used when we are modifying element positions in the cache. | AudioStreamingCache.h | |
| CacheOverflowCount | FThreadSafeCounter | Counter for the number of times this cache has overflown | AudioStreamingCache.h | |
| CachePool | TArray< FCacheElement > | Our actual memory pool. | AudioStreamingCache.h | |
| ChunksInUse | int32 | This is incremented on every call of InsertChunk until we hit CachePool.Num() or MemoryCounterBytes hits MemoryLimitBytes. | AudioStreamingCache.h | |
| FeatureMemoryCounterBytes | TUniqueObj< TAtomic< uint64 > > | AudioStreamingCache.h | ||
| ForceInlineMemoryCounterBytes | TUniqueObj< TAtomic< uint64 > > | AudioStreamingCache.h | ||
| LeastRecentElement | FCacheElement * | AudioStreamingCache.h | ||
| MemoryCounterBytes | TUniqueObj< TAtomic< uint64 > > | This counter is used to start evicting chunks before we hit CachePool.Num(). | AudioStreamingCache.h | |
| MemoryLimitBytes | uint64 | AudioStreamingCache.h | ||
| MostRecentElement | FCacheElement * | AudioStreamingCache.h | ||
| NumberOfLoadsInFlight | FThreadSafeCounter | Number of async load operations we have currently in flight. | AudioStreamingCache.h | |
| SoundWaveMemoryTrackerCritSec | TDontCopy< FCriticalSection > | AudioStreamingCache.h | ||
| SoundWaveTracker | TMap< FSoundWaveProxyPtr, FSoundWaveMemoryTracker > | A map to look up the number of times a sound wave has been added for memory tracking as well as the memory added for the "latest" addition | AudioStreamingCache.h | |
| TimeOfBeginPlayCycles | uint64 | Time begin play came in. (so we can validate load times against load screen/vs level loads). | AudioStreamingCache.h |
Functions
Public
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
void AddForceInlineSoundWave
(
const FSoundWaveProxyPtr& |
AudioStreamingCache.h | ||
void AddMemoryCountedFeature
(
const FAudioStreamCacheMemoryHandle& Feature |
AudioStreamingCache.h | ||
void AddNewReferenceToChunk
(
const FChunkKey& InKey |
Add an additional reference for a chunk. | AudioStreamingCache.h | |
uint64 AddOrTouchChunk
(
const FChunkKey& InKey, |
Places chunk in cache, or puts this chunk back at the top of the cache if it's already loaded. | AudioStreamingCache.h | |
void BeginLoggingCacheMisses () |
Debug tools: Call this to start enqueing reports on any cache misses to a queue. | AudioStreamingCache.h | |
void BlockForAllPendingLoads() |
This function will continue to lock until any async file loads are finished. | AudioStreamingCache.h | |
void CancelAllPendingLoads() |
This function will cancel any in-flight loads and wait for their completion. | AudioStreamingCache.h | |
void ClearCache() |
Evict all sounds from the cache. Does not account for force inline sounds. | AudioStreamingCache.h | |
| AudioStreamingCache.h | |||
| AudioStreamingCache.h | |||
TPair< int, int > DebugDisplayLegacy
(
UWorld* World, |
This is for debugging purposes only. | AudioStreamingCache.h | |
FString DebugPrint() |
Generate a formatted text file for this cache. | AudioStreamingCache.h | |
| AudioStreamingCache.h | |||
FString FlushCacheMissLog() |
When called, flushes the entire queue of cache misses that has accumulated And prints them to a formatted | AudioStreamingCache.h | |
uint64 GetCacheLookupIDForChunk
(
const FChunkKey& InChunkKey |
Interface with the cache id lookup map | AudioStreamingCache.h | |
TArrayView< uint8 > GetChunk
(
const FChunkKey& InKey, |
Returns the chunk asked for, or an empty TArrayView if that chunk is not loaded. | AudioStreamingCache.h | |
TArray< FObjectKey > GetLeastRecentlyUsedRetainedSoundWaves
(
int32 NumSoundWavesToRetrieve |
Returns an array of the USoundwaves retaining the least recently used retained chunks in the cache. | AudioStreamingCache.h | |
int32 GetNumberOfCacheOverflows() |
AudioStreamingCache.h | ||
void HandleStarvation
(
const FSoundWaveProxyPtr& SoundWave, |
AudioStreamingCache.h | ||
void IncrementCacheOverflowCounter() |
AudioStreamingCache.h | ||
void RemoveForceInlineSoundWave
(
const FSoundWaveProxyPtr& |
AudioStreamingCache.h | ||
void RemoveMemoryCountedFeature
(
const FAudioStreamCacheMemoryHandle& Feature |
AudioStreamingCache.h | ||
void RemoveReferenceToChunk
(
const FChunkKey& InKey |
AudioStreamingCache.h | ||
uint64 ReportCacheSize() |
Reports the size of this cache's memory pool, in bytes. | AudioStreamingCache.h | |
void SetCacheLookupIDForChunk
(
const FChunkKey& InChunkKey, |
AudioStreamingCache.h | ||
void StopLoggingCacheMisses() |
This will stop enqueueing reports of cache misses. | AudioStreamingCache.h | |
uint64 TrimMemory
(
uint64 BytesToFree, |
This function will reclaim memory by freeing as many chunks as needed to free BytesToFree. | AudioStreamingCache.h |
Static
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
static bool DoesKeyContainValidChunkIndex
(
const FChunkKey& InKey, |
Static helper function to make sure a chunk is withing the bounds of a USoundWave. | AudioStreamingCache.h | |
static void ExecuteOnLoadCompleteCallback
(
EAudioChunkLoadResult Result, |
Calls OnLoadCompleted on current thread if CallbackThread == ENamedThreads::AnyThread, and dispatchs an async task on a named thread otherwise. | AudioStreamingCache.h |