using YooAsset; namespace TEngine { /// /// 音频数据。 /// public class AudioData : MemoryObject { /// /// 资源句柄。 /// public AssetHandle AssetHandle { private set; get; } /// /// 是否使用对象池。 /// public bool InPool { private set; get; } = false; public override void InitFromPool() { } /// /// 回收到对象池。 /// public override void RecycleToPool() { if (!InPool) { AssetHandle.Dispose(); } InPool = false; AssetHandle = null; } /// /// 生成音频数据。 /// /// 资源操作句柄。 /// 是否使用对象池。 /// 音频数据。 internal static AudioData Alloc(AssetHandle assetHandle, bool inPool) { AudioData ret = MemoryPool.Acquire(); ret.AssetHandle = assetHandle; ret.InPool = inPool; ret.InitFromPool(); return ret; } /// /// 回收音频数据。 /// /// internal static void DeAlloc(AudioData audioData) { if (audioData != null) { MemoryPool.Release(audioData); audioData.RecycleToPool(); } } } }