2018-04-24 18:57:39 +00:00
|
|
|
using Ryujinx.Core.Logging;
|
2018-02-25 04:34:16 +00:00
|
|
|
using Ryujinx.Core.OsHle.Ipc;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
2018-03-20 20:00:00 +00:00
|
|
|
namespace Ryujinx.Core.OsHle.Services.Aud
|
2018-02-25 04:34:16 +00:00
|
|
|
{
|
2018-03-21 23:30:10 +00:00
|
|
|
class IAudioRendererManager : IpcService
|
2018-02-25 04:34:16 +00:00
|
|
|
{
|
|
|
|
private Dictionary<int, ServiceProcessRequest> m_Commands;
|
|
|
|
|
2018-03-19 18:58:46 +00:00
|
|
|
public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands;
|
2018-02-25 04:34:16 +00:00
|
|
|
|
2018-03-21 23:30:10 +00:00
|
|
|
public IAudioRendererManager()
|
2018-02-25 04:34:16 +00:00
|
|
|
{
|
|
|
|
m_Commands = new Dictionary<int, ServiceProcessRequest>()
|
|
|
|
{
|
2018-03-12 19:29:06 +00:00
|
|
|
{ 0, OpenAudioRenderer },
|
|
|
|
{ 1, GetAudioRendererWorkBufferSize },
|
|
|
|
{ 2, GetAudioDevice }
|
2018-02-25 04:34:16 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
public long OpenAudioRenderer(ServiceCtx Context)
|
|
|
|
{
|
|
|
|
MakeObject(Context, new IAudioRenderer());
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
public long GetAudioRendererWorkBufferSize(ServiceCtx Context)
|
|
|
|
{
|
2018-05-02 00:02:28 +00:00
|
|
|
long SampleRate = Context.RequestData.ReadUInt32();
|
|
|
|
long Unknown4 = Context.RequestData.ReadUInt32();
|
|
|
|
long Unknown8 = Context.RequestData.ReadUInt32();
|
|
|
|
long UnknownC = Context.RequestData.ReadUInt32();
|
|
|
|
long Unknown10 = Context.RequestData.ReadUInt32();
|
|
|
|
long Unknown14 = Context.RequestData.ReadUInt32();
|
|
|
|
long Unknown18 = Context.RequestData.ReadUInt32();
|
|
|
|
long Unknown1c = Context.RequestData.ReadUInt32();
|
|
|
|
uint Reserved20 = Context.RequestData.ReadUInt32(); //Not used in FW1.0
|
|
|
|
uint Reserved24 = Context.RequestData.ReadUInt32(); //Not used in FW1.0
|
|
|
|
uint Reserved28 = Context.RequestData.ReadUInt32(); //Not used in FW1.0
|
|
|
|
uint Reserved2c = Context.RequestData.ReadUInt32(); //Not used in FW1.0
|
|
|
|
uint Rev1Magic = Context.RequestData.ReadUInt32();
|
2018-02-25 04:34:16 +00:00
|
|
|
|
2018-05-02 00:02:28 +00:00
|
|
|
if (Rev1Magic == 0x31564552) //REV1
|
|
|
|
{
|
|
|
|
long Size;
|
|
|
|
|
|
|
|
Size = UnknownC * 0x400 + 0x50;
|
|
|
|
Size += RoundUp(Unknown8 * 4, 64);
|
|
|
|
Size += (UnknownC + 1) * 0x940;
|
|
|
|
Size += Unknown14 * 0x170;
|
|
|
|
Size += Unknown10 * 0x100;
|
|
|
|
Size += (Unknown14 + UnknownC) * 0x2C0;
|
|
|
|
Size += Unknown10 * 0x2F0;
|
|
|
|
Size += Unknown10 * 0x100 + 0x40;
|
|
|
|
Size += Unknown18 * 0x4B0;
|
|
|
|
Size += RoundUp((UnknownC + 1) * 8, 16);
|
|
|
|
Size += RoundUp(Unknown10 * 8, 16);
|
|
|
|
Size += (Unknown18 + Unknown10 * 4) * 0x20;
|
|
|
|
Size += RoundUp((Unknown4 * 4 + (UnknownC + Unknown14) * 0x3C0) * (Unknown8 + 6), 64);
|
|
|
|
|
|
|
|
if (Unknown1c == 0)
|
|
|
|
{
|
|
|
|
Size += (((((UnknownC + 1) + Unknown10 + Unknown14 + Unknown18) * 16 + 0x658) * (Unknown1c + 1) + 0xFF) & ~0x3FL);
|
|
|
|
}
|
|
|
|
|
|
|
|
long WorkBufferSize = (Size + 0x1907D) & ~0xFFFL;
|
|
|
|
|
|
|
|
Context.ResponseData.Write(WorkBufferSize);
|
|
|
|
|
|
|
|
Context.Ns.Log.PrintDebug(LogClass.ServiceAudio, $"WorkBufferSize is 0x{WorkBufferSize:x16}.");
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Context.ResponseData.Write(0L);
|
|
|
|
|
|
|
|
Context.Ns.Log.PrintError(LogClass.ServiceAudio, "REV1 magic not found!");
|
|
|
|
|
|
|
|
return 0x499;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private static long RoundUp(long Value, int Size)
|
|
|
|
{
|
|
|
|
return (Value + (Size - 1)) & ~((long)Size - 1);
|
2018-02-25 04:34:16 +00:00
|
|
|
}
|
2018-03-12 05:07:48 +00:00
|
|
|
|
2018-03-12 19:29:06 +00:00
|
|
|
public long GetAudioDevice(ServiceCtx Context)
|
2018-03-12 05:07:48 +00:00
|
|
|
{
|
2018-03-12 19:29:06 +00:00
|
|
|
long UserId = Context.RequestData.ReadInt64();
|
|
|
|
|
2018-04-22 04:21:49 +00:00
|
|
|
MakeObject(Context, new IAudioDevice());
|
2018-03-12 05:07:48 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2018-02-25 04:34:16 +00:00
|
|
|
}
|
2018-05-02 00:02:28 +00:00
|
|
|
}
|