Fix sample disabled status not being updated correctly from seek state

This commit is contained in:
Dean Herbert
2020-10-05 12:46:15 +09:00
parent af7d10afe0
commit e4710f82ec
2 changed files with 11 additions and 5 deletions

View File

@ -228,7 +228,9 @@ namespace osu.Game.Rulesets.UI
{ {
} }
public override bool IsSeeking => ParentGameplayClock != null && Math.Abs(CurrentTime - ParentGameplayClock.CurrentTime) > 200; protected override bool ShouldDisableSamplePlayback =>
// handle the case where playback is catching up to real-time.
base.ShouldDisableSamplePlayback || (ParentGameplayClock != null && Math.Abs(CurrentTime - ParentGameplayClock.CurrentTime) > 200);
} }
} }
} }

View File

@ -28,6 +28,8 @@ namespace osu.Game.Screens.Play
/// </summary> /// </summary>
public virtual IEnumerable<Bindable<double>> NonGameplayAdjustments => Enumerable.Empty<Bindable<double>>(); public virtual IEnumerable<Bindable<double>> NonGameplayAdjustments => Enumerable.Empty<Bindable<double>>();
private readonly Bindable<bool> samplePlaybackDisabled = new Bindable<bool>();
public GameplayClock(IFrameBasedClock underlyingClock) public GameplayClock(IFrameBasedClock underlyingClock)
{ {
this.underlyingClock = underlyingClock; this.underlyingClock = underlyingClock;
@ -62,13 +64,15 @@ namespace osu.Game.Screens.Play
public bool IsRunning => underlyingClock.IsRunning; public bool IsRunning => underlyingClock.IsRunning;
/// <summary> /// <summary>
/// Whether an ongoing seek operation is active. /// Whether nested samples supporting the <see cref="ISamplePlaybackDisabler"/> interface should be paused.
/// </summary> /// </summary>
public virtual bool IsSeeking => false; protected virtual bool ShouldDisableSamplePlayback => IsPaused.Value;
public void ProcessFrame() public void ProcessFrame()
{ {
// we do not want to process the underlying clock. // intentionally not updating the underlying clock (handled externally).
samplePlaybackDisabled.Value = ShouldDisableSamplePlayback;
} }
public double ElapsedFrameTime => underlyingClock.ElapsedFrameTime; public double ElapsedFrameTime => underlyingClock.ElapsedFrameTime;
@ -79,6 +83,6 @@ namespace osu.Game.Screens.Play
public IClock Source => underlyingClock; public IClock Source => underlyingClock;
public IBindable<bool> SamplePlaybackDisabled => IsPaused; IBindable<bool> ISamplePlaybackDisabler.SamplePlaybackDisabled => samplePlaybackDisabled;
} }
} }