[CommandHipc(5)] // 12.0.0+ // GetWorkBufferSizeEx(OpusParametersEx) -> u32 public ResultCode GetWorkBufferSizeEx(ServiceCtx context) { OpusParametersEx parameters = context.RequestData.ReadStruct <OpusParametersEx>(); // NOTE: The sample rate is ignored because it is fixed to 48KHz. context.ResponseData.Write(GetOpusDecoderSize(parameters.ChannelCount)); return(ResultCode.Success); }
[CommandHipc(4)] // 12.0.0+ // InitializeEx(OpusParametersEx, u32, handle<copy>) -> object<nn::codec::detail::IHardwareOpusDecoder> public ResultCode InitializeEx(ServiceCtx context) { OpusParametersEx parameters = context.RequestData.ReadStruct <OpusParametersEx>(); // UseLargeFrameSize can be ignored due to not relying on fixed size buffers for storing the decoded result. MakeObject(context, new IHardwareOpusDecoder(parameters.SampleRate, parameters.ChannelCount)); // Close transfer memory immediately as we don't use it. context.Device.System.KernelContext.Syscall.CloseHandle(context.Request.HandleDesc.ToCopy[0]); return(ResultCode.Success); }
[CommandHipc(5)] // 12.0.0+ // GetWorkBufferSizeEx(OpusParametersEx) -> u32 public ResultCode GetWorkBufferSizeEx(ServiceCtx context) { OpusParametersEx parameters = context.RequestData.ReadStruct <OpusParametersEx>(); int opusDecoderSize = GetOpusDecoderSize(parameters.ChannelsCount); int frameSizeMono48KHz = parameters.Flags.HasFlag(OpusDecoderFlags.LargeFrameSize) ? 5760 : 1920; int frameSize = BitUtils.AlignUp(parameters.ChannelsCount * frameSizeMono48KHz / (48000 / parameters.SampleRate), 64); int totalSize = opusDecoderSize + 1536 + frameSize; context.ResponseData.Write(totalSize); return(ResultCode.Success); }