/// <summary> /// Encodes and writes a block of audio data. /// </summary> public override void WriteBlock(byte[] data, int startIndex, int length) { Argument.IsNotNull(data, nameof(data)); Argument.IsNotNegative(startIndex, nameof(startIndex)); Argument.IsPositive(length, nameof(length)); Argument.ConditionIsMet(startIndex + length <= data.Length, "End offset exceeds the length of data."); // Prevent accessing encoded buffer by multiple threads simultaneously lock (syncBuffer) { EnsureBufferIsSufficient(length); var encodedLength = encoder.EncodeBlock(data, startIndex, length, encodedBuffer, 0); if (encodedLength > 0) { base.WriteBlock(encodedBuffer, 0, encodedLength); } } }
/// <summary> /// Encodes and writes a block of audio data. /// </summary> public override void WriteBlock(byte[] data, int startIndex, int length) { // Prevent accessing encoded buffer by multiple threads simultaneously lock (syncBuffer) { EnsureBufferIsSufficient(length); var encodedLength = encoder.EncodeBlock(data, startIndex, length, encodedBuffer, 0); if (encodedLength > 0) { base.WriteBlock(encodedBuffer, 0, encodedLength); } } }