Skip to content

Commit

Permalink
Fix broken BASS tests
Browse files Browse the repository at this point in the history
  • Loading branch information
hwsmm committed Oct 30, 2023
1 parent 949ba72 commit b4a6c58
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 4 deletions.
2 changes: 1 addition & 1 deletion osu.Framework.Tests/Audio/AudioManagerWithDeviceLoss.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace osu.Framework.Tests.Audio
/// <see cref="AudioManager"/> that can simulate the loss of a device.
/// This will NOT work without a physical audio device!
/// </summary>
internal class AudioManagerWithDeviceLoss : AudioManager
internal class AudioManagerWithDeviceLoss : BassAudioManager
{
public AudioManagerWithDeviceLoss(AudioThread audioThread, ResourceStore<byte[]> trackStore, ResourceStore<byte[]> sampleStore)
: base(audioThread, trackStore, sampleStore)
Expand Down
13 changes: 11 additions & 2 deletions osu.Framework.Tests/Audio/BassTestComponents.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using osu.Framework.Audio.Sample;
using osu.Framework.Audio.Track;
using osu.Framework.Development;
using osu.Framework.Extensions;
using osu.Framework.IO.Stores;
using osu.Framework.Threading;

Expand Down Expand Up @@ -36,8 +37,16 @@ public BassTestComponents(bool init = true)

Mixer = CreateMixer();
Resources = new DllResourceStore(typeof(TrackBassTest).Assembly);
TrackStore = new TrackStore(Resources, Mixer);
SampleStore = new SampleStore(Resources, Mixer);
TrackStore = new TrackStore(Resources, Mixer, (data, name) => new TrackBass(data, name));
SampleStore = new SampleStore(Resources, Mixer, (stream, name, mixer, playbackConcurrency) =>
{
byte[] data;
using (stream)
data = stream.ReadAllBytesToArray();
return new SampleBassFactory(data, name, (BassAudioMixer)mixer, playbackConcurrency);
});

Add(TrackStore, SampleStore);
}
Expand Down
7 changes: 7 additions & 0 deletions osu.Framework.Tests/Visual/Audio/TestSceneAudioManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// See the LICENCE file in the repository root for full licence text.

using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
Expand Down Expand Up @@ -65,6 +66,12 @@ public override byte[] Get(string name)
return base.Get(name);
}

public override Stream GetStream(string name)
{
attemptedLookups.Add(name);
return base.GetStream(name);
}

public override Task<byte[]> GetAsync(string name, CancellationToken cancellationToken = default)
{
attemptedLookups.Add(name);
Expand Down
2 changes: 1 addition & 1 deletion osu.Framework/IO/Stores/ResourceStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ public virtual T Get(string name)
return default;
}

public Stream GetStream(string name)
public virtual Stream GetStream(string name)
{
if (name == null)
return null;
Expand Down

0 comments on commit b4a6c58

Please sign in to comment.