1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-15 16:25:32 +08:00

Merge pull request #12892 from smoogipoo/force-end-playing

Forcefully trigger EndPlaying() to fix test failures
This commit is contained in:
Dean Herbert 2021-05-21 14:50:42 +09:00 committed by GitHub
commit a37520d5ba
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 0 deletions

View File

@ -174,6 +174,9 @@ namespace osu.Game.Online.Spectator
public void EndPlaying()
{
if (!IsPlaying)
return;
IsPlaying = false;
currentBeatmap = null;

View File

@ -22,6 +22,7 @@ using osu.Game.Configuration;
using osu.Game.Graphics.Containers;
using osu.Game.IO.Archives;
using osu.Game.Online.API;
using osu.Game.Online.Spectator;
using osu.Game.Overlays;
using osu.Game.Replays;
using osu.Game.Rulesets;
@ -93,6 +94,9 @@ namespace osu.Game.Screens.Play
[Resolved]
private MusicController musicController { get; set; }
[Resolved]
private SpectatorClient spectatorClient { get; set; }
private Sample sampleRestart;
public BreakOverlay BreakOverlay;
@ -882,6 +886,11 @@ namespace osu.Game.Screens.Play
return true;
}
// EndPlaying() is typically called from ReplayRecorder.Dispose(). Disposal is currently asynchronous.
// To resolve test failures, forcefully end playing synchronously when this screen exits.
// Todo: Replace this with a more permanent solution once osu-framework has a synchronous cleanup method.
spectatorClient.EndPlaying();
// GameplayClockContainer performs seeks / start / stop operations on the beatmap's track.
// as we are no longer the current screen, we cannot guarantee the track is still usable.
(GameplayClockContainer as MasterGameplayClockContainer)?.StopUsingBeatmapClock();