Use fire-and-forget async operations on global track

This avoids any blocking overhead caused by a backlogged audio thread.
Test seem to pass so might be okay?

Note that order is still guaranteed due to the `ensureUpdateThread`
queueing system framework-side.
This commit is contained in:
Dean Herbert
2022-07-06 16:32:53 +09:00
parent 45c5b7e7dd
commit 7ef03dd2cb
2 changed files with 18 additions and 4 deletions

View File

@ -133,9 +133,9 @@ namespace osu.Game.Overlays
UserPauseRequested = false; UserPauseRequested = false;
if (restart) if (restart)
CurrentTrack.Restart(); CurrentTrack.RestartAsync();
else if (!IsPlaying) else if (!IsPlaying)
CurrentTrack.Start(); CurrentTrack.StartAsync();
return true; return true;
} }
@ -152,7 +152,7 @@ namespace osu.Game.Overlays
{ {
UserPauseRequested |= requestedByUser; UserPauseRequested |= requestedByUser;
if (CurrentTrack.IsRunning) if (CurrentTrack.IsRunning)
CurrentTrack.Stop(); CurrentTrack.StopAsync();
} }
/// <summary> /// <summary>
@ -250,7 +250,7 @@ namespace osu.Game.Overlays
{ {
// if not scheduled, the previously track will be stopped one frame later (see ScheduleAfterChildren logic in GameBase). // if not scheduled, the previously track will be stopped one frame later (see ScheduleAfterChildren logic in GameBase).
// we probably want to move this to a central method for switching to a new working beatmap in the future. // we probably want to move this to a central method for switching to a new working beatmap in the future.
Schedule(() => CurrentTrack.Restart()); Schedule(() => CurrentTrack.RestartAsync());
} }
private WorkingBeatmap current; private WorkingBeatmap current;

View File

@ -430,11 +430,19 @@ namespace osu.Game.Tests.Visual
return accumulated == seek; return accumulated == seek;
} }
public override Task<bool> SeekAsync(double seek) => Task.FromResult(Seek(seek));
public override void Start() public override void Start()
{ {
running = true; running = true;
} }
public override Task StartAsync()
{
Start();
return Task.CompletedTask;
}
public override void Reset() public override void Reset()
{ {
Seek(0); Seek(0);
@ -450,6 +458,12 @@ namespace osu.Game.Tests.Visual
} }
} }
public override Task StopAsync()
{
Stop();
return Task.CompletedTask;
}
public override bool IsRunning => running; public override bool IsRunning => running;
private double? lastReferenceTime; private double? lastReferenceTime;