Vulkan Schnee 0.0.1 (22840dc8)
High-performance rendering engine
Loading...
Searching...
No Matches
Engine::Core::AudioClipStore Class Reference

Registry store for authored audio clip handles. More...

#include <AssetRegistry.h>

Collaboration diagram for Engine::Core::AudioClipStore:

Classes

struct  Record
 Stored metadata for one audio clip handle slot. More...

Public Member Functions

 AudioClipStore (AssetManager *assetManager=nullptr)
 Creates an audio clip store backed by an optional asset manager.
void setAssetManager (AssetManager *assetManager)
 Sets the asset manager used when new audio handles request payload loading.
Assets::AudioClipHandle load (const Asset::Path &source)
 Gets or creates a stable handle for an authored audio source path.
Assets::AudioClipHandle load (const std::filesystem::path &source)
 Gets or creates a stable handle for an authored audio source path.
bool isValid (Assets::AudioClipHandle handle) const
 Checks whether an audio clip handle refers to a live slot in this store.
const Asset::Path * sourcePath (Assets::AudioClipHandle handle) const
 Returns the authored source path for an audio clip handle.
Asset::LoadState state (Assets::AudioClipHandle handle) const
 Returns the current CPU loading state of the payload behind a clip handle.
bool isLoaded (Assets::AudioClipHandle handle) const
 Checks whether the payload behind a clip handle has finished loading.
bool isLoading (Assets::AudioClipHandle handle) const
 Checks whether the payload behind a clip handle is currently being loaded.
Assets::Audio * payload (Assets::AudioClipHandle handle) const
 Returns the loaded payload behind a clip handle, or nullptr when not yet loaded.

Static Private Member Functions

static std::string keyFor (const Asset::Path &source)
 Builds the deduplication key for an audio source path.

Private Attributes

AssetManager * assetManager_ = nullptr
 Optional bridge used to request legacy audio refs.
std::vector< Record > records_
 Slot storage indexed by AudioClipHandle::index.
std::unordered_map< std::string, uint32_t > sourceToIndex_
 Deduplication map from keyFor() to slot index.

Detailed Description

Registry store for authored audio clip handles.

AudioClipStore deduplicates source paths, returns stable AudioClipHandle values, and can reconstruct authored audio refs from handles. Each slot also tracks the loading state of its backing payload (via the legacy AudioAssetRef) so gameplay code can query readiness and pull the loaded payload straight off the handle — the audio analog of the bindless "swap at the end of the handle" model.

Definition at line 319 of file AssetRegistry.h.

Constructor & Destructor Documentation

◆ AudioClipStore()

Engine::Core::AudioClipStore::AudioClipStore ( AssetManager * assetManager = nullptr)
explicit

Creates an audio clip store backed by an optional asset manager.

Parameters
assetManagerAsset manager used to request audio payload loads, or nullptr for handle-only use.

Member Function Documentation

◆ isLoaded()

bool Engine::Core::AudioClipStore::isLoaded ( Assets::AudioClipHandle handle) const
nodiscard

Checks whether the payload behind a clip handle has finished loading.

Parameters
handleClip handle to query.
Returns
True when the backing record is LOADED and a payload is available.

◆ isLoading()

bool Engine::Core::AudioClipStore::isLoading ( Assets::AudioClipHandle handle) const
nodiscard

Checks whether the payload behind a clip handle is currently being loaded.

Parameters
handleClip handle to query.
Returns
True when the backing record is REQUESTED_LOAD or LOADING.

◆ isValid()

bool Engine::Core::AudioClipStore::isValid ( Assets::AudioClipHandle handle) const
nodiscard

Checks whether an audio clip handle refers to a live slot in this store.

Parameters
handleHandle to validate.
Returns
True when the handle index and generation match a stored record.

◆ keyFor()

std::string Engine::Core::AudioClipStore::keyFor ( const Asset::Path & source)
staticnodiscardprivate

Builds the deduplication key for an audio source path.

Parameters
sourceEngine-relative audio source path.
Returns
Stable string key used by sourceToIndex_.

◆ load() [1/2]

Assets::AudioClipHandle Engine::Core::AudioClipStore::load ( const Asset::Path & source)
nodiscard

Gets or creates a stable handle for an authored audio source path.

Parameters
sourceEngine-relative audio source path.
Returns
Existing or newly created audio clip handle, or a null handle for an empty source path.
Exceptions
std::invalid_argumentwhen source contains an absolute source path.

◆ load() [2/2]

Assets::AudioClipHandle Engine::Core::AudioClipStore::load ( const std::filesystem::path & source)
nodiscard

Gets or creates a stable handle for an authored audio source path.

Parameters
sourceEngine-relative audio source path.
Returns
Existing or newly created audio clip handle, or a null handle for an empty source path.

◆ payload()

Assets::Audio * Engine::Core::AudioClipStore::payload ( Assets::AudioClipHandle handle) const
nodiscard

Returns the loaded payload behind a clip handle, or nullptr when not yet loaded.

The payload is swapped in automatically once the async decode completes (the record is resolved through the AudioAssetManager), so polling this is the "switch out the resource at the end of the handle" check for audio.

Parameters
handleClip handle to look up.
Returns
Loaded Audio payload, or nullptr when the handle is invalid or the payload is not loaded.

◆ setAssetManager()

void Engine::Core::AudioClipStore::setAssetManager ( AssetManager * assetManager)

Sets the asset manager used when new audio handles request payload loading.

Parameters
assetManagerAsset manager to use, or nullptr to disable payload load requests.

◆ sourcePath()

const Asset::Path * Engine::Core::AudioClipStore::sourcePath ( Assets::AudioClipHandle handle) const
nodiscard

Returns the authored source path for an audio clip handle.

Parameters
handleHandle to look up.
Returns
Pointer to the stored source path, or nullptr when the handle is invalid.

◆ state()

Asset::LoadState Engine::Core::AudioClipStore::state ( Assets::AudioClipHandle handle) const
nodiscard

Returns the current CPU loading state of the payload behind a clip handle.

Parameters
handleClip handle to query.
Returns
State of the backing asset record, or UNLOADED when the handle is invalid or the record expired.

Member Data Documentation

◆ assetManager_

AssetManager* Engine::Core::AudioClipStore::assetManager_ = nullptr
private

Optional bridge used to request legacy audio refs.

Definition at line 415 of file AssetRegistry.h.

◆ records_

std::vector<Record> Engine::Core::AudioClipStore::records_
private

Slot storage indexed by AudioClipHandle::index.

Definition at line 416 of file AssetRegistry.h.

◆ sourceToIndex_

std::unordered_map<std::string, uint32_t> Engine::Core::AudioClipStore::sourceToIndex_
private

Deduplication map from keyFor() to slot index.

Definition at line 417 of file AssetRegistry.h.


The documentation for this class was generated from the following file:
  • /workspace/magerbeton/gl3-vulkan/code/Engine/include/Engine/Asset/AssetRegistry.h