Browse Source

Fixed a couple incoming audio bugs

pull/603/head
RogueException 8 years ago
parent
commit
0d361def93
3 changed files with 4 additions and 4 deletions
  1. +2
    -2
      src/Discord.Net.WebSocket/Audio/Opus/OpusDecoder.cs
  2. +1
    -1
      src/Discord.Net.WebSocket/Audio/Streams/OpusDecodeStream.cs
  3. +1
    -1
      src/Discord.Net.WebSocket/DiscordVoiceApiClient.cs

+ 2
- 2
src/Discord.Net.WebSocket/Audio/Opus/OpusDecoder.cs View File

@@ -32,11 +32,11 @@ namespace Discord.Audio
int result = 0; int result = 0;
fixed (byte* inPtr = input) fixed (byte* inPtr = input)
fixed (byte* outPtr = output) fixed (byte* outPtr = output)
result = Decode(_ptr, inPtr + inputOffset, inputCount, outPtr + outputOffset, (output.Length - outputOffset) / SampleSize / MaxChannels, 0);
result = Decode(_ptr, inPtr + inputOffset, inputCount, outPtr + outputOffset, (output.Length - outputOffset) / SampleSize, 0); //TODO: Enable FEC


if (result < 0) if (result < 0)
throw new Exception($"Opus Error: {(OpusError)result}"); throw new Exception($"Opus Error: {(OpusError)result}");
return result;
return result * 4;
} }


protected override void Dispose(bool disposing) protected override void Dispose(bool disposing)


+ 1
- 1
src/Discord.Net.WebSocket/Audio/Streams/OpusDecodeStream.cs View File

@@ -12,7 +12,7 @@ namespace Discord.Audio.Streams
private readonly byte[] _buffer; private readonly byte[] _buffer;
private readonly OpusDecoder _decoder; private readonly OpusDecoder _decoder;


public OpusDecodeStream(AudioStream next, int channels = OpusConverter.MaxChannels, int bufferSize = 4000)
public OpusDecodeStream(AudioStream next, int channels = OpusConverter.MaxChannels, int bufferSize = 5760 * 4)
{ {
_next = next; _next = next;
_buffer = new byte[bufferSize]; _buffer = new byte[bufferSize];


+ 1
- 1
src/Discord.Net.WebSocket/DiscordVoiceApiClient.cs View File

@@ -54,7 +54,7 @@ namespace Discord.Audio
_udp = udpSocketProvider(); _udp = udpSocketProvider();
_udp.ReceivedDatagram += async (data, index, count) => _udp.ReceivedDatagram += async (data, index, count) =>
{ {
if (index != 0)
if (index != 0 || count != data.Length)
{ {
var newData = new byte[count]; var newData = new byte[count];
Buffer.BlockCopy(data, index, newData, 0, count); Buffer.BlockCopy(data, index, newData, 0, count);


Loading…
Cancel
Save