1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-16 08:02:54 +08:00

Merge pull request #259 from peppy/general-fixes

Keep reference to reader to avoid early disposal.
This commit is contained in:
Thomas Müller 2016-12-18 12:50:58 +01:00 committed by GitHub
commit 401d3c1907

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 { }