mirror of
https://github.com/ppy/osu.git
synced 2024-09-21 13:27:25 +08:00
Centralise calls to end high performance sessions
This commit is contained in:
parent
b01fb2a5bf
commit
57fe5bdcfc
@ -3,6 +3,7 @@
|
||||
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using ManagedBass.Fx;
|
||||
using osu.Framework.Allocation;
|
||||
@ -288,8 +289,7 @@ namespace osu.Game.Screens.Play
|
||||
|
||||
Debug.Assert(CurrentPlayer != null);
|
||||
|
||||
highPerformanceSession?.Dispose();
|
||||
highPerformanceSession = null;
|
||||
endHighPerformance();
|
||||
|
||||
// prepare for a retry.
|
||||
CurrentPlayer = null;
|
||||
@ -329,8 +329,7 @@ namespace osu.Game.Screens.Play
|
||||
BackgroundBrightnessReduction = false;
|
||||
Beatmap.Value.Track.RemoveAdjustment(AdjustableProperty.Volume, volumeAdjustment);
|
||||
|
||||
highPerformanceSession?.Dispose();
|
||||
highPerformanceSession = null;
|
||||
endHighPerformance();
|
||||
|
||||
return base.OnExiting(e);
|
||||
}
|
||||
@ -531,11 +530,7 @@ namespace osu.Game.Screens.Play
|
||||
// ensure that once we have reached this "point of no return", readyForPush will be false for all future checks (until a new player instance is prepared).
|
||||
Player consumedPlayer = consumePlayer();
|
||||
|
||||
consumedPlayer.OnShowingResults += () =>
|
||||
{
|
||||
highPerformanceSession?.Dispose();
|
||||
highPerformanceSession = null;
|
||||
};
|
||||
consumedPlayer.OnShowingResults += endHighPerformance;
|
||||
|
||||
ContentOut();
|
||||
|
||||
@ -568,6 +563,8 @@ namespace osu.Game.Screens.Play
|
||||
scheduledPushPlayer = null;
|
||||
}
|
||||
|
||||
private void endHighPerformance() => Interlocked.Exchange(ref highPerformanceSession, null)?.Dispose();
|
||||
|
||||
#region Disposal
|
||||
|
||||
protected override void Dispose(bool isDisposing)
|
||||
@ -580,8 +577,7 @@ namespace osu.Game.Screens.Play
|
||||
DisposalTask = LoadTask?.ContinueWith(_ => CurrentPlayer?.Dispose());
|
||||
}
|
||||
|
||||
highPerformanceSession?.Dispose();
|
||||
highPerformanceSession = null;
|
||||
endHighPerformance();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
Loading…
Reference in New Issue
Block a user