public override int FillStreamBuffer(int samplePos, short[] buffer) { queue.RetrieveBuffer(bufferID, out int compressedSize, out byte[] compressedBuffer); if (compressedSize > 0) { VoipConfig.Decoder.Decode(compressedBuffer, 0, compressedSize, buffer, 0, VoipConfig.BUFFER_SIZE); bufferID++; return(VoipConfig.BUFFER_SIZE * 2); } if (bufferID < queue.LatestBufferID - (VoipQueue.BUFFER_COUNT - 1)) { bufferID = queue.LatestBufferID - (VoipQueue.BUFFER_COUNT - 1); } return(0); }
public override int FillStreamBuffer(int samplePos, short[] buffer) { queue.RetrieveBuffer(bufferID, out int compressedSize, out byte[] compressedBuffer); try { if (compressedSize > 0) { VoipConfig.Decoder.Decode(compressedBuffer, 0, compressedSize, buffer, 0, VoipConfig.BUFFER_SIZE); bufferID++; return(VoipConfig.BUFFER_SIZE); } if (bufferID < queue.LatestBufferID - (VoipQueue.BUFFER_COUNT - 1)) { bufferID = queue.LatestBufferID - (VoipQueue.BUFFER_COUNT - 1); } } catch (Exception e) { DebugConsole.ThrowError($"Failed to decode Opus buffer (buffer size {compressedBuffer.Length}, packet size {compressedSize})", e); bufferID = queue.LatestBufferID - (VoipQueue.BUFFER_COUNT - 1); } return(0); }