mirror of
https://github.com/ppy/osu.git
synced 2025-01-28 11:02:54 +08:00
Don't stop non-looping samples immediately when pausing
This commit is contained in:
parent
e41085dbb5
commit
758088672c
@ -109,9 +109,9 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void StopAllSamples()
|
public override void StopLoopingSamples()
|
||||||
{
|
{
|
||||||
base.StopAllSamples();
|
base.StopLoopingSamples();
|
||||||
slidingSample?.Stop();
|
slidingSample?.Stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -124,9 +124,9 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void StopAllSamples()
|
public override void StopLoopingSamples()
|
||||||
{
|
{
|
||||||
base.StopAllSamples();
|
base.StopLoopingSamples();
|
||||||
spinningSample?.Stop();
|
spinningSample?.Stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,6 +18,7 @@ using osu.Game.Rulesets.Objects.Types;
|
|||||||
using osu.Game.Rulesets.Scoring;
|
using osu.Game.Rulesets.Scoring;
|
||||||
using osu.Game.Skinning;
|
using osu.Game.Skinning;
|
||||||
using osu.Game.Configuration;
|
using osu.Game.Configuration;
|
||||||
|
using osu.Game.Screens.Play;
|
||||||
using osuTK.Graphics;
|
using osuTK.Graphics;
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Objects.Drawables
|
namespace osu.Game.Rulesets.Objects.Drawables
|
||||||
@ -387,7 +388,10 @@ namespace osu.Game.Rulesets.Objects.Drawables
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Stops playback of all samples. Automatically called when <see cref="DrawableHitObject{TObject}"/>'s lifetime has been exceeded.
|
/// Stops playback of all samples. Automatically called when <see cref="DrawableHitObject{TObject}"/>'s lifetime has been exceeded.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public virtual void StopAllSamples() => Samples?.Stop();
|
public virtual void StopLoopingSamples()
|
||||||
|
{
|
||||||
|
if (Samples?.Looping == true)
|
||||||
|
Samples.Stop();
|
||||||
|
|
||||||
protected override void Update()
|
protected override void Update()
|
||||||
{
|
{
|
||||||
@ -457,7 +461,9 @@ namespace osu.Game.Rulesets.Objects.Drawables
|
|||||||
foreach (var nested in NestedHitObjects)
|
foreach (var nested in NestedHitObjects)
|
||||||
nested.OnKilled();
|
nested.OnKilled();
|
||||||
|
|
||||||
StopAllSamples();
|
// failsafe to ensure looping samples don't get stuck in a playing state.
|
||||||
|
// this could occur in a non-frame-stable context where DrawableHitObjects get killed before a SkinnableSound has the chance to be stopped.
|
||||||
|
StopLoopingSamples();
|
||||||
|
|
||||||
UpdateResult(false);
|
UpdateResult(false);
|
||||||
}
|
}
|
||||||
|
@ -34,21 +34,21 @@ namespace osu.Game.Skinning
|
|||||||
samplePlaybackDisabled.BindTo(samplePlaybackDisabler.SamplePlaybackDisabled);
|
samplePlaybackDisabled.BindTo(samplePlaybackDisabler.SamplePlaybackDisabled);
|
||||||
samplePlaybackDisabled.BindValueChanged(disabled =>
|
samplePlaybackDisabled.BindValueChanged(disabled =>
|
||||||
{
|
{
|
||||||
if (RequestedPlaying)
|
if (!RequestedPlaying) return;
|
||||||
|
|
||||||
|
// let non-looping samples that have already been started play out to completion (sounds better than abruptly cutting off).
|
||||||
|
if (!Looping) return;
|
||||||
|
|
||||||
|
if (disabled.NewValue)
|
||||||
|
base.Stop();
|
||||||
|
else
|
||||||
{
|
{
|
||||||
if (disabled.NewValue)
|
// schedule so we don't start playing a sample which is no longer alive.
|
||||||
base.Stop();
|
Schedule(() =>
|
||||||
// it's not easy to know if a sample has finished playing (to end).
|
|
||||||
// to keep things simple only resume playing looping samples.
|
|
||||||
else if (Looping)
|
|
||||||
{
|
{
|
||||||
// schedule so we don't start playing a sample which is no longer alive.
|
if (RequestedPlaying)
|
||||||
Schedule(() =>
|
base.Play();
|
||||||
{
|
});
|
||||||
if (RequestedPlaying)
|
|
||||||
base.Play();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user