using AlicizaX; using YooAsset; namespace AlicizaX.Audio.Runtime { /// /// 音频数据。 /// public class AudioData : IMemory { /// /// 资源句柄。 /// public AssetHandle AssetHandle { private set; get; } /// /// 是否使用对象池。 /// public bool InPool { private set; get; } = false; /// /// 生成音频数据。 /// /// 资源操作句柄。 /// 是否使用对象池。 /// 音频数据。 internal static AudioData Alloc(AssetHandle assetHandle, bool inPool) { AudioData ret = MemoryPool.Acquire(); ret.AssetHandle = assetHandle; ret.InPool = inPool; return ret; } /// /// 回收音频数据。 /// /// internal static void DeAlloc(AudioData audioData) { if (audioData == null) return; MemoryPool.Release(audioData); } public void Clear() { bool inPool = InPool; AssetHandle handle = AssetHandle; InPool = false; AssetHandle = null; if (!inPool && handle is { IsValid: true }) handle.Dispose(); } } }