Merge branch 'master' into fix-menu-notifications

This commit is contained in:
Dan Balasescu
2018-06-07 15:35:30 +09:00
committed by GitHub
23 changed files with 131 additions and 305 deletions

View File

@ -44,13 +44,18 @@ namespace osu.Game.Screens.Play
public Action OnResume;
public Action OnPause;
private readonly IAdjustableClock adjustableClock;
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.adjustableClock = adjustableClock;
this.decoupledClock = decoupledClock;
RelativeSizeAxes = Axes.Both;
@ -80,7 +85,7 @@ namespace osu.Game.Screens.Play
if (IsPaused) return;
// stop the seekable clock (stops the audio eventually)
adjustableClock.Stop();
decoupledClock.Stop();
IsPaused = true;
OnPause?.Invoke();
@ -97,10 +102,10 @@ namespace osu.Game.Screens.Play
IsResuming = false;
lastPauseActionTime = Time.Current;
// seek back to the time of the framed clock.
// this accounts for the audio clock potentially taking time to enter a completely stopped state.
adjustableClock.Seek(framedClock.CurrentTime);
adjustableClock.Start();
// 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 source potentially taking time to enter a completely stopped state
decoupledClock.Seek(decoupledClock.CurrentTime);
decoupledClock.Start();
OnResume?.Invoke();
pauseOverlay.Hide();

View File

@ -4,6 +4,7 @@
using System;
using System.Linq;
using System.Threading.Tasks;
using osu.Framework;
using osu.Framework.Allocation;
using osu.Framework.Audio;
using osu.Framework.Audio.Sample;
@ -146,8 +147,12 @@ namespace osu.Game.Screens.Play
adjustableClock.ProcessFrame();
// Lazer's audio timings in general doesn't match stable. This is the result of user testing, albeit limited.
// This only seems to be required on windows. We need to eventually figure out why, with a bit of luck.
var platformOffsetClock = new FramedOffsetClock(adjustableClock) { Offset = RuntimeInfo.OS == RuntimeInfo.Platform.Windows ? 22 : 0 };
// the final usable gameplay clock with user-set offsets applied.
var offsetClock = new FramedOffsetClock(adjustableClock);
var offsetClock = new FramedOffsetClock(platformOffsetClock);
userAudioOffset.ValueChanged += v => offsetClock.Offset = v;
userAudioOffset.TriggerChange();