internal void Update() { if (State != SoundState.Playing) { // Shh, we don't need you right now... return; } if (handle != IntPtr.Zero) { FAudio.FAudioVoiceState state; FAudio.FAudioSourceVoice_GetState( handle, out state, FAudio.FAUDIO_VOICE_NOSAMPLESPLAYED ); while (PendingBufferCount > state.BuffersQueued) { Marshal.FreeHGlobal(queuedBuffers[0]); queuedBuffers.RemoveAt(0); } } // Do we need even moar buffers? for ( int i = MINIMUM_BUFFER_CHECK - PendingBufferCount; (i > 0) && BufferNeeded != null; i -= 1 ) { BufferNeeded(this, null); } }