private void FreeBufferList() { _currentBuffer = null; if (_bufferList != null) { var firstBuffer = _bufferList; _bufferList = null; var buffer = firstBuffer; do { WaveOutBuffer nextBuffer = buffer.NextBuffer; buffer.Dispose(); buffer = nextBuffer; } while (buffer != firstBuffer); } }
private void AllocateBufferList(int bufferSize, int bufferCount) { FreeBufferList(); if (bufferCount > 0) { _bufferList = new WaveOutBuffer(_wave, bufferSize); WaveOutBuffer prevBuffer = _bufferList; try { for (int bufferIndex = 1; bufferIndex < bufferCount; bufferIndex++) { var buffer = new WaveOutBuffer(_wave, bufferSize); prevBuffer.NextBuffer = buffer; prevBuffer = buffer; } } finally { prevBuffer.NextBuffer = _bufferList; } } }
private void Advance() { _currentBuffer = (_currentBuffer == null ? _bufferList : _currentBuffer.NextBuffer); _currentBuffer.WaitFor(); }