1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-15 14:02:55 +08:00

Fix waveform test beatmap accessing zip archive across multiple threads

This commit is contained in:
Dean Herbert 2019-12-19 19:48:48 +09:00
parent ed856851a1
commit 81e842f6b4
2 changed files with 24 additions and 22 deletions

View File

@ -68,8 +68,11 @@ namespace osu.Game.Tests.Visual.Editor
{ {
private readonly Drawable marker; private readonly Drawable marker;
private readonly IBindable<WorkingBeatmap> beatmap = new Bindable<WorkingBeatmap>(); [Resolved]
private IAdjustableClock adjustableClock; private IBindable<WorkingBeatmap> beatmap { get; set; }
[Resolved]
private IAdjustableClock adjustableClock { get; set; }
public AudioVisualiser() public AudioVisualiser()
{ {
@ -91,13 +94,6 @@ namespace osu.Game.Tests.Visual.Editor
}; };
} }
[BackgroundDependencyLoader]
private void load(IAdjustableClock adjustableClock, IBindable<WorkingBeatmap> beatmap)
{
this.adjustableClock = adjustableClock;
this.beatmap.BindTo(beatmap);
}
protected override void Update() protected override void Update()
{ {
base.Update(); base.Update();

View File

@ -20,23 +20,21 @@ namespace osu.Game.Tests
/// </summary> /// </summary>
public class WaveformTestBeatmap : WorkingBeatmap public class WaveformTestBeatmap : WorkingBeatmap
{ {
private readonly ZipArchiveReader reader;
private readonly Stream stream;
private readonly ITrackStore trackStore; private readonly ITrackStore trackStore;
private Stream getStream() => TestResources.GetTestBeatmapStream();
private ZipArchiveReader getZipReader() => new ZipArchiveReader(getStream());
public WaveformTestBeatmap(AudioManager audioManager) public WaveformTestBeatmap(AudioManager audioManager)
: base(new BeatmapInfo(), audioManager) : base(new BeatmapInfo(), audioManager)
{ {
stream = TestResources.GetTestBeatmapStream(); trackStore = audioManager.GetTrackStore(getZipReader());
reader = new ZipArchiveReader(stream);
trackStore = audioManager.GetTrackStore(reader);
} }
protected override void Dispose(bool isDisposing) protected override void Dispose(bool isDisposing)
{ {
base.Dispose(isDisposing); base.Dispose(isDisposing);
stream?.Dispose();
reader?.Dispose();
trackStore?.Dispose(); trackStore?.Dispose();
} }
@ -50,15 +48,23 @@ namespace osu.Game.Tests
protected override Track GetTrack() => trackStore.Get(firstAudioFile); protected override Track GetTrack() => trackStore.Get(firstAudioFile);
private string firstAudioFile => reader.Filenames.First(f => f.EndsWith(".mp3")); private string firstAudioFile
{
private Stream getBeatmapStream() => reader.GetStream(reader.Filenames.First(f => f.EndsWith(".osu"))); get
{
using (var reader = getZipReader())
return reader.Filenames.First(f => f.EndsWith(".mp3"));
}
}
private Beatmap createTestBeatmap() private Beatmap createTestBeatmap()
{ {
using (var beatmapStream = getBeatmapStream()) using (var reader = getZipReader())
{
using (var beatmapStream = reader.GetStream(reader.Filenames.First(f => f.EndsWith(".osu"))))
using (var beatmapReader = new LineBufferedReader(beatmapStream)) using (var beatmapReader = new LineBufferedReader(beatmapStream))
return Decoder.GetDecoder<Beatmap>(beatmapReader).Decode(beatmapReader); return Decoder.GetDecoder<Beatmap>(beatmapReader).Decode(beatmapReader);
} }
} }
}
} }