mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 16:27:26 +08:00
Merge pull request #2655 from smoogipoo/remove-decoder-offset
Apply platform universal offset in Player
This commit is contained in:
commit
feb75eecbf
@ -58,7 +58,7 @@ namespace osu.Game.Tests.Beatmaps.IO
|
|||||||
Assert.AreEqual("03. Renatus - Soleily 192kbps.mp3", meta.AudioFile);
|
Assert.AreEqual("03. Renatus - Soleily 192kbps.mp3", meta.AudioFile);
|
||||||
Assert.AreEqual("Deif", meta.AuthorString);
|
Assert.AreEqual("Deif", meta.AuthorString);
|
||||||
Assert.AreEqual("machinetop_background.jpg", meta.BackgroundFile);
|
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(string.Empty, meta.Source);
|
||||||
Assert.AreEqual("MBC7 Unisphere 地球ヤバイEP Chikyu Yabai", meta.Tags);
|
Assert.AreEqual("MBC7 Unisphere 地球ヤバイEP Chikyu Yabai", meta.Tags);
|
||||||
Assert.AreEqual("Renatus", meta.Title);
|
Assert.AreEqual("Renatus", meta.Title);
|
||||||
|
@ -8,7 +8,6 @@ using System.Linq;
|
|||||||
using osu.Game.Beatmaps.Timing;
|
using osu.Game.Beatmaps.Timing;
|
||||||
using osu.Game.Rulesets.Objects.Legacy;
|
using osu.Game.Rulesets.Objects.Legacy;
|
||||||
using osu.Game.Beatmaps.ControlPoints;
|
using osu.Game.Beatmaps.ControlPoints;
|
||||||
using osu.Framework;
|
|
||||||
|
|
||||||
namespace osu.Game.Beatmaps.Formats
|
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())));
|
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>
|
/// <summary>
|
||||||
/// Whether or not beatmap or runtime offsets should be applied. Defaults on; only disable for testing purposes.
|
/// Whether or not beatmap or runtime offsets should be applied. Defaults on; only disable for testing purposes.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool ApplyOffsets = true;
|
public bool ApplyOffsets = true;
|
||||||
|
|
||||||
private readonly int offset = UniversalOffset;
|
private readonly int offset;
|
||||||
|
|
||||||
public LegacyBeatmapDecoder(int version = LATEST_VERSION) : base(version)
|
public LegacyBeatmapDecoder(int version = LATEST_VERSION) : base(version)
|
||||||
{
|
{
|
||||||
// BeatmapVersion 4 and lower had an incorrect offset (stable has this set as 24ms off)
|
// 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)
|
protected override void ParseStreamInto(StreamReader stream, Beatmap beatmap)
|
||||||
|
@ -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();
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using osu.Framework;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Audio;
|
using osu.Framework.Audio;
|
||||||
using osu.Framework.Audio.Sample;
|
using osu.Framework.Audio.Sample;
|
||||||
@ -146,8 +147,12 @@ namespace osu.Game.Screens.Play
|
|||||||
|
|
||||||
adjustableClock.ProcessFrame();
|
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.
|
// 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.ValueChanged += v => offsetClock.Offset = v;
|
||||||
userAudioOffset.TriggerChange();
|
userAudioOffset.TriggerChange();
|
||||||
|
Loading…
Reference in New Issue
Block a user