1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-21 20:47:28 +08:00

Merge pull request #9036 from peppy/fix-audio-offsets-rate-adjust

Fix applied platform/user offsets being incorrect when rate adjust mods are active
This commit is contained in:
Dan Balasescu 2020-05-15 19:33:28 +09:00 committed by GitHub
commit 43c42cdf31
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -78,10 +78,10 @@ namespace osu.Game.Screens.Play
// Lazer's audio timings in general doesn't match stable. This is the result of user testing, albeit limited. // 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. // This only seems to be required on windows. We need to eventually figure out why, with a bit of luck.
platformOffsetClock = new FramedOffsetClock(adjustableClock) { Offset = RuntimeInfo.OS == RuntimeInfo.Platform.Windows ? 15 : 0 }; platformOffsetClock = new HardwareCorrectionOffsetClock(adjustableClock) { Offset = RuntimeInfo.OS == RuntimeInfo.Platform.Windows ? 15 : 0 };
// the final usable gameplay clock with user-set offsets applied. // the final usable gameplay clock with user-set offsets applied.
userOffsetClock = new FramedOffsetClock(platformOffsetClock); userOffsetClock = new HardwareCorrectionOffsetClock(platformOffsetClock);
// the clock to be exposed via DI to children. // the clock to be exposed via DI to children.
GameplayClock = new GameplayClock(userOffsetClock); GameplayClock = new GameplayClock(userOffsetClock);
@ -248,5 +248,16 @@ namespace osu.Game.Screens.Play
speedAdjustmentsApplied = false; speedAdjustmentsApplied = false;
} }
} }
private class HardwareCorrectionOffsetClock : FramedOffsetClock
{
// we always want to apply the same real-time offset, so it should be adjusted by the playback rate to achieve this.
public override double CurrentTime => SourceTime + Offset * Rate;
public HardwareCorrectionOffsetClock(IClock source, bool processSource = true)
: base(source, processSource)
{
}
}
} }
} }