Refactoring commands handling (#728)
* Refactoring commands handling - Use Reflection to handle commands ID. - Add all symbols (from SwIPC so not all time accurate). - Re-sort some services commands methods. - Some cleanup. - Keep some empty constructor for consistency. * Fix order in IProfile
This commit is contained in:
parent
f723f6f39a
commit
560ccbeb2d
99 changed files with 1035 additions and 1983 deletions
|
@ -4,42 +4,24 @@ using Ryujinx.HLE.HOS.Ipc;
|
|||
using Ryujinx.HLE.HOS.Kernel.Common;
|
||||
using Ryujinx.HLE.HOS.Kernel.Threading;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Ryujinx.HLE.HOS.Services.Aud.AudioOut
|
||||
{
|
||||
class IAudioOut : IpcService, IDisposable
|
||||
{
|
||||
private Dictionary<int, ServiceProcessRequest> _commands;
|
||||
|
||||
public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => _commands;
|
||||
|
||||
private IAalOutput _audioOut;
|
||||
|
||||
private KEvent _releaseEvent;
|
||||
|
||||
private int _track;
|
||||
private KEvent _releaseEvent;
|
||||
private int _track;
|
||||
|
||||
public IAudioOut(IAalOutput audioOut, KEvent releaseEvent, int track)
|
||||
{
|
||||
_commands = new Dictionary<int, ServiceProcessRequest>
|
||||
{
|
||||
{ 0, GetAudioOutState },
|
||||
{ 1, StartAudioOut },
|
||||
{ 2, StopAudioOut },
|
||||
{ 3, AppendAudioOutBuffer },
|
||||
{ 4, RegisterBufferEvent },
|
||||
{ 5, GetReleasedAudioOutBuffer },
|
||||
{ 6, ContainsAudioOutBuffer },
|
||||
{ 7, AppendAudioOutBufferAuto },
|
||||
{ 8, GetReleasedAudioOutBufferAuto }
|
||||
};
|
||||
|
||||
_audioOut = audioOut;
|
||||
_releaseEvent = releaseEvent;
|
||||
_track = track;
|
||||
}
|
||||
|
||||
[Command(0)]
|
||||
// GetAudioOutState() -> u32 state
|
||||
public long GetAudioOutState(ServiceCtx context)
|
||||
{
|
||||
context.ResponseData.Write((int)_audioOut.GetState(_track));
|
||||
|
@ -47,6 +29,8 @@ namespace Ryujinx.HLE.HOS.Services.Aud.AudioOut
|
|||
return 0;
|
||||
}
|
||||
|
||||
[Command(1)]
|
||||
// StartAudioOut()
|
||||
public long StartAudioOut(ServiceCtx context)
|
||||
{
|
||||
_audioOut.Start(_track);
|
||||
|
@ -54,6 +38,8 @@ namespace Ryujinx.HLE.HOS.Services.Aud.AudioOut
|
|||
return 0;
|
||||
}
|
||||
|
||||
[Command(2)]
|
||||
// StopAudioOut()
|
||||
public long StopAudioOut(ServiceCtx context)
|
||||
{
|
||||
_audioOut.Stop(_track);
|
||||
|
@ -61,11 +47,15 @@ namespace Ryujinx.HLE.HOS.Services.Aud.AudioOut
|
|||
return 0;
|
||||
}
|
||||
|
||||
[Command(3)]
|
||||
// AppendAudioOutBuffer(u64 tag, buffer<nn::audio::AudioOutBuffer, 5>)
|
||||
public long AppendAudioOutBuffer(ServiceCtx context)
|
||||
{
|
||||
return AppendAudioOutBufferImpl(context, context.Request.SendBuff[0].Position);
|
||||
}
|
||||
|
||||
[Command(4)]
|
||||
// RegisterBufferEvent() -> handle<copy>
|
||||
public long RegisterBufferEvent(ServiceCtx context)
|
||||
{
|
||||
if (context.Process.HandleTable.GenerateHandle(_releaseEvent.ReadableEvent, out int handle) != KernelResult.Success)
|
||||
|
@ -78,6 +68,8 @@ namespace Ryujinx.HLE.HOS.Services.Aud.AudioOut
|
|||
return 0;
|
||||
}
|
||||
|
||||
[Command(5)]
|
||||
// GetReleasedAudioOutBuffer() -> (u32 count, buffer<nn::audio::AudioOutBuffer, 6>)
|
||||
public long GetReleasedAudioOutBuffer(ServiceCtx context)
|
||||
{
|
||||
long position = context.Request.ReceiveBuff[0].Position;
|
||||
|
@ -86,6 +78,8 @@ namespace Ryujinx.HLE.HOS.Services.Aud.AudioOut
|
|||
return GetReleasedAudioOutBufferImpl(context, position, size);
|
||||
}
|
||||
|
||||
[Command(6)]
|
||||
// ContainsAudioOutBuffer(u64 tag) -> b8
|
||||
public long ContainsAudioOutBuffer(ServiceCtx context)
|
||||
{
|
||||
long tag = context.RequestData.ReadInt64();
|
||||
|
@ -95,6 +89,8 @@ namespace Ryujinx.HLE.HOS.Services.Aud.AudioOut
|
|||
return 0;
|
||||
}
|
||||
|
||||
[Command(7)] // 3.0.0+
|
||||
// AppendAudioOutBufferAuto(u64 tag, buffer<nn::audio::AudioOutBuffer, 0x21>)
|
||||
public long AppendAudioOutBufferAuto(ServiceCtx context)
|
||||
{
|
||||
(long position, long size) = context.Request.GetBufferType0x21();
|
||||
|
@ -119,6 +115,8 @@ namespace Ryujinx.HLE.HOS.Services.Aud.AudioOut
|
|||
return 0;
|
||||
}
|
||||
|
||||
[Command(8)] // 3.0.0+
|
||||
// GetReleasedAudioOutBufferAuto() -> (u32 count, buffer<nn::audio::AudioOutBuffer, 0x22>)
|
||||
public long GetReleasedAudioOutBufferAuto(ServiceCtx context)
|
||||
{
|
||||
(long position, long size) = context.Request.GetBufferType0x22();
|
||||
|
@ -162,4 +160,4 @@ namespace Ryujinx.HLE.HOS.Services.Aud.AudioOut
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue