1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-19 19:13:21 +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; } set { lock (beatmapLock) beatmap = value; }
} }
private ArchiveReader trackReader;
private AudioTrack track; private AudioTrack track;
private object trackLock = new object(); private object trackLock = new object();
public AudioTrack Track public AudioTrack Track
@ -79,12 +80,11 @@ namespace osu.Game.Beatmaps
try try
{ {
using (var reader = GetReader()) //store a reference to the reader as we may continue accessing the stream in the background.
{ trackReader = GetReader();
var trackData = reader?.GetStream(BeatmapInfo.Metadata.AudioFile); var trackData = trackReader?.GetStream(BeatmapInfo.Metadata.AudioFile);
if (trackData != null) if (trackData != null)
track = new AudioTrackBass(trackData); track = new AudioTrackBass(trackData);
}
} }
catch { } catch { }