/// <summary> /// Writes all buffered data to file. /// </summary> public void Flush() { lock (_syncLock) { _writer.Flush(); if (_encoder != null) { // Flush the encoder _encoder.EnsureBufferIsSufficient(ref _encodedBuffer, 0); var encodedLength = _encoder.Flush(_encodedBuffer, 0); if (encodedLength > 0) { _writer.Write(_encodedBuffer, 0, encodedLength); Length += encodedLength; } } if (!_riff) { return; } var pos = _writer.BaseStream.Position; UpdateHeader(); _writer.BaseStream.Position = pos; } }
public override void FinishWriting() { // Prevent accessing encoded buffer by multiple threads simultaneously lock (syncBuffer) { // Flush the encoder EnsureBufferIsSufficient(0); var encodedLength = encoder.Flush(encodedBuffer, 0); if (encodedLength > 0) { base.WriteBlock(encodedBuffer, 0, encodedLength); } } base.FinishWriting(); }