Enable FEC decoding

This commit is contained in:
RogueException
2017-04-07 21:28:03 -03:00
parent 483d26093b
commit 65154e0d4a
3 changed files with 4 additions and 4 deletions

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>

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)

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];