From ed84dd431fee9cd7fae3d4741cfba7e0469a9826 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 8 Apr 2026 00:03:05 +0900 Subject: [PATCH] Tidy up track switching handling (#37230) This doesn't fix https://github.com/ppy/osu/issues/37136, but it does fix the fact that I left some weird code around in https://github.com/ppy/osu/commit/aab01b0fe54c543e015e7be4f218bf71d72290c7 that wasn't required (the re-equality check and disposal). Just cleaning that up here. I doubt it will fix the issue. But also, I can't see how the issue can occur yet. --- osu.Game/Overlays/MusicController.cs | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/osu.Game/Overlays/MusicController.cs b/osu.Game/Overlays/MusicController.cs index 037448c192..00c24e6589 100644 --- a/osu.Game/Overlays/MusicController.cs +++ b/osu.Game/Overlays/MusicController.cs @@ -9,6 +9,7 @@ using osu.Framework.Allocation; using osu.Framework.Audio; using osu.Framework.Audio.Track; using osu.Framework.Bindables; +using osu.Framework.Development; using osu.Framework.Graphics; using osu.Framework.Graphics.Audio; using osu.Framework.Graphics.Containers; @@ -513,30 +514,22 @@ namespace osu.Game.Overlays private void changeTrack() { + Debug.Assert(ThreadSafety.IsUpdateThread); + const double track_fade_in_time = 220; const double track_fade_out_time = 150; var queuedTrack = getQueuedTrack(); - var lastTrack = CurrentTrack; + lastTrack.Completed -= onTrackCompleted; + lastTrack.VolumeTo(0, track_fade_out_time, Easing.Out).Expire(); CurrentTrack = queuedTrack; - lastTrack.VolumeTo(0, track_fade_out_time, Easing.Out).Expire(); - - if (queuedTrack == CurrentTrack) - { - queuedTrack.Volume.Value = 0; - AddInternal(queuedTrack); - queuedTrack.Delay(DELAY_BEFORE_FADE).VolumeTo(1, track_fade_in_time); - } - else - { - // If the track has changed since the call to changeTrack, it is safe to dispose the - // queued track rather than consume it. - queuedTrack.Dispose(); - } + queuedTrack.Volume.Value = 0; + AddInternal(queuedTrack); + queuedTrack.Delay(DELAY_BEFORE_FADE).VolumeTo(1, track_fade_in_time); } private DrawableTrack getQueuedTrack()