mirror of
https://git.743378673.xyz/MeloNX/MeloNX.git
synced 2025-07-23 15:07:11 +02:00

* dotnet format style --severity info Some changes were manually reverted. * dotnet format analyzers --serverity info Some changes have been minimally adapted. * Restore a few unused methods and variables * Silence dotnet format IDE0060 warnings * Silence dotnet format IDE0052 warnings * Address or silence dotnet format IDE1006 warnings * Address dotnet format CA1816 warnings * Address or silence dotnet format CA2208 warnings * Address or silence dotnet format CA1806 and a few CA1854 warnings * Address dotnet format CA2211 warnings * Address dotnet format CA1822 warnings * Address or silence dotnet format CA1069 warnings * Make dotnet format succeed in style mode * Address or silence dotnet format CA2211 warnings * Address review comments * Address dotnet format CA2208 warnings properly * Make ProcessResult readonly * Address most dotnet format whitespace warnings * Apply dotnet format whitespace formatting A few of them have been manually reverted and the corresponding warning was silenced * Add previously silenced warnings back I have no clue how these disappeared * Revert formatting changes for while and for-loops * Format if-blocks correctly * Run dotnet format style after rebase * Run dotnet format whitespace after rebase * Run dotnet format style after rebase * Run dotnet format analyzers after rebase * Run dotnet format after rebase and remove unused usings - analyzers - style - whitespace * Disable 'prefer switch expression' rule * Add comments to disabled warnings * Fix a few disabled warnings * Fix naming rule violation, Convert shader properties to auto-property and convert values to const * Simplify properties and array initialization, Use const when possible, Remove trailing commas * Start working on disabled warnings * Fix and silence a few dotnet-format warnings again * Run dotnet format after rebase * Use using declaration instead of block syntax * Address IDE0251 warnings * Address a few disabled IDE0060 warnings * Silence IDE0060 in .editorconfig * Revert "Simplify properties and array initialization, Use const when possible, Remove trailing commas" This reverts commit 9462e4136c0a2100dc28b20cf9542e06790aa67e. * dotnet format whitespace after rebase * First dotnet format pass * Fix naming rule violations * Fix typo * Add trailing commas, use targeted new and use array initializer * Fix build issues * Fix remaining build issues * Remove SuppressMessage for CA1069 where possible * Address dotnet format issues * Address formatting issues Co-authored-by: Ac_K <acoustik666@gmail.com> * Add GetHashCode implementation for RenderingSurfaceInfo * Explicitly silence CA1822 for every affected method in Syscall * Address formatting issues in Demangler.cs * Address review feedback Co-authored-by: Ac_K <acoustik666@gmail.com> * Revert marking service methods as static * Next dotnet format pass * Address review feedback --------- Co-authored-by: Ac_K <acoustik666@gmail.com>
215 lines
7.3 KiB
C#
215 lines
7.3 KiB
C#
using Ryujinx.Common.Logging;
|
|
using Ryujinx.Common.Memory;
|
|
using Ryujinx.HLE.HOS.Ipc;
|
|
using Ryujinx.HLE.HOS.Kernel.Threading;
|
|
using Ryujinx.Horizon.Common;
|
|
using System;
|
|
using System.Buffers;
|
|
|
|
namespace Ryujinx.HLE.HOS.Services.Audio.AudioRenderer
|
|
{
|
|
class AudioRendererServer : DisposableIpcService
|
|
{
|
|
private readonly IAudioRenderer _impl;
|
|
|
|
public AudioRendererServer(IAudioRenderer impl)
|
|
{
|
|
_impl = impl;
|
|
}
|
|
|
|
[CommandCmif(0)]
|
|
// GetSampleRate() -> u32
|
|
public ResultCode GetSampleRate(ServiceCtx context)
|
|
{
|
|
context.ResponseData.Write(_impl.GetSampleRate());
|
|
|
|
return ResultCode.Success;
|
|
}
|
|
|
|
[CommandCmif(1)]
|
|
// GetSampleCount() -> u32
|
|
public ResultCode GetSampleCount(ServiceCtx context)
|
|
{
|
|
context.ResponseData.Write(_impl.GetSampleCount());
|
|
|
|
return ResultCode.Success;
|
|
}
|
|
|
|
[CommandCmif(2)]
|
|
// GetMixBufferCount() -> u32
|
|
public ResultCode GetMixBufferCount(ServiceCtx context)
|
|
{
|
|
context.ResponseData.Write(_impl.GetMixBufferCount());
|
|
|
|
return ResultCode.Success;
|
|
}
|
|
|
|
[CommandCmif(3)]
|
|
// GetState() -> u32
|
|
public ResultCode GetState(ServiceCtx context)
|
|
{
|
|
context.ResponseData.Write(_impl.GetState());
|
|
|
|
return ResultCode.Success;
|
|
}
|
|
|
|
[CommandCmif(4)]
|
|
// RequestUpdate(buffer<nn::audio::detail::AudioRendererUpdateDataHeader, 5> input)
|
|
// -> (buffer<nn::audio::detail::AudioRendererUpdateDataHeader, 6> output, buffer<nn::audio::detail::AudioRendererUpdateDataHeader, 6> performanceOutput)
|
|
public ResultCode RequestUpdate(ServiceCtx context)
|
|
{
|
|
ulong inputPosition = context.Request.SendBuff[0].Position;
|
|
ulong inputSize = context.Request.SendBuff[0].Size;
|
|
|
|
ulong outputPosition = context.Request.ReceiveBuff[0].Position;
|
|
ulong outputSize = context.Request.ReceiveBuff[0].Size;
|
|
|
|
ulong performanceOutputPosition = context.Request.ReceiveBuff[1].Position;
|
|
ulong performanceOutputSize = context.Request.ReceiveBuff[1].Size;
|
|
|
|
ReadOnlyMemory<byte> input = context.Memory.GetSpan(inputPosition, (int)inputSize).ToArray();
|
|
|
|
using IMemoryOwner<byte> outputOwner = ByteMemoryPool.RentCleared(outputSize);
|
|
using IMemoryOwner<byte> performanceOutputOwner = ByteMemoryPool.RentCleared(performanceOutputSize);
|
|
Memory<byte> output = outputOwner.Memory;
|
|
Memory<byte> performanceOutput = performanceOutputOwner.Memory;
|
|
|
|
using MemoryHandle outputHandle = output.Pin();
|
|
using MemoryHandle performanceOutputHandle = performanceOutput.Pin();
|
|
|
|
ResultCode result = _impl.RequestUpdate(output, performanceOutput, input);
|
|
|
|
if (result == ResultCode.Success)
|
|
{
|
|
context.Memory.Write(outputPosition, output.Span);
|
|
context.Memory.Write(performanceOutputPosition, performanceOutput.Span);
|
|
}
|
|
else
|
|
{
|
|
Logger.Error?.Print(LogClass.ServiceAudio, $"Error while processing renderer update: 0x{(int)result:X}");
|
|
}
|
|
|
|
return result;
|
|
}
|
|
|
|
[CommandCmif(5)]
|
|
// Start()
|
|
public ResultCode Start(ServiceCtx context)
|
|
{
|
|
return _impl.Start();
|
|
}
|
|
|
|
[CommandCmif(6)]
|
|
// Stop()
|
|
public ResultCode Stop(ServiceCtx context)
|
|
{
|
|
return _impl.Stop();
|
|
}
|
|
|
|
[CommandCmif(7)]
|
|
// QuerySystemEvent() -> handle<copy, event>
|
|
public ResultCode QuerySystemEvent(ServiceCtx context)
|
|
{
|
|
ResultCode result = _impl.QuerySystemEvent(out KEvent systemEvent);
|
|
|
|
if (result == ResultCode.Success)
|
|
{
|
|
if (context.Process.HandleTable.GenerateHandle(systemEvent.ReadableEvent, out int handle) != Result.Success)
|
|
{
|
|
throw new InvalidOperationException("Out of handles!");
|
|
}
|
|
|
|
context.Response.HandleDesc = IpcHandleDesc.MakeCopy(handle);
|
|
}
|
|
|
|
return result;
|
|
}
|
|
|
|
[CommandCmif(8)]
|
|
// SetAudioRendererRenderingTimeLimit(u32 limit)
|
|
public ResultCode SetAudioRendererRenderingTimeLimit(ServiceCtx context)
|
|
{
|
|
uint limit = context.RequestData.ReadUInt32();
|
|
|
|
_impl.SetRenderingTimeLimit(limit);
|
|
|
|
return ResultCode.Success;
|
|
}
|
|
|
|
[CommandCmif(9)]
|
|
// GetAudioRendererRenderingTimeLimit() -> u32 limit
|
|
public ResultCode GetAudioRendererRenderingTimeLimit(ServiceCtx context)
|
|
{
|
|
uint limit = _impl.GetRenderingTimeLimit();
|
|
|
|
context.ResponseData.Write(limit);
|
|
|
|
return ResultCode.Success;
|
|
}
|
|
|
|
[CommandCmif(10)] // 3.0.0+
|
|
// RequestUpdateAuto(buffer<nn::audio::detail::AudioRendererUpdateDataHeader, 0x21> input)
|
|
// -> (buffer<nn::audio::detail::AudioRendererUpdateDataHeader, 0x22> output, buffer<nn::audio::detail::AudioRendererUpdateDataHeader, 0x22> performanceOutput)
|
|
public ResultCode RequestUpdateAuto(ServiceCtx context)
|
|
{
|
|
(ulong inputPosition, ulong inputSize) = context.Request.GetBufferType0x21();
|
|
(ulong outputPosition, ulong outputSize) = context.Request.GetBufferType0x22(0);
|
|
(ulong performanceOutputPosition, ulong performanceOutputSize) = context.Request.GetBufferType0x22(1);
|
|
|
|
ReadOnlyMemory<byte> input = context.Memory.GetSpan(inputPosition, (int)inputSize).ToArray();
|
|
|
|
Memory<byte> output = new byte[outputSize];
|
|
Memory<byte> performanceOutput = new byte[performanceOutputSize];
|
|
|
|
using MemoryHandle outputHandle = output.Pin();
|
|
using MemoryHandle performanceOutputHandle = performanceOutput.Pin();
|
|
|
|
ResultCode result = _impl.RequestUpdate(output, performanceOutput, input);
|
|
|
|
if (result == ResultCode.Success)
|
|
{
|
|
context.Memory.Write(outputPosition, output.Span);
|
|
context.Memory.Write(performanceOutputPosition, performanceOutput.Span);
|
|
}
|
|
|
|
return result;
|
|
}
|
|
|
|
[CommandCmif(11)] // 3.0.0+
|
|
// ExecuteAudioRendererRendering()
|
|
public ResultCode ExecuteAudioRendererRendering(ServiceCtx context)
|
|
{
|
|
return _impl.ExecuteAudioRendererRendering();
|
|
}
|
|
|
|
[CommandCmif(12)] // 15.0.0+
|
|
// SetVoiceDropParameter(f32 voiceDropParameter)
|
|
public ResultCode SetVoiceDropParameter(ServiceCtx context)
|
|
{
|
|
float voiceDropParameter = context.RequestData.ReadSingle();
|
|
|
|
_impl.SetVoiceDropParameter(voiceDropParameter);
|
|
|
|
return ResultCode.Success;
|
|
}
|
|
|
|
[CommandCmif(13)] // 15.0.0+
|
|
// GetVoiceDropParameter() -> f32 voiceDropParameter
|
|
public ResultCode GetVoiceDropParameter(ServiceCtx context)
|
|
{
|
|
float voiceDropParameter = _impl.GetVoiceDropParameter();
|
|
|
|
context.ResponseData.Write(voiceDropParameter);
|
|
|
|
return ResultCode.Success;
|
|
}
|
|
|
|
protected override void Dispose(bool isDisposing)
|
|
{
|
|
if (isDisposing)
|
|
{
|
|
_impl.Dispose();
|
|
}
|
|
}
|
|
}
|
|
}
|