4 using System.Collections.Generic;
12 private static readonly HashSet<uint> bufferPool =
new HashSet<uint>();
19 private readonly
Sound sound;
21 public uint
AlBuffer {
get;
private set; } = 0;
67 DebugConsole.AddWarning($
"Error when generating sound buffer: {Al.GetErrorString(alError)}. {BuffersGenerated} buffer(s) were generated. No more sound buffers will be generated.");
72 DebugConsole.AddWarning($
"Error when generating sound buffer: result is not a valid buffer. {BuffersGenerated} buffer(s) were generated. No more sound buffers will be generated.");
77 bufferPool.Add(newBuffer);
81 DebugConsole.AddWarning($
"{BuffersGenerated} buffer(s) were generated. No more sound buffers will be generated.");
86 if (bufferPool.Count >= 2)
97 foreach (var otherSound
in sound.Owner.LoadedSounds)
99 if (otherSound == sound) {
continue; }
100 if (otherSound.IsPlaying()) {
continue; }
101 if (otherSound.Buffers ==
null) {
continue; }
102 if (otherSound.Buffers.AlBuffer == 0) {
continue; }
111 otherSound.Owner.KillChannels(otherSound);
113 AlBuffer = otherSound.Buffers.AlBuffer;
115 otherSound.Buffers.AlBuffer = 0;
116 otherSound.Buffers.AlMuffledBuffer = 0;
122 sound.Owner.MoveSoundToPosition(sound, sound.Owner.LoadedSoundCount-1);
126 throw new Exception(sound.Filename +
" has an invalid buffer!");
130 throw new Exception(sound.Filename +
" has an invalid muffled buffer!");
SoundBuffers(Sound sound)
static int BuffersGenerated
static void DeleteBuffer(uint buffer)
static bool IsBuffer(uint bid)
static void GenBuffer(out uint buffer)