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);
}