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 @@ 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)

View File

@ -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;