1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-15 05:42:56 +08:00

Fix HitObject samples getting stuck in a playing state on seeking far into the future

This commit is contained in:
Dean Herbert 2020-09-29 15:07:55 +09:00
parent 56c8e4dacf
commit 5d1c377379
4 changed files with 21 additions and 1 deletions

View File

@ -110,6 +110,12 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
} }
} }
public override void StopAllSamples()
{
base.StopAllSamples();
slidingSample?.Stop();
}
private void updateSlidingSample(ValueChangedEvent<bool> tracking) private void updateSlidingSample(ValueChangedEvent<bool> tracking)
{ {
if (tracking.NewValue) if (tracking.NewValue)

View File

@ -124,6 +124,12 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
} }
} }
public override void StopAllSamples()
{
base.StopAllSamples();
spinningSample?.Stop();
}
protected override void AddNestedHitObject(DrawableHitObject hitObject) protected override void AddNestedHitObject(DrawableHitObject hitObject)
{ {
base.AddNestedHitObject(hitObject); base.AddNestedHitObject(hitObject);

View File

@ -387,6 +387,11 @@ namespace osu.Game.Rulesets.Objects.Drawables
} }
} }
/// <summary>
/// Stops playback of all samples. Automatically called when <see cref="DrawableHitObject{TObject}"/>'s lifetime has been exceeded.
/// </summary>
public virtual void StopAllSamples() => Samples?.Stop();
protected override void Update() protected override void Update()
{ {
base.Update(); base.Update();
@ -455,6 +460,8 @@ namespace osu.Game.Rulesets.Objects.Drawables
foreach (var nested in NestedHitObjects) foreach (var nested in NestedHitObjects)
nested.OnKilled(); nested.OnKilled();
StopAllSamples();
UpdateResult(false); UpdateResult(false);
} }

View File

@ -73,7 +73,8 @@ namespace osu.Game.Skinning
// it's not easy to know if a sample has finished playing (to end). // it's not easy to know if a sample has finished playing (to end).
// to keep things simple only resume playing looping samples. // to keep things simple only resume playing looping samples.
else if (Looping) else if (Looping)
play(); // schedule so we don't start playing a sample which is no longer alive.
Schedule(play);
} }
}); });
} }