NVorbis.RingBuffer.CopyTo C# (CSharp) Method

CopyTo() private method

private CopyTo ( float buffer, int index, int count ) : void
buffer float
index int
count int
return void
        internal void CopyTo(float[] buffer, int index, int count)
        {
            if (index < 0 || index + count > buffer.Length) throw new ArgumentOutOfRangeException("index");

            var start = _start;
            RemoveItems(count);

            // this is used to pull data out of the buffer, so we'll update the start position too...
            var len = (_end - start + _bufLen) % _bufLen;
            if (count > len) throw new ArgumentOutOfRangeException("count");

            var cnt = Math.Min(count, _bufLen - start);
            Array.Copy(_buffer, start, buffer, index, cnt);

            if (cnt < count)
            {
                Array.Copy(_buffer, 0, buffer, index + cnt, count - cnt);
            }
        }

Usage Example

Exemplo n.º 1
0
        internal int ReadSamples(float[] buffer, int offset, int count)
        {
            int num = 0;

            lock (_seekLock)
            {
                if (_prevBuffer != null)
                {
                    int num2 = Math.Min(count, _prevBuffer.Length);
                    Buffer.BlockCopy(_prevBuffer, 0, buffer, offset, num2 * 4);
                    if (num2 < _prevBuffer.Length)
                    {
                        float[] array = new float[_prevBuffer.Length - num2];
                        Buffer.BlockCopy(_prevBuffer, num2 * 4, array, 0, (_prevBuffer.Length - num2) * 4);
                        _prevBuffer = array;
                    }
                    else
                    {
                        _prevBuffer = null;
                    }
                    count  -= num2;
                    offset += num2;
                    num     = num2;
                }
                else if (_isParameterChange)
                {
                    throw new InvalidOperationException("Currently pending a parameter change.  Read new parameters before requesting further samples!");
                }
                int size = count + Block1Size * _channels;
                _outputBuffer.EnsureSize(size);
                while (_preparedLength * _channels < count && !_eosFound && !_isParameterChange)
                {
                    DecodeNextPacket();
                    if (_prevBuffer != null)
                    {
                        return(ReadSamples(buffer, offset, _prevBuffer.Length));
                    }
                }
                if (_preparedLength * _channels < count)
                {
                    count = _preparedLength * _channels;
                }
                _outputBuffer.CopyTo(buffer, offset, count);
                _preparedLength  -= count / _channels;
                _reportedPosition = _currentPosition - _preparedLength;
            }
            return(num + count);
        }
All Usage Examples Of NVorbis.RingBuffer::CopyTo