From ba99a808af624d4a2ae9c4a77dc0f3be8a25f535 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 9 Sep 2021 01:21:19 +0900 Subject: [PATCH] Use a decoupled clock for triangles intro to avoid startup freezes on broken audio device --- osu.Game/Screens/Menu/IntroScreen.cs | 2 +- osu.Game/Screens/Menu/IntroTriangles.cs | 18 +++++++++++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/osu.Game/Screens/Menu/IntroScreen.cs b/osu.Game/Screens/Menu/IntroScreen.cs index 07a94fb97e..ac4a53f4a9 100644 --- a/osu.Game/Screens/Menu/IntroScreen.cs +++ b/osu.Game/Screens/Menu/IntroScreen.cs @@ -165,7 +165,7 @@ public override void OnSuspending(IScreen next) 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. if (UsingThemedIntro) diff --git a/osu.Game/Screens/Menu/IntroTriangles.cs b/osu.Game/Screens/Menu/IntroTriangles.cs index 0ea83fe5e7..69333d4a12 100644 --- a/osu.Game/Screens/Menu/IntroTriangles.cs +++ b/osu.Game/Screens/Menu/IntroTriangles.cs @@ -41,6 +41,8 @@ public class IntroTriangles : IntroScreen private Sample welcome; + private DecoupleableInterpolatingFramedClock decoupledClock; + [BackgroundDependencyLoader] private void load() { @@ -56,10 +58,18 @@ protected override void LogoArriving(OsuLogo logo, bool resuming) { PrepareMenuLoad(); + decoupledClock = new DecoupleableInterpolatingFramedClock + { + IsCoupled = false + }; + + if (UsingThemedIntro) + decoupledClock.ChangeSource(Track); + LoadComponentAsync(new TrianglesIntroSequence(logo, background) { RelativeSizeAxes = Axes.Both, - Clock = new FramedClock(UsingThemedIntro ? Track : null), + Clock = decoupledClock, LoadMenu = LoadMenu }, t => { @@ -78,6 +88,12 @@ public override void OnResuming(IScreen last) background.FadeOut(100); } + protected override void StartTrack() + { + if (UsingThemedIntro) + decoupledClock.Start(); + } + private class TrianglesIntroSequence : CompositeDrawable { private readonly OsuLogo logo;