1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 18:27:26 +08:00

Fix adjustments not being removed correctly on retry from pause (#6728)

Fix adjustments not being removed correctly on retry from pause
This commit is contained in:
Dean Herbert 2019-11-06 17:54:20 +09:00 committed by GitHub
commit 813d3a0bfa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 8 deletions

View File

@ -237,6 +237,7 @@ namespace osu.Game.Tests.Visual.Gameplay
AddUntilStep("player not exited", () => Player.IsCurrentScreen()); AddUntilStep("player not exited", () => Player.IsCurrentScreen());
AddStep("exit", () => Player.Exit()); AddStep("exit", () => Player.Exit());
confirmExited(); confirmExited();
confirmNoTrackAdjustments();
} }
private void confirmPaused() private void confirmPaused()
@ -258,6 +259,11 @@ namespace osu.Game.Tests.Visual.Gameplay
AddUntilStep("player exited", () => !Player.IsCurrentScreen()); AddUntilStep("player exited", () => !Player.IsCurrentScreen());
} }
private void confirmNoTrackAdjustments()
{
AddAssert("track has no adjustments", () => Beatmap.Value.Track.AggregateFrequency.Value == 1);
}
private void restart() => AddStep("restart", () => Player.Restart()); private void restart() => AddStep("restart", () => Player.Restart());
private void pause() => AddStep("pause", () => Player.Pause()); private void pause() => AddStep("pause", () => Player.Pause());
private void resume() => AddStep("resume", () => Player.Resume()); private void resume() => AddStep("resume", () => Player.Resume());

View File

@ -162,16 +162,12 @@ namespace osu.Game.Screens.Play
if (sourceClock != beatmap.Track) if (sourceClock != beatmap.Track)
return; return;
removeSourceClockAdjustments();
sourceClock = new TrackVirtual(beatmap.Track.Length); sourceClock = new TrackVirtual(beatmap.Track.Length);
adjustableClock.ChangeSource(sourceClock); adjustableClock.ChangeSource(sourceClock);
} }
public void ResetLocalAdjustments()
{
// In the case of replays, we may have changed the playback rate.
UserPlaybackRate.Value = 1;
}
protected override void Update() protected override void Update()
{ {
if (!IsPaused.Value) if (!IsPaused.Value)
@ -198,6 +194,14 @@ namespace osu.Game.Screens.Play
protected override void Dispose(bool isDisposing) protected override void Dispose(bool isDisposing)
{ {
base.Dispose(isDisposing); base.Dispose(isDisposing);
removeSourceClockAdjustments();
sourceClock = null;
}
private void removeSourceClockAdjustments()
{
sourceClock.ResetSpeedAdjustments();
(sourceClock as IAdjustableAudioComponent)?.RemoveAdjustment(AdjustableProperty.Frequency, pauseFreqAdjust); (sourceClock as IAdjustableAudioComponent)?.RemoveAdjustment(AdjustableProperty.Frequency, pauseFreqAdjust);
} }
} }

View File

@ -536,8 +536,6 @@ namespace osu.Game.Screens.Play
return true; return true;
} }
GameplayClockContainer.ResetLocalAdjustments();
// GameplayClockContainer performs seeks / start / stop operations on the beatmap's track. // 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. // as we are no longer the current screen, we cannot guarantee the track is still usable.
GameplayClockContainer.StopUsingBeatmapClock(); GameplayClockContainer.StopUsingBeatmapClock();