1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-26 17:53:53 +08:00

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;
if (restart)
CurrentTrack.Restart();
CurrentTrack.RestartAsync();
else if (!IsPlaying)
CurrentTrack.Start();
CurrentTrack.StartAsync();
return true;
}
@ -152,7 +152,7 @@ namespace osu.Game.Overlays
{
UserPauseRequested |= requestedByUser;
if (CurrentTrack.IsRunning)
CurrentTrack.Stop();
CurrentTrack.StopAsync();
}
/// <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).
// 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;

View File

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