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

Merge pull request #12496 from smoogipoo/fix-pre-seek-sample-lifetime

Fix storyboard samples not getting a lifetime end if initially seeked past
This commit is contained in:
Dean Herbert 2021-04-20 18:07:15 +09:00 committed by GitHub
commit 3932f6c3e3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 41 additions and 11 deletions

View File

@ -77,7 +77,33 @@ namespace osu.Game.Tests.Gameplay
AddStep("start time", () => gameplayContainer.Start());
AddUntilStep("sample playback succeeded", () => sample.LifetimeEnd < double.MaxValue);
AddUntilStep("sample played", () => sample.RequestedPlaying);
AddUntilStep("sample has lifetime end", () => sample.LifetimeEnd < double.MaxValue);
}
[Test]
public void TestSampleHasLifetimeEndWithInitialClockTime()
{
GameplayClockContainer gameplayContainer = null;
DrawableStoryboardSample sample = null;
AddStep("create container", () =>
{
var working = CreateWorkingBeatmap(new OsuRuleset().RulesetInfo);
working.LoadTrack();
Add(gameplayContainer = new GameplayClockContainer(working, 1000, true));
gameplayContainer.Add(sample = new DrawableStoryboardSample(new StoryboardSampleInfo(string.Empty, 0, 1))
{
Clock = gameplayContainer.GameplayClock
});
});
AddStep("start time", () => gameplayContainer.Start());
AddUntilStep("sample not played", () => !sample.RequestedPlaying);
AddUntilStep("sample has lifetime end", () => sample.LifetimeEnd < double.MaxValue);
}
[TestCase(typeof(OsuModDoubleTime), 1.5)]

View File

@ -16,7 +16,7 @@ namespace osu.Game.Skinning
{
public double Length => !DrawableSamples.Any() ? 0 : DrawableSamples.Max(sample => sample.Length);
protected bool RequestedPlaying { get; private set; }
public bool RequestedPlaying { get; private set; }
public PausableSkinnableSound()
{

View File

@ -61,28 +61,32 @@ namespace osu.Game.Storyboards.Drawables
{
base.Update();
// Check if we've yet to pass the sample start time.
if (Time.Current < sampleInfo.StartTime)
{
// We've rewound before the start time of the sample
Stop();
// In the case that the user fast-forwards to a point far beyond the start time of the sample,
// we want to be able to fall into the if-conditional below (therefore we must not have a life time end)
// Playback has stopped, but if the user fast-forwards to a point after the start time of the sample then
// we must not have a lifetime end in order to continue receiving updates and start the sample below.
LifetimeStart = sampleInfo.StartTime;
LifetimeEnd = double.MaxValue;
return;
}
else if (Time.Current - Time.Elapsed <= sampleInfo.StartTime)
// Ensure that we've elapsed from a point before the sample's start time before playing.
if (Time.Current - Time.Elapsed <= sampleInfo.StartTime)
{
// We've passed the start time of the sample. We only play the sample if we're within an allowable range
// from the sample's start, to reduce layering if we've been fast-forwarded far into the future
if (!RequestedPlaying && Time.Current - sampleInfo.StartTime < allowable_late_start)
Play();
// In the case that the user rewinds to a point far behind the start time of the sample,
// we want to be able to fall into the if-conditional above (therefore we must not have a life time start)
LifetimeStart = double.MinValue;
LifetimeEnd = sampleInfo.StartTime;
}
// Playback has started, but if the user rewinds to a point before the start time of the sample then
// we must not have a lifetime start in order to continue receiving updates and stop the sample above.
LifetimeStart = double.MinValue;
LifetimeEnd = sampleInfo.StartTime;
}
}
}