2018-02-20 21:09:23 +01:00
|
|
|
using Ryujinx.Core.OsHle.Handles;
|
|
|
|
using Ryujinx.Core.OsHle.Ipc;
|
2018-03-19 19:58:46 +01:00
|
|
|
using System;
|
2018-02-10 01:14:55 +01:00
|
|
|
using System.Collections.Generic;
|
2018-02-08 17:52:02 +01:00
|
|
|
|
2018-03-20 21:00:00 +01:00
|
|
|
namespace Ryujinx.Core.OsHle.Services.Aud
|
2018-02-05 00:08:20 +01:00
|
|
|
{
|
2018-03-19 19:58:46 +01:00
|
|
|
class IAudioRenderer : IpcService, IDisposable
|
2018-02-05 00:08:20 +01:00
|
|
|
{
|
2018-02-10 01:14:55 +01:00
|
|
|
private Dictionary<int, ServiceProcessRequest> m_Commands;
|
|
|
|
|
2018-03-19 19:58:46 +01:00
|
|
|
public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands;
|
|
|
|
|
|
|
|
private KEvent UpdateEvent;
|
2018-02-10 01:14:55 +01:00
|
|
|
|
|
|
|
public IAudioRenderer()
|
|
|
|
{
|
|
|
|
m_Commands = new Dictionary<int, ServiceProcessRequest>()
|
|
|
|
{
|
|
|
|
{ 4, RequestUpdateAudioRenderer },
|
|
|
|
{ 5, StartAudioRenderer },
|
|
|
|
{ 6, StopAudioRenderer },
|
|
|
|
{ 7, QuerySystemEvent }
|
|
|
|
};
|
2018-03-19 19:58:46 +01:00
|
|
|
|
|
|
|
UpdateEvent = new KEvent();
|
2018-02-10 01:14:55 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public long RequestUpdateAudioRenderer(ServiceCtx Context)
|
2018-02-05 00:08:20 +01:00
|
|
|
{
|
2018-02-10 01:14:55 +01:00
|
|
|
//(buffer<unknown, 5, 0>) -> (buffer<unknown, 6, 0>, buffer<unknown, 6, 0>)
|
2018-02-08 17:52:02 +01:00
|
|
|
|
2018-02-05 00:08:20 +01:00
|
|
|
long Position = Context.Request.ReceiveBuff[0].Position;
|
|
|
|
|
|
|
|
//0x40 bytes header
|
2018-02-08 17:52:02 +01:00
|
|
|
Context.Memory.WriteInt32(Position + 0x4, 0xb0); //Behavior Out State Size? (note: this is the last section)
|
|
|
|
Context.Memory.WriteInt32(Position + 0x8, 0x18e0); //Memory Pool Out State Size?
|
|
|
|
Context.Memory.WriteInt32(Position + 0xc, 0x600); //Voice Out State Size?
|
2018-02-05 00:08:20 +01:00
|
|
|
Context.Memory.WriteInt32(Position + 0x14, 0xe0); //Effect Out State Size?
|
|
|
|
Context.Memory.WriteInt32(Position + 0x1c, 0x20); //Sink Out State Size?
|
|
|
|
Context.Memory.WriteInt32(Position + 0x20, 0x10); //Performance Out State Size?
|
|
|
|
Context.Memory.WriteInt32(Position + 0x3c, 0x20e0); //Total Size (including 0x40 bytes header)
|
|
|
|
|
|
|
|
for (int Offset = 0x40; Offset < 0x40 + 0x18e0; Offset += 0x10)
|
|
|
|
{
|
|
|
|
Context.Memory.WriteInt32(Position + Offset, 5);
|
|
|
|
}
|
2018-02-06 16:15:08 +01:00
|
|
|
|
2018-03-19 19:58:46 +01:00
|
|
|
//TODO: We shouldn't be signaling this here.
|
|
|
|
UpdateEvent.Handle.Set();
|
|
|
|
|
2018-02-05 00:08:20 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-02-10 01:14:55 +01:00
|
|
|
public long StartAudioRenderer(ServiceCtx Context)
|
2018-02-05 00:08:20 +01:00
|
|
|
{
|
2018-04-17 02:24:42 +02:00
|
|
|
Logging.Stub(LogClass.ServiceAudio, "Stubbed");
|
|
|
|
|
2018-02-05 00:08:20 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-02-10 01:14:55 +01:00
|
|
|
public long StopAudioRenderer(ServiceCtx Context)
|
2018-02-08 17:52:02 +01:00
|
|
|
{
|
2018-04-17 02:24:42 +02:00
|
|
|
Logging.Stub(LogClass.ServiceAudio, "Stubbed");
|
|
|
|
|
2018-02-08 17:52:02 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-02-10 01:14:55 +01:00
|
|
|
public long QuerySystemEvent(ServiceCtx Context)
|
2018-02-05 00:08:20 +01:00
|
|
|
{
|
2018-03-19 19:58:46 +01:00
|
|
|
int Handle = Context.Process.HandleTable.OpenHandle(UpdateEvent);
|
2018-02-08 17:52:02 +01:00
|
|
|
|
|
|
|
Context.Response.HandleDesc = IpcHandleDesc.MakeCopy(Handle);
|
|
|
|
|
2018-02-05 00:08:20 +01:00
|
|
|
return 0;
|
|
|
|
}
|
2018-03-19 19:58:46 +01:00
|
|
|
|
|
|
|
public void Dispose()
|
|
|
|
{
|
|
|
|
Dispose(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected virtual void Dispose(bool Disposing)
|
|
|
|
{
|
|
|
|
if (Disposing)
|
|
|
|
{
|
|
|
|
UpdateEvent.Dispose();
|
|
|
|
}
|
|
|
|
}
|
2018-02-05 00:08:20 +01:00
|
|
|
}
|
|
|
|
}
|