1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 12:17:26 +08:00

Keep reference to reader to avoid early disposal.

This commit is contained in:
Dean Herbert 2016-12-18 20:47:00 +09:00
parent f14a9e7d6b
commit 1d5dc77c4d

View File

@ -67,6 +67,7 @@ namespace osu.Game.Beatmaps
set { lock (beatmapLock) beatmap = value; }
}
private ArchiveReader trackReader;
private AudioTrack track;
private object trackLock = new object();
public AudioTrack Track
@ -79,12 +80,11 @@ namespace osu.Game.Beatmaps
try
{
using (var reader = GetReader())
{
var trackData = reader?.GetStream(BeatmapInfo.Metadata.AudioFile);
if (trackData != null)
track = new AudioTrackBass(trackData);
}
//store a reference to the reader as we may continue accessing the stream in the background.
trackReader = GetReader();
var trackData = trackReader?.GetStream(BeatmapInfo.Metadata.AudioFile);
if (trackData != null)
track = new AudioTrackBass(trackData);
}
catch { }