NVorbis.StreamReadBuffer.FillBuffer C# (CSharp) Method

FillBuffer() private method

private FillBuffer ( long offset, int count, int readStart, int readEnd ) : int
offset long
count int
readStart int
readEnd int
return int
        int FillBuffer(long offset, int count, int readStart, int readEnd)
        {
            var readOffset = _baseOffset + readStart;
            var readCount = readEnd - readStart;

            lock (_wrapper.LockObject)
            {
                readCount = PrepareStreamForRead(readCount, readOffset);

                ReadStream(readStart, readCount, readOffset);

                // check for full read...
                if (_end < readStart + readCount)
                {
                    count = Math.Max(0, (int)(_baseOffset + _end - offset));
                }
                else if (!_minimalRead && _end < _data.Length)
                {
                    // try to finish filling the buffer
                    readCount = _data.Length - _end;
                    readCount = PrepareStreamForRead(readCount, _baseOffset + _end);
                    _end += _wrapper.Source.Read(_data, _end, readCount);
                }
            }
            return count;
        }