/// <summary> /// Fills the buffer. /// </summary> /// <param name="target">The OpenALDataBuffer.</param> private void FillBuffer(OpenALDataBuffer target) { lock (_locker) { var unqueueBuffer = new uint[1]; OpenAL.alSourceUnqueueBuffers(_source.SourceId, 1, unqueueBuffer); var data = new byte[_bufferSize]; var datalength = _bufferSize; if (_bufferSize > _audioData.Length - _processedBytes) { Buffer.BlockCopy(_audioData, _processedBytes, data, 0, _audioData.Length - _processedBytes); datalength = _audioData.Length - _processedBytes; _processedBytes += datalength; } else { Buffer.BlockCopy(_audioData, _processedBytes, data, 0, _bufferSize); _processedBytes += _bufferSize; } _audioMixer.ApplyEffects(data, WaveFormat); OpenAL.alBufferData(target.Id, Format, data, datalength, SampleRate); OpenAL.alSourceQueueBuffers(_source.SourceId, 1, new[] { target.Id }); } }