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:
Ac_K 2019-07-12 03:13:43 +02:00 committed by gdkchan
parent f723f6f39a
commit 560ccbeb2d
99 changed files with 1035 additions and 1983 deletions

View file

@ -1,6 +1,4 @@
using Concentus.Structs;
using Ryujinx.HLE.HOS.Ipc;
using System.Collections.Generic;
using static Ryujinx.HLE.HOS.ErrorCode;
@ -10,10 +8,6 @@ namespace Ryujinx.HLE.HOS.Services.Aud
{
private const int FixedSampleRate = 48000;
private Dictionary<int, ServiceProcessRequest> _commands;
public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => _commands;
private int _sampleRate;
private int _channelsCount;
@ -21,29 +15,14 @@ namespace Ryujinx.HLE.HOS.Services.Aud
public IHardwareOpusDecoder(int sampleRate, int channelsCount)
{
_commands = new Dictionary<int, ServiceProcessRequest>
{
{ 0, DecodeInterleaved },
{ 4, DecodeInterleavedWithPerf }
};
_sampleRate = sampleRate;
_channelsCount = channelsCount;
_decoder = new OpusDecoder(FixedSampleRate, channelsCount);
}
public long DecodeInterleavedWithPerf(ServiceCtx context)
{
long result = DecodeInterleaved(context);
// TODO: Figure out what this value is.
// According to switchbrew, it is now used.
context.ResponseData.Write(0L);
return result;
}
[Command(0)]
// DecodeInterleaved(buffer<unknown, 5>) -> (u32, u32, buffer<unknown, 6>)
public long DecodeInterleaved(ServiceCtx context)
{
long inPosition = context.Request.SendBuff[0].Position;
@ -87,5 +66,18 @@ namespace Ryujinx.HLE.HOS.Services.Aud
return 0;
}
[Command(4)]
// DecodeInterleavedWithPerf(buffer<unknown, 5>) -> (u32, u32, u64, buffer<unknown, 0x46>)
public long DecodeInterleavedWithPerf(ServiceCtx context)
{
long result = DecodeInterleaved(context);
// TODO: Figure out what this value is.
// According to switchbrew, it is now used.
context.ResponseData.Write(0L);
return result;
}
}
}
}