Browse Source

Enable FEC decoding

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

+ 1
- 1
src/Discord.Net.WebSocket/Audio/Opus/OpusConverter.cs View File

@@ -7,7 +7,7 @@ namespace Discord.Audio
protected IntPtr _ptr; protected IntPtr _ptr;


/// <summary> Gets the bit rate of this converter. </summary> /// <summary> Gets the bit rate of this converter. </summary>
public const int BitsPerSample = 16;
public const int BitsPerSample = sizeof(short) * 8;
/// <summary> Gets the bytes per sample. </summary> /// <summary> Gets the bytes per sample. </summary>
public const int SampleSize = (BitsPerSample / 8) * MaxChannels; public const int SampleSize = (BitsPerSample / 8) * MaxChannels;
/// <summary> Gets the maximum amount of channels this encoder supports. </summary> /// <summary> Gets the maximum amount of channels this encoder supports. </summary>


+ 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, 0); //TODO: Enable FEC
result = Decode(_ptr, inPtr + inputOffset, inputCount, outPtr + outputOffset, (output.Length - outputOffset) / SampleSize, 1);


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


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 = 5760 * 4)
public OpusDecodeStream(AudioStream next, int channels = OpusConverter.MaxChannels, int bufferSize = 5760 * 2 * sizeof(short))
{ {
_next = next; _next = next;
_buffer = new byte[bufferSize]; _buffer = new byte[bufferSize];


Loading…
Cancel
Save