1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 20:22:55 +08:00

Add a paired schedule in SpectatorClient.BeginPlaying

Optimally, I would like to remove the `Schedule` in `EndPlaying`, but it
turns out quite a few test are relying on this at very least. Adding a
paired schedule ensure that order of operations is correct, at least.
This commit is contained in:
Dean Herbert 2021-12-06 16:34:15 +09:00
parent a13067eaa4
commit 7a333ffdcc

View File

@ -136,8 +136,9 @@ namespace osu.Game.Online.Spectator
public void BeginPlaying(GameplayState state, Score score) public void BeginPlaying(GameplayState state, Score score)
{ {
Debug.Assert(ThreadSafety.IsUpdateThread); // This schedule is only here to match the one below in `EndPlaying`.
Schedule(() =>
{
if (IsPlaying) if (IsPlaying)
throw new InvalidOperationException($"Cannot invoke {nameof(BeginPlaying)} when already playing"); throw new InvalidOperationException($"Cannot invoke {nameof(BeginPlaying)} when already playing");
@ -152,14 +153,15 @@ namespace osu.Game.Online.Spectator
currentScore = score; currentScore = score;
BeginPlayingInternal(currentState); BeginPlayingInternal(currentState);
});
} }
public void SendFrames(FrameDataBundle data) => lastSend = SendFramesInternal(data); public void SendFrames(FrameDataBundle data) => lastSend = SendFramesInternal(data);
public void EndPlaying() public void EndPlaying()
{ {
// This method is most commonly called via Dispose(), which is asynchronous. // This method is most commonly called via Dispose(), which is can be asynchronous (via the AsyncDisposalQueue).
// Todo: This should not be a thing, but requires framework changes. // We probably need to find a better way to handle this...
Schedule(() => Schedule(() =>
{ {
if (!IsPlaying) if (!IsPlaying)