1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-13 16:13:34 +08:00

Apply safeties for AudioFilter usage around drawables which go non-present

This commit is contained in:
Dean Herbert 2024-02-26 21:16:15 +08:00
parent 7a96cf1289
commit c686dfd361
No known key found for this signature in database
3 changed files with 36 additions and 12 deletions

View File

@ -115,6 +115,11 @@ namespace osu.Game.Collections
};
}
public override bool IsPresent => base.IsPresent
// Safety for low pass filter potentially getting stuck in applied state due to
// transforms on `this` causing children to no longer be updated.
|| lowPassFilter.IsAttached;
protected override void PopIn()
{
lowPassFilter.CutoffTo(300, 100, Easing.OutCubic);

View File

@ -27,6 +27,12 @@ namespace osu.Game.Overlays
public PopupDialog CurrentDialog { get; private set; }
public override bool IsPresent => Scheduler.HasPendingTasks
|| dialogContainer.Children.Count > 0
// Safety for low pass filter potentially getting stuck in applied state due to
// transforms on `this` causing children to no longer be updated.
|| lowPassFilter.IsAttached;
public DialogOverlay()
{
AutoSizeAxes = Axes.Y;
@ -95,8 +101,6 @@ namespace osu.Game.Overlays
}
}
public override bool IsPresent => Scheduler.HasPendingTasks || dialogContainer.Children.Count > 0;
protected override bool BlockNonPositionalInput => true;
protected override void PopIn()

View File

@ -78,8 +78,8 @@ namespace osu.Game.Screens.Play
private readonly BindableDouble volumeAdjustment = new BindableDouble(1);
private AudioFilter lowPassFilter = null!;
private AudioFilter highPassFilter = null!;
private AudioFilter? lowPassFilter;
private AudioFilter? highPassFilter;
private SkinnableSound sampleRestart = null!;
@ -158,7 +158,7 @@ namespace osu.Game.Screens.Play
}
[BackgroundDependencyLoader]
private void load(SessionStatics sessionStatics, AudioManager audio, OsuConfigManager config)
private void load(SessionStatics sessionStatics, OsuConfigManager config)
{
muteWarningShownOnce = sessionStatics.GetBindable<bool>(Static.MutedAudioNotificationShownOnce);
batteryWarningShownOnce = sessionStatics.GetBindable<bool>(Static.LowBatteryNotificationShownOnce);
@ -205,8 +205,6 @@ namespace osu.Game.Screens.Play
},
},
idleTracker = new IdleTracker(750),
lowPassFilter = new AudioFilter(audio.TrackMixer),
highPassFilter = new AudioFilter(audio.TrackMixer, BQFType.HighPass),
sampleRestart = new SkinnableSound(new SampleInfo(@"Gameplay/restart", @"pause-retry-click"))
};
@ -284,8 +282,9 @@ namespace osu.Game.Screens.Play
// stop the track before removing adjustment to avoid a volume spike.
Beatmap.Value.Track.Stop();
Beatmap.Value.Track.RemoveAdjustment(AdjustableProperty.Volume, volumeAdjustment);
lowPassFilter.CutoffTo(AudioFilter.MAX_LOWPASS_CUTOFF);
highPassFilter.CutoffTo(0);
lowPassFilter?.RemoveAndDisposeImmediately();
highPassFilter?.RemoveAndDisposeImmediately();
}
public override bool OnExiting(ScreenExitEvent e)
@ -425,6 +424,12 @@ namespace osu.Game.Screens.Play
settingsScroll.FadeInFromZero(500, Easing.Out)
.MoveToX(0, 500, Easing.OutQuint);
AddRangeInternal(new[]
{
lowPassFilter = new AudioFilter(audioManager.TrackMixer),
highPassFilter = new AudioFilter(audioManager.TrackMixer, BQFType.HighPass),
});
lowPassFilter.CutoffTo(1000, 650, Easing.OutQuint);
highPassFilter.CutoffTo(300).Then().CutoffTo(0, 1250); // 1250 is to line up with the appearance of MetadataInfo (750 delay + 500 fade-in)
@ -437,13 +442,23 @@ namespace osu.Game.Screens.Play
content.StopTracking();
content.ScaleTo(0.7f, CONTENT_OUT_DURATION * 2, Easing.OutQuint);
content.FadeOut(CONTENT_OUT_DURATION, Easing.OutQuint);
content.FadeOut(CONTENT_OUT_DURATION, Easing.OutQuint)
// Safety for filter potentially getting stuck in applied state due to
// transforms on `this` causing children to no longer be updated.
.OnComplete(_ =>
{
highPassFilter?.RemoveAndDisposeImmediately();
highPassFilter = null;
lowPassFilter?.RemoveAndDisposeImmediately();
lowPassFilter = null;
});
settingsScroll.FadeOut(CONTENT_OUT_DURATION, Easing.OutQuint)
.MoveToX(settingsScroll.DrawWidth, CONTENT_OUT_DURATION * 2, Easing.OutQuint);
lowPassFilter.CutoffTo(AudioFilter.MAX_LOWPASS_CUTOFF, CONTENT_OUT_DURATION);
highPassFilter.CutoffTo(0, CONTENT_OUT_DURATION);
lowPassFilter?.CutoffTo(AudioFilter.MAX_LOWPASS_CUTOFF, CONTENT_OUT_DURATION);
highPassFilter?.CutoffTo(0, CONTENT_OUT_DURATION);
}
private void pushWhenLoaded()