1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-12 16:02:55 +08:00
This commit is contained in:
smoogipoo 2020-11-19 20:38:36 +09:00
parent 812d5d59b1
commit 70cb197957
3 changed files with 21 additions and 12 deletions

View File

@ -156,7 +156,7 @@ namespace osu.Game.Rulesets.Objects.Drawables
config.BindWith(OsuSetting.PositionalHitSounds, userPositionalHitSounds);
// Explicit non-virtual function call.
base.AddInternal(Samples = new PausableSkinnableSound(Array.Empty<ISampleInfo>()));
base.AddInternal(Samples = new PausableSkinnableSound());
}
protected override void LoadAsyncComplete()
@ -266,7 +266,8 @@ namespace osu.Game.Rulesets.Objects.Drawables
// In order to stop this needless update, the event is unbound and re-bound as late as possible in Apply().
samplesBindable.CollectionChanged -= onSamplesChanged;
Samples.Samples = Array.Empty<ISampleInfo>();
// Release the samples for other hitobjects to use.
Samples.Samples = null;
if (nestedHitObjects.IsValueCreated)
{
@ -334,8 +335,6 @@ namespace osu.Game.Rulesets.Objects.Drawables
/// </summary>
protected virtual void LoadSamples()
{
Samples.Samples = Array.Empty<ISampleInfo>();
var samples = GetSamples().ToArray();
if (samples.Length <= 0)

View File

@ -2,6 +2,7 @@
// See the LICENCE file in the repository root for full licence text.
using System.Collections.Generic;
using JetBrains.Annotations;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Threading;
@ -14,16 +15,20 @@ namespace osu.Game.Skinning
{
protected bool RequestedPlaying { get; private set; }
public PausableSkinnableSound(ISampleInfo sample)
: base(sample)
public PausableSkinnableSound()
{
}
public PausableSkinnableSound(IEnumerable<ISampleInfo> samples)
public PausableSkinnableSound([NotNull] IEnumerable<ISampleInfo> samples)
: base(samples)
{
}
public PausableSkinnableSound([NotNull] ISampleInfo sample)
: base(sample)
{
}
private readonly IBindable<bool> samplePlaybackDisabled = new Bindable<bool>();
private ScheduledDelegate scheduledStart;

View File

@ -4,6 +4,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using JetBrains.Annotations;
using osu.Framework.Allocation;
using osu.Framework.Audio;
using osu.Framework.Audio.Track;
@ -38,18 +39,23 @@ namespace osu.Game.Skinning
[Resolved(CanBeNull = true)]
private IPooledSampleProvider pooledProvider { get; set; }
public SkinnableSound(ISampleInfo sample)
: this(new[] { sample })
public SkinnableSound()
{
}
public SkinnableSound(IEnumerable<ISampleInfo> samples)
public SkinnableSound([NotNull] IEnumerable<ISampleInfo> samples)
: this()
{
this.samples = samples.ToArray();
InternalChild = SamplesContainer = new AudioContainer<PoolableSkinnableSample>();
}
public SkinnableSound([NotNull] ISampleInfo sample)
: this(new[] { sample })
{
}
private ISampleInfo[] samples;
public ISampleInfo[] Samples
@ -57,8 +63,7 @@ namespace osu.Game.Skinning
get => samples;
set
{
if (value == null)
throw new ArgumentNullException(nameof(value));
value ??= Array.Empty<ISampleInfo>();
if (samples == value)
return;