Exemplo n.º 1
0
        private ResultCode DecodeInterleavedInternal(ServiceCtx context, OpusDecoderFlags flags, bool reset, bool withPerf)
        {
            ulong inPosition     = context.Request.SendBuff[0].Position;
            ulong inSize         = context.Request.SendBuff[0].Size;
            ulong outputPosition = context.Request.ReceiveBuff[0].Position;
            ulong outputSize     = context.Request.ReceiveBuff[0].Size;

            ReadOnlySpan <byte> input = context.Memory.GetSpan(inPosition, (int)inSize);

            ResultCode result = _decoder.DecodeInterleaved(reset, input, out short[] outPcmData, outputSize, out uint outConsumed, out int outSamples);

            if (result == ResultCode.Success)
            {
                context.Memory.Write(outputPosition, MemoryMarshal.Cast <short, byte>(outPcmData.AsSpan()));

                context.ResponseData.Write(outConsumed);
                context.ResponseData.Write(outSamples);

                if (withPerf)
                {
                    // This is the time the DSP took to process the request, TODO: fill this.
                    context.ResponseData.Write(0UL);
                }
            }

            return(result);
        }