public static SampleValue PreViewNextSampleValue() { lock (theLock) { SampleValue Value = DequeueSampleValue(true); return(Value); } }
public static SampleValue DequeueNextSampleValue() { lock (theLock) { SampleValue Value = DequeueSampleValue(false); return(Value); } }
public static void EnqueueSampleValue(SampleValue SampleValue) { lock (theLock) { if (_count == _capacity) { Grow(); //Debug.Print("New Capacity: " + _buffer.Length); } _buffer[_head] = SampleValue; _head = (_head + 1) % _capacity; _count++; } }
private static void Grow() { int newCapacity = _capacity << 1; SampleValue[] newBuffer = new SampleValue[newCapacity]; if (_tail < _head) { Array.Copy(_buffer, _tail, newBuffer, 0, _count); } else { Array.Copy(_buffer, _tail, newBuffer, 0, _capacity - _tail); Array.Copy(_buffer, 0, newBuffer, _capacity - _tail, _head); } _buffer = newBuffer; _head = _count; _tail = 0; _capacity = newCapacity; }
private static SampleValue DequeueSampleValue(bool PreView) { lock (theLock) { if (_count > 0) { SampleValue value = _buffer[_tail]; if (!PreView) { _tail = (_tail + 1) % _capacity; _count--; } return(value); } else { return(null); } } }