public void AddSamples(JitterBufferAudio jitterBufferAudio)
        {
            lock (_lock)
            {
                //re-order if we can or discard

                //add to linked list
                //add front to back
                if (_bufferedAudio.Count == 0)
                {
                    _bufferedAudio.AddFirst(jitterBufferAudio);
                }
                else if (jitterBufferAudio.PacketNumber > _lastRead)
                {
                    var time = _bufferedAudio.Count * AudioManager.INPUT_AUDIO_LENGTH_MS; // this isnt quite true as there can be padding audio but good enough

                    if (time > MAXIMUM_BUFFER_SIZE_MS)
                    {
                        _bufferedAudio.Clear();
                        Logger.Warn($"Cleared Audio buffer - length was {time} ms");
                    }

                    for (var it = _bufferedAudio.First; it != null;)
                    {
                        //iterate list
                        //if packetNumber == curentItem
                        // discard
                        //else if packetNumber < _currentItem
                        //add before
                        //else if packetNumber > _currentItem
                        //add before

                        //if not added - add to end?

                        var next = it.Next;

                        if (it.Value.PacketNumber == jitterBufferAudio.PacketNumber)
                        {
                            //discard! Duplicate packet
                            return;
                        }

                        if (jitterBufferAudio.PacketNumber < it.Value.PacketNumber)
                        {
                            _bufferedAudio.AddBefore(it, jitterBufferAudio);
                            return;
                        }

                        if ((jitterBufferAudio.PacketNumber > it.Value.PacketNumber) &&
                            ((next == null) || (jitterBufferAudio.PacketNumber < next.Value.PacketNumber)))
                        {
                            _bufferedAudio.AddAfter(it, jitterBufferAudio);
                            return;
                        }

                        it = next;
                    }
                }
            }
        }
        public void AddSamples(JitterBufferAudio jitterBufferAudio)
        {
            lock (_lock)
            {
                //re-order if we can or discard

                //add to linked list
                //add front to back
                if (_bufferedAudio.Count == 0)
                {
                    _bufferedAudio.AddFirst(jitterBufferAudio);
                }
                else if (jitterBufferAudio.PacketNumber > _lastRead)
                {
                    for (var it = _bufferedAudio.First; it != null;)
                    {
                        //iterate list
                        //if packetNumber == curentItem
                        // discard
                        //else if packetNumber < _currentItem
                        //add before
                        //else if packetNumber > _currentItem
                        //add before

                        //if not added - add to end?

                        var next = it.Next;

                        if (it.Value.PacketNumber == jitterBufferAudio.PacketNumber)
                        {
                            //discard! Duplicate packet
                            return;
                        }

                        if (jitterBufferAudio.PacketNumber < it.Value.PacketNumber)
                        {
                            _bufferedAudio.AddBefore(it, jitterBufferAudio);
                            return;
                        }

                        if ((jitterBufferAudio.PacketNumber > it.Value.PacketNumber) &&
                            ((next == null) || (jitterBufferAudio.PacketNumber < next.Value.PacketNumber)))
                        {
                            _bufferedAudio.AddAfter(it, jitterBufferAudio);
                            return;
                        }

                        it = next;
                    }
                }
            }
        }
 public void AddSamples(JitterBufferAudio jitterBufferAudio)
 {
     _circularBuffer.Write(jitterBufferAudio.Audio, 0, jitterBufferAudio.Audio.Length);
 }