1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-22 03:27:24 +08:00

Merge pull request #2655 from smoogipoo/remove-decoder-offset

Apply platform universal offset in Player
This commit is contained in:
Dean Herbert 2018-06-07 15:17:45 +09:00 committed by GitHub
commit feb75eecbf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 22 additions and 19 deletions

View File

@ -58,7 +58,7 @@ namespace osu.Game.Tests.Beatmaps.IO
Assert.AreEqual("03. Renatus - Soleily 192kbps.mp3", meta.AudioFile);
Assert.AreEqual("Deif", meta.AuthorString);
Assert.AreEqual("machinetop_background.jpg", meta.BackgroundFile);
Assert.AreEqual(164471 + LegacyBeatmapDecoder.UniversalOffset, meta.PreviewTime);
Assert.AreEqual(164471, meta.PreviewTime);
Assert.AreEqual(string.Empty, meta.Source);
Assert.AreEqual("MBC7 Unisphere 地球ヤバイEP Chikyu Yabai", meta.Tags);
Assert.AreEqual("Renatus", meta.Title);

View File

@ -8,7 +8,6 @@ using System.Linq;
using osu.Game.Beatmaps.Timing;
using osu.Game.Rulesets.Objects.Legacy;
using osu.Game.Beatmaps.ControlPoints;
using osu.Framework;
namespace osu.Game.Beatmaps.Formats
{
@ -28,23 +27,17 @@ namespace osu.Game.Beatmaps.Formats
AddDecoder<Beatmap>(@"osu file format v", m => new LegacyBeatmapDecoder(int.Parse(m.Split('v').Last())));
}
/// <summary>
/// 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.
/// </summary>
public static int UniversalOffset => RuntimeInfo.OS == RuntimeInfo.Platform.Windows ? -22 : 0;
/// <summary>
/// Whether or not beatmap or runtime offsets should be applied. Defaults on; only disable for testing purposes.
/// </summary>
public bool ApplyOffsets = true;
private readonly int offset = UniversalOffset;
private readonly int offset;
public LegacyBeatmapDecoder(int version = LATEST_VERSION) : base(version)
{
// BeatmapVersion 4 and lower had an incorrect offset (stable has this set as 24ms off)
offset += FormatVersion < 5 ? 24 : 0;
offset = FormatVersion < 5 ? 24 : 0;
}
protected override void ParseStreamInto(StreamReader stream, Beatmap beatmap)

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();