Browse Source

Added offset to VoiceBuffer

tags/docs-0.9
RogueException 9 years ago
parent
commit
83470eb386
1 changed files with 4 additions and 4 deletions
  1. +4
    -4
      src/Discord.Net.Audio/VoiceBuffer.cs

+ 4
- 4
src/Discord.Net.Audio/VoiceBuffer.cs 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;


Loading…
Cancel
Save