// The EFX surface. The pinned openal-soft always implements ALC_EXT_EFX, so there is no presence
// gate. EFX entry points bind statically in Al.PInvoke like core ones (see Extensions.cs). The
// Gen*/Delete* and typed Create* methods are generated, the latter over the checked creation
// helpers in Efx.Internal.cs.
namespace Brutal.OpenAlApi;
///
/// The EFX extension surface: effect, filter and auxiliary-effect-slot creation, plus the EFX
/// device queries.
///
///
/// Obtained from . The typed create methods (for example
/// CreateReverb) fix the object's type at creation and return a typed wrapper; the
/// Gen* methods create raw, untyped objects for lower-level use. Deletion lives on the
/// handles themselves ( etc.) or in bulk via the generated
/// Delete* span methods.
///
/// The typed create methods require a context on this instance's device to be current, and
/// throw otherwise. An belongs to
/// the it was obtained from, but the underlying AL calls route through
/// the process-global current context, so the two have to agree - otherwise the objects are
/// created on whichever device happens to be current instead. The lower-level Gen*
/// methods do not check, matching the raw AL behaviour.
///
///
public sealed partial class Efx
{
internal Device Device { get; }
internal Efx(Device device) => Device = device;
// Lifetime-constant queries, cached on first access. The versions are fixed by the loaded
// implementation; the send count is renegotiable via Device.Reset/Reopen, which call
// InvalidateDeviceCaches below.
//
// Named fields, not the property-backing 'field' keyword: 'field' is typed as the property (an
// int property can't take ??=) and is unreachable outside its own accessors (so an externally
// invalidated cache couldn't be reset). Every cache in this package is written this way.
private int? _efxMajorVersion;
private int? _efxMinorVersion;
private int? _maxAuxiliarySends;
internal void InvalidateDeviceCaches() => _maxAuxiliarySends = null;
/// The EFX major version (ALC_EFX_MAJOR_VERSION).
public int EfxMajorVersion
{
get
{
Device.ThrowIfDisposed();
var device = Device.Handle;
return _efxMajorVersion ??= Alc.GetInteger(device, AlcInteger.EfxMajorVersion);
}
}
/// The EFX minor version (ALC_EFX_MINOR_VERSION).
public int EfxMinorVersion
{
get
{
Device.ThrowIfDisposed();
var device = Device.Handle;
return _efxMinorVersion ??= Alc.GetInteger(device, AlcInteger.EfxMinorVersion);
}
}
///
/// The number of auxiliary sends per source (ALC_MAX_AUXILIARY_SENDS). Cached;
/// and (which can renegotiate it)
/// drop the cache.
///
public int MaxAuxiliarySends
{
get
{
Device.ThrowIfDisposed();
var device = Device.Handle;
return _maxAuxiliarySends ??= Alc.GetInteger(device, AlcInteger.MaxAuxiliarySends);
}
}
}