/// <summary>
        /// Flushes the rest of the PCM data in this buffer to VoiceNext packet queue.
        /// </summary>
        // Token: 0x060000C5 RID: 197 RVA: 0x00003DEC File Offset: 0x00001FEC
        public unsafe override void Flush()
        {
            Span <byte> span = this.PcmMemory.Span;

            Helpers.ZeroFill(span.Slice(this.PcmBufferLength));
            Span <short>        pcmData = MemoryMarshal.Cast <byte, short>(span);
            List <IVoiceFilter> filters = this.Filters;

            lock (filters)
            {
                if (this.Filters.Any <IVoiceFilter>())
                {
                    foreach (IVoiceFilter voiceFilter in this.Filters)
                    {
                        voiceFilter.Transform(pcmData, this.Connection.AudioFormat, this.SampleDuration);
                    }
                }
            }
            if (this.VolumeModifier != 1.0)
            {
                for (int i = 0; i < pcmData.Length; i++)
                {
                    *pcmData[i] = (short)((double)(*pcmData[i]) * this.VolumeModifier);
                }
            }
            Memory <byte> memory = MemoryExtensions.AsMemory <byte>(new byte[span.Length]);

            this.Connection.PreparePacket(span, ref memory);
            this.Connection.EnqueuePacket(new VoicePacket(memory, this.PcmBufferDuration, false));
        }
 // Token: 0x060000BF RID: 191 RVA: 0x00003B10 File Offset: 0x00001D10
 internal VoiceTransmitStream(VoiceNextConnection vnc, int pcmBufferDuration)
 {
     this.Connection        = vnc;
     this.PcmBufferDuration = pcmBufferDuration;
     this.PcmBuffer         = new byte[vnc.AudioFormat.CalculateSampleSize(pcmBufferDuration)];
     this.PcmMemory         = MemoryExtensions.AsMemory <byte>(this.PcmBuffer);
     this.PcmBufferLength   = 0;
     this.Filters           = new List <IVoiceFilter>();
 }
 /// <summary>
 /// Writes PCM data to the stream. The data is prepared for transmission, and enqueued.
 /// </summary>
 /// <param name="buffer">PCM data buffer to send.</param>
 // Token: 0x060000C4 RID: 196 RVA: 0x00003BD4 File Offset: 0x00001DD4
 public unsafe void Write(ReadOnlySpan <byte> buffer)
 {
     byte[] pcmBuffer = this.PcmBuffer;
     lock (pcmBuffer)
     {
         int i = buffer.Length;
         ReadOnlySpan <byte> readOnlySpan = buffer;
         Span <byte>         span         = this.PcmMemory.Span;
         while (i > 0)
         {
             int         num   = Math.Min(span.Length - this.PcmBufferLength, i);
             Span <byte> span2 = span.Slice(this.PcmBufferLength);
             readOnlySpan.Slice(0, num).CopyTo(span2);
             this.PcmBufferLength += num;
             i           -= num;
             readOnlySpan = readOnlySpan.Slice(num);
             if (this.PcmBufferLength == this.PcmBuffer.Length)
             {
                 Span <short>        pcmData = MemoryMarshal.Cast <byte, short>(span);
                 List <IVoiceFilter> filters = this.Filters;
                 lock (filters)
                 {
                     if (this.Filters.Any <IVoiceFilter>())
                     {
                         foreach (IVoiceFilter voiceFilter in this.Filters)
                         {
                             voiceFilter.Transform(pcmData, this.Connection.AudioFormat, this.SampleDuration);
                         }
                     }
                 }
                 if (this.VolumeModifier != 1.0)
                 {
                     for (int j = 0; j < pcmData.Length; j++)
                     {
                         *pcmData[j] = (short)((double)(*pcmData[j]) * this.VolumeModifier);
                     }
                 }
                 this.PcmBufferLength = 0;
                 Memory <byte> memory = MemoryExtensions.AsMemory <byte>(new byte[span.Length]);
                 this.Connection.PreparePacket(span, ref memory);
                 this.Connection.EnqueuePacket(new VoicePacket(memory, this.PcmBufferDuration, false));
             }
         }
     }
 }