Use a decoupled clock for triangles intro to avoid startup freezes on broken audio device

This commit is contained in:
Dean Herbert 2021-09-09 01:21:19 +09:00
parent 2c6ee0ebf7
commit ba99a808af
2 changed files with 18 additions and 2 deletions

View File

@ -165,7 +165,7 @@ namespace osu.Game.Screens.Menu
protected override BackgroundScreen CreateBackground() => new BackgroundScreenBlack(); protected override BackgroundScreen CreateBackground() => new BackgroundScreenBlack();
protected void StartTrack() protected virtual void StartTrack()
{ {
// Only start the current track if it is the menu music. A beatmap's track is started when entering the Main Menu. // Only start the current track if it is the menu music. A beatmap's track is started when entering the Main Menu.
if (UsingThemedIntro) if (UsingThemedIntro)

View File

@ -41,6 +41,8 @@ namespace osu.Game.Screens.Menu
private Sample welcome; private Sample welcome;
private DecoupleableInterpolatingFramedClock decoupledClock;
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load() private void load()
{ {
@ -56,10 +58,18 @@ namespace osu.Game.Screens.Menu
{ {
PrepareMenuLoad(); PrepareMenuLoad();
decoupledClock = new DecoupleableInterpolatingFramedClock
{
IsCoupled = false
};
if (UsingThemedIntro)
decoupledClock.ChangeSource(Track);
LoadComponentAsync(new TrianglesIntroSequence(logo, background) LoadComponentAsync(new TrianglesIntroSequence(logo, background)
{ {
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
Clock = new FramedClock(UsingThemedIntro ? Track : null), Clock = decoupledClock,
LoadMenu = LoadMenu LoadMenu = LoadMenu
}, t => }, t =>
{ {
@ -78,6 +88,12 @@ namespace osu.Game.Screens.Menu
background.FadeOut(100); background.FadeOut(100);
} }
protected override void StartTrack()
{
if (UsingThemedIntro)
decoupledClock.Start();
}
private class TrianglesIntroSequence : CompositeDrawable private class TrianglesIntroSequence : CompositeDrawable
{ {
private readonly OsuLogo logo; private readonly OsuLogo logo;