// Like AlBuffer, an OpenAL source is an ALuint object *name*, not a pointer - a value type over a
// uint.
//
// Hand-written half: the queue span operations and the auxiliary send. Everything else is
// generated (identity, playback verbs, named properties) or lives elsewhere (keyed access in the
// opt-in Params namespace, the latency/clock getters in AlSource.Ext.cs).
namespace Brutal.OpenAlApi;
public readonly unsafe partial struct AlSource
{
///
/// Queues buffers onto the source, in playback order, for streaming playback
/// (alSourceQueueBuffers).
///
public void QueueBuffers(ReadOnlySpan buffers)
{
if (buffers.IsEmpty)
return;
var names = MemoryMarshal.Cast(buffers);
fixed (uint* p = names)
Al.PInvoke.SourceQueueBuffers(Name, names.Length, p);
}
///
/// Removes processed buffers from the front of the source's queue
/// (alSourceUnqueueBuffers), filling with the removed
/// buffer names. The span's length determines how many are unqueued and must not exceed the
/// number of processed buffers on the source.
///
public void UnqueueBuffers(Span buffers)
{
if (buffers.IsEmpty)
return;
var names = MemoryMarshal.Cast(buffers);
fixed (uint* p = names)
Al.PInvoke.SourceUnqueueBuffers(Name, names.Length, p);
}
///
/// Routes this source to an auxiliary effect slot (AL_AUXILIARY_SEND_FILTER,
/// alSource3i), optionally through a wet-path filter (,
/// the default, means unfiltered). Pass to disable
/// the send. Send indices run 0 to - 1.
///
public void SetAuxiliarySend(AlAuxiliaryEffectSlot slot, int send, AlFilter filter = default)
{
Al.PInvoke.Source3i(Name, Al.Constants.AL_AUXILIARY_SEND_FILTER, (int)slot.Name, send, (int)filter.Name);
}
}