Added offset to VoiceBuffer

This commit is contained in:
RogueException
2016-01-05 00:12:51 -04:00
parent 55c5f0dade
commit 83470eb386

View File

@@ -32,18 +32,18 @@ namespace Discord.Audio
_lock = new AsyncLock();
}
public void Push(byte[] buffer, int bytes, CancellationToken cancelToken)
public void Push(byte[] buffer, int offset, int count, CancellationToken cancelToken)
{
if (cancelToken.IsCancellationRequested)
throw new OperationCanceledException("Client is disconnected.", cancelToken);
int wholeFrames = bytes / _frameSize;
int wholeFrames = count / _frameSize;
int expectedBytes = wholeFrames * _frameSize;
int lastFrameSize = bytes - expectedBytes;
int lastFrameSize = count - expectedBytes;
using (_lock.Lock())
{
for (int i = 0, pos = 0; i <= wholeFrames; i++, pos += _frameSize)
for (int i = 0, pos = offset; i <= wholeFrames; i++, pos += _frameSize)
{
//If the read cursor is in the next position, wait for it to move.
ushort nextPosition = _writeCursor;