mirror of
https://github.com/Ryubing/Ryujinx.git
synced 2025-11-27 06:22:22 -05: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>
182 lines
5.6 KiB
C#
182 lines
5.6 KiB
C#
using Ryujinx.Audio.Common;
|
|
using Ryujinx.Cpu;
|
|
using Ryujinx.HLE.HOS.Ipc;
|
|
using Ryujinx.HLE.HOS.Kernel.Threading;
|
|
using Ryujinx.Horizon.Common;
|
|
using Ryujinx.Memory;
|
|
using System;
|
|
using System.Runtime.InteropServices;
|
|
|
|
namespace Ryujinx.HLE.HOS.Services.Audio.AudioOut
|
|
{
|
|
class AudioOutServer : DisposableIpcService
|
|
{
|
|
private readonly IAudioOut _impl;
|
|
|
|
public AudioOutServer(IAudioOut impl)
|
|
{
|
|
_impl = impl;
|
|
}
|
|
|
|
[CommandCmif(0)]
|
|
// GetAudioOutState() -> u32 state
|
|
public ResultCode GetAudioOutState(ServiceCtx context)
|
|
{
|
|
context.ResponseData.Write((uint)_impl.GetState());
|
|
|
|
return ResultCode.Success;
|
|
}
|
|
|
|
[CommandCmif(1)]
|
|
// Start()
|
|
public ResultCode Start(ServiceCtx context)
|
|
{
|
|
return _impl.Start();
|
|
}
|
|
|
|
[CommandCmif(2)]
|
|
// Stop()
|
|
public ResultCode Stop(ServiceCtx context)
|
|
{
|
|
return _impl.Stop();
|
|
}
|
|
|
|
[CommandCmif(3)]
|
|
// AppendAudioOutBuffer(u64 bufferTag, buffer<nn::audio::AudioOutBuffer, 5> buffer)
|
|
public ResultCode AppendAudioOutBuffer(ServiceCtx context)
|
|
{
|
|
ulong position = context.Request.SendBuff[0].Position;
|
|
|
|
ulong bufferTag = context.RequestData.ReadUInt64();
|
|
|
|
AudioUserBuffer data = MemoryHelper.Read<AudioUserBuffer>(context.Memory, position);
|
|
|
|
return _impl.AppendBuffer(bufferTag, ref data);
|
|
}
|
|
|
|
[CommandCmif(4)]
|
|
// RegisterBufferEvent() -> handle<copy>
|
|
public ResultCode RegisterBufferEvent(ServiceCtx context)
|
|
{
|
|
KEvent bufferEvent = _impl.RegisterBufferEvent();
|
|
|
|
if (context.Process.HandleTable.GenerateHandle(bufferEvent.ReadableEvent, out int handle) != Result.Success)
|
|
{
|
|
throw new InvalidOperationException("Out of handles!");
|
|
}
|
|
|
|
context.Response.HandleDesc = IpcHandleDesc.MakeCopy(handle);
|
|
|
|
return ResultCode.Success;
|
|
}
|
|
|
|
[CommandCmif(5)]
|
|
// GetReleasedAudioOutBuffers() -> (u32 count, buffer<u64, 6> tags)
|
|
public ResultCode GetReleasedAudioOutBuffers(ServiceCtx context)
|
|
{
|
|
ulong position = context.Request.ReceiveBuff[0].Position;
|
|
ulong size = context.Request.ReceiveBuff[0].Size;
|
|
|
|
using WritableRegion outputRegion = context.Memory.GetWritableRegion(position, (int)size);
|
|
ResultCode result = _impl.GetReleasedBuffers(MemoryMarshal.Cast<byte, ulong>(outputRegion.Memory.Span), out uint releasedCount);
|
|
|
|
context.ResponseData.Write(releasedCount);
|
|
|
|
return result;
|
|
}
|
|
|
|
[CommandCmif(6)]
|
|
// ContainsAudioOutBuffer(u64 tag) -> b8
|
|
public ResultCode ContainsAudioOutBuffer(ServiceCtx context)
|
|
{
|
|
ulong bufferTag = context.RequestData.ReadUInt64();
|
|
|
|
context.ResponseData.Write(_impl.ContainsBuffer(bufferTag));
|
|
|
|
return ResultCode.Success;
|
|
}
|
|
|
|
[CommandCmif(7)] // 3.0.0+
|
|
// AppendAudioOutBufferAuto(u64 tag, buffer<nn::audio::AudioOutBuffer, 0x21>)
|
|
public ResultCode AppendAudioOutBufferAuto(ServiceCtx context)
|
|
{
|
|
(ulong position, _) = context.Request.GetBufferType0x21();
|
|
|
|
ulong bufferTag = context.RequestData.ReadUInt64();
|
|
|
|
AudioUserBuffer data = MemoryHelper.Read<AudioUserBuffer>(context.Memory, position);
|
|
|
|
return _impl.AppendBuffer(bufferTag, ref data);
|
|
}
|
|
|
|
[CommandCmif(8)] // 3.0.0+
|
|
// GetReleasedAudioOutBuffersAuto() -> (u32 count, buffer<u64, 0x22> tags)
|
|
public ResultCode GetReleasedAudioOutBuffersAuto(ServiceCtx context)
|
|
{
|
|
(ulong position, ulong size) = context.Request.GetBufferType0x22();
|
|
|
|
using WritableRegion outputRegion = context.Memory.GetWritableRegion(position, (int)size);
|
|
ResultCode result = _impl.GetReleasedBuffers(MemoryMarshal.Cast<byte, ulong>(outputRegion.Memory.Span), out uint releasedCount);
|
|
|
|
context.ResponseData.Write(releasedCount);
|
|
|
|
return result;
|
|
}
|
|
|
|
[CommandCmif(9)] // 4.0.0+
|
|
// GetAudioOutBufferCount() -> u32
|
|
public ResultCode GetAudioOutBufferCount(ServiceCtx context)
|
|
{
|
|
context.ResponseData.Write(_impl.GetBufferCount());
|
|
|
|
return ResultCode.Success;
|
|
}
|
|
|
|
[CommandCmif(10)] // 4.0.0+
|
|
// GetAudioOutPlayedSampleCount() -> u64
|
|
public ResultCode GetAudioOutPlayedSampleCount(ServiceCtx context)
|
|
{
|
|
context.ResponseData.Write(_impl.GetPlayedSampleCount());
|
|
|
|
return ResultCode.Success;
|
|
}
|
|
|
|
[CommandCmif(11)] // 4.0.0+
|
|
// FlushAudioOutBuffers() -> b8
|
|
public ResultCode FlushAudioOutBuffers(ServiceCtx context)
|
|
{
|
|
context.ResponseData.Write(_impl.FlushBuffers());
|
|
|
|
return ResultCode.Success;
|
|
}
|
|
|
|
[CommandCmif(12)] // 6.0.0+
|
|
// SetAudioOutVolume(s32)
|
|
public ResultCode SetAudioOutVolume(ServiceCtx context)
|
|
{
|
|
float volume = context.RequestData.ReadSingle();
|
|
|
|
_impl.SetVolume(volume);
|
|
|
|
return ResultCode.Success;
|
|
}
|
|
|
|
[CommandCmif(13)] // 6.0.0+
|
|
// GetAudioOutVolume() -> s32
|
|
public ResultCode GetAudioOutVolume(ServiceCtx context)
|
|
{
|
|
context.ResponseData.Write(_impl.GetVolume());
|
|
|
|
return ResultCode.Success;
|
|
}
|
|
|
|
protected override void Dispose(bool isDisposing)
|
|
{
|
|
if (isDisposing)
|
|
{
|
|
_impl.Dispose();
|
|
}
|
|
}
|
|
}
|
|
}
|