osu/osu.Game/Beatmaps/WorkingBeatmap.cs
2016-10-28 18:03:26 +09:00

60 lines
1.5 KiB
C#

//Copyright (c) 2007-2016 ppy Pty Ltd <contact@ppy.sh>.
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
using osu.Framework.Audio.Track;
using osu.Game.Beatmaps.IO;
namespace osu.Game.Beatmaps
{
public class WorkingBeatmap : IDisposable
{
public readonly ArchiveReader Reader;
public readonly Beatmap Beatmap;
private AudioTrack track;
public AudioTrack Track
{
get
{
if (track == null)
{
try
{
var trackData = Reader.ReadFile(Beatmap.Metadata.AudioFile);
if (trackData != null)
track = new AudioTrackBass(trackData);
}
catch { }
}
return track;
}
set { track = value; }
}
public WorkingBeatmap(Beatmap beatmap, ArchiveReader reader = null)
{
Beatmap = beatmap;
Reader = reader;
}
private bool isDisposed;
protected virtual void Dispose(bool disposing)
{
if (!isDisposed)
{
track?.Dispose();
Reader?.Dispose();
isDisposed = true;
}
}
public void Dispose()
{
Dispose(true);
}
}
}