mirror of
https://github.com/osukey/osukey.git
synced 2025-08-07 00:23:59 +09:00
Fix wrong clock being seeked when unpausing
This commit is contained in:
@ -44,13 +44,18 @@ namespace osu.Game.Screens.Play
|
|||||||
public Action OnResume;
|
public Action OnResume;
|
||||||
public Action OnPause;
|
public Action OnPause;
|
||||||
|
|
||||||
private readonly IAdjustableClock adjustableClock;
|
|
||||||
private readonly FramedClock framedClock;
|
private readonly FramedClock framedClock;
|
||||||
|
private readonly DecoupleableInterpolatingFramedClock decoupledClock;
|
||||||
|
|
||||||
public PauseContainer(FramedClock framedClock, IAdjustableClock adjustableClock)
|
/// <summary>
|
||||||
|
/// Creates a new <see cref="PauseContainer"/>.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="framedClock">The gameplay clock. This is the clock that will process frames.</param>
|
||||||
|
/// <param name="decoupledClock">The seekable clock. This is the clock that will be paused and resumed.</param>
|
||||||
|
public PauseContainer(FramedClock framedClock, DecoupleableInterpolatingFramedClock decoupledClock)
|
||||||
{
|
{
|
||||||
this.framedClock = framedClock;
|
this.framedClock = framedClock;
|
||||||
this.adjustableClock = adjustableClock;
|
this.decoupledClock = decoupledClock;
|
||||||
|
|
||||||
RelativeSizeAxes = Axes.Both;
|
RelativeSizeAxes = Axes.Both;
|
||||||
|
|
||||||
@ -80,7 +85,7 @@ namespace osu.Game.Screens.Play
|
|||||||
if (IsPaused) return;
|
if (IsPaused) return;
|
||||||
|
|
||||||
// stop the seekable clock (stops the audio eventually)
|
// stop the seekable clock (stops the audio eventually)
|
||||||
adjustableClock.Stop();
|
decoupledClock.Stop();
|
||||||
IsPaused = true;
|
IsPaused = true;
|
||||||
|
|
||||||
OnPause?.Invoke();
|
OnPause?.Invoke();
|
||||||
@ -97,10 +102,10 @@ namespace osu.Game.Screens.Play
|
|||||||
IsResuming = false;
|
IsResuming = false;
|
||||||
lastPauseActionTime = Time.Current;
|
lastPauseActionTime = Time.Current;
|
||||||
|
|
||||||
// seek back to the time of the framed clock.
|
// Seeking the decoupled clock to its current time ensures that its source clock will be seeked to the same time
|
||||||
// this accounts for the audio clock potentially taking time to enter a completely stopped state.
|
// This accounts for the audio clock source potentially taking time to enter a completely stopped state
|
||||||
adjustableClock.Seek(framedClock.CurrentTime);
|
decoupledClock.Seek(decoupledClock.CurrentTime);
|
||||||
adjustableClock.Start();
|
decoupledClock.Start();
|
||||||
|
|
||||||
OnResume?.Invoke();
|
OnResume?.Invoke();
|
||||||
pauseOverlay.Hide();
|
pauseOverlay.Hide();
|
||||||
|
Reference in New Issue
Block a user