Merge pull request #27226 from peppy/no-audio-filter-funny-business

Ensure audio filters can't be attached before load (or post-disposal)
This commit is contained in:
Bartłomiej Dach 2024-02-19 13:01:34 +01:00 committed by GitHub
commit d7b1e3ba50
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 15 additions and 1 deletions

View File

@ -4,6 +4,7 @@
using System.Diagnostics;
using ManagedBass.Fx;
using osu.Framework.Audio.Mixing;
using osu.Framework.Caching;
using osu.Framework.Graphics;
namespace osu.Game.Audio.Effects
@ -22,6 +23,8 @@ public partial class AudioFilter : Component, ITransformableFilter
private bool isAttached;
private readonly Cached filterApplication = new Cached();
private int cutoff;
/// <summary>
@ -36,7 +39,7 @@ public int Cutoff
return;
cutoff = value;
updateFilter(cutoff);
filterApplication.Invalidate();
}
}
@ -61,6 +64,17 @@ public AudioFilter(AudioMixer mixer, BQFType type = BQFType.LowPass)
Cutoff = getInitialCutoff(type);
}
protected override void Update()
{
base.Update();
if (!filterApplication.IsValid)
{
updateFilter(cutoff);
filterApplication.Validate();
}
}
private int getInitialCutoff(BQFType type)
{
switch (type)