mirror of
https://github.com/ppy/osu.git
synced 2026-05-21 03:39:53 +08:00
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.
This commit is contained in:
committed by
GitHub
Unverified
parent
84cce2f0d1
commit
ed84dd431f
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user