Example #1
0
        public int Dequeue(TimeLocatedBuffer buffer, int length = -1)
        {
            lock (this) {
                if (length == -1)
                {
                    length = buffer.GetSamples().Length;
                }
                if (buffer.Samplerate != _rate)
                {
                    throw new InvalidOperationException();
                }

                var result = Dequeue(buffer.GetSamples(), 0, length);
                buffer.SetWritten(result);
                return(result);
            }
        }
Example #2
0
        public void Enqueue(TimeLocatedBuffer buffer)
        {
            lock (this) {
                if (buffer.Samplerate != _rate)
                {
                    throw new InvalidOperationException();
                }
                Enqueue(buffer.GetSamples(), 0, buffer.WrittenSamples);
                _timeBufEnd = _timeBufEnd.Add(buffer.WrittenSamples, _rate);

                if (buffer.CurrentTime.Value != _timeBufEnd.Value)
                {
                    GlobalSettings.Instance.Errors.Add(
                        new Error($"Ring Buffer: Missing samples. Buffer Timestamp: { buffer.CurrentTime.Value } \t Ring Timestamp: { _timeBufEnd.Value}")
                        );
                    _timeBufEnd = new TimeStamp(buffer.CurrentTime);
                }
            }
        }