2018-06-10 20:46:42 -04:00
|
|
|
using Ryujinx.HLE.Logging;
|
|
|
|
using Ryujinx.HLE.OsHle.Handles;
|
|
|
|
using Ryujinx.HLE.OsHle.Ipc;
|
2018-03-19 14:58:46 -04:00
|
|
|
using System;
|
2018-02-09 19:14:55 -05:00
|
|
|
using System.Collections.Generic;
|
2018-02-08 11:52:02 -05:00
|
|
|
|
2018-06-10 20:46:42 -04:00
|
|
|
namespace Ryujinx.HLE.OsHle.Services.Aud
|
2018-02-04 18:08:20 -05:00
|
|
|
{
|
2018-03-19 14:58:46 -04:00
|
|
|
class IAudioRenderer : IpcService, IDisposable
|
2018-02-04 18:08:20 -05:00
|
|
|
{
|
2018-02-09 19:14:55 -05:00
|
|
|
private Dictionary<int, ServiceProcessRequest> m_Commands;
|
|
|
|
|
2018-03-19 14:58:46 -04:00
|
|
|
public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands;
|
|
|
|
|
|
|
|
private KEvent UpdateEvent;
|
2018-02-09 19:14:55 -05:00
|
|
|
|
|
|
|
public IAudioRenderer()
|
|
|
|
{
|
|
|
|
m_Commands = new Dictionary<int, ServiceProcessRequest>()
|
|
|
|
{
|
2018-06-21 22:34:04 -04:00
|
|
|
{ 4, RequestUpdateAudioRenderer },
|
|
|
|
{ 5, StartAudioRenderer },
|
|
|
|
{ 6, StopAudioRenderer },
|
|
|
|
{ 7, QuerySystemEvent },
|
|
|
|
{ 10, RequestUpdateAudioRendererAuto }
|
2018-02-09 19:14:55 -05:00
|
|
|
};
|
2018-03-19 14:58:46 -04:00
|
|
|
|
|
|
|
UpdateEvent = new KEvent();
|
2018-02-09 19:14:55 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
public long RequestUpdateAudioRenderer(ServiceCtx Context)
|
2018-02-04 18:08:20 -05:00
|
|
|
{
|
2018-06-21 22:34:04 -04:00
|
|
|
RequestUpdateAudioRendererMethod(Context, Context.Request.ReceiveBuff[0].Position);
|
2018-02-08 11:52:02 -05:00
|
|
|
|
2018-06-21 22:34:04 -04:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
public long RequestUpdateAudioRendererAuto(ServiceCtx Context)
|
|
|
|
{
|
|
|
|
RequestUpdateAudioRendererMethod(Context, Context.Request.GetBufferType0x21().Position);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void RequestUpdateAudioRendererMethod(ServiceCtx Context, long Position)
|
|
|
|
{
|
|
|
|
//(buffer<unknown, 5, 0>) -> (buffer<unknown, 6, 0>, buffer<unknown, 6, 0>)
|
2018-02-04 18:08:20 -05:00
|
|
|
|
|
|
|
//0x40 bytes header
|
2018-02-08 11:52:02 -05: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-04 18:08:20 -05: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 10:15:08 -05:00
|
|
|
|
2018-03-19 14:58:46 -04:00
|
|
|
//TODO: We shouldn't be signaling this here.
|
2018-04-18 22:52:23 -04:00
|
|
|
UpdateEvent.WaitEvent.Set();
|
2018-02-04 18:08:20 -05:00
|
|
|
}
|
|
|
|
|
2018-02-09 19:14:55 -05:00
|
|
|
public long StartAudioRenderer(ServiceCtx Context)
|
2018-02-04 18:08:20 -05:00
|
|
|
{
|
2018-04-24 14:57:39 -04:00
|
|
|
Context.Ns.Log.PrintStub(LogClass.ServiceAudio, "Stubbed.");
|
2018-04-16 20:24:42 -04:00
|
|
|
|
2018-02-04 18:08:20 -05:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-02-09 19:14:55 -05:00
|
|
|
public long StopAudioRenderer(ServiceCtx Context)
|
2018-02-08 11:52:02 -05:00
|
|
|
{
|
2018-04-24 14:57:39 -04:00
|
|
|
Context.Ns.Log.PrintStub(LogClass.ServiceAudio, "Stubbed.");
|
2018-04-16 20:24:42 -04:00
|
|
|
|
2018-02-08 11:52:02 -05:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-02-09 19:14:55 -05:00
|
|
|
public long QuerySystemEvent(ServiceCtx Context)
|
2018-02-04 18:08:20 -05:00
|
|
|
{
|
2018-03-19 14:58:46 -04:00
|
|
|
int Handle = Context.Process.HandleTable.OpenHandle(UpdateEvent);
|
2018-02-08 11:52:02 -05:00
|
|
|
|
|
|
|
Context.Response.HandleDesc = IpcHandleDesc.MakeCopy(Handle);
|
|
|
|
|
2018-02-04 18:08:20 -05:00
|
|
|
return 0;
|
|
|
|
}
|
2018-03-19 14:58:46 -04:00
|
|
|
|
|
|
|
public void Dispose()
|
|
|
|
{
|
|
|
|
Dispose(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected virtual void Dispose(bool Disposing)
|
|
|
|
{
|
|
|
|
if (Disposing)
|
|
|
|
{
|
|
|
|
UpdateEvent.Dispose();
|
|
|
|
}
|
|
|
|
}
|
2018-02-04 18:08:20 -05:00
|
|
|
}
|
2018-06-21 22:34:04 -04:00
|
|
|
}
|