IAudioRenderer.cs 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. using Ryujinx.Core.Logging;
  2. using Ryujinx.Core.OsHle.Handles;
  3. using Ryujinx.Core.OsHle.Ipc;
  4. using System;
  5. using System.Collections.Generic;
  6. namespace Ryujinx.Core.OsHle.Services.Aud
  7. {
  8. class IAudioRenderer : IpcService, IDisposable
  9. {
  10. private Dictionary<int, ServiceProcessRequest> m_Commands;
  11. public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands;
  12. private KEvent UpdateEvent;
  13. public IAudioRenderer()
  14. {
  15. m_Commands = new Dictionary<int, ServiceProcessRequest>()
  16. {
  17. { 4, RequestUpdateAudioRenderer },
  18. { 5, StartAudioRenderer },
  19. { 6, StopAudioRenderer },
  20. { 7, QuerySystemEvent }
  21. };
  22. UpdateEvent = new KEvent();
  23. }
  24. public long RequestUpdateAudioRenderer(ServiceCtx Context)
  25. {
  26. //(buffer<unknown, 5, 0>) -> (buffer<unknown, 6, 0>, buffer<unknown, 6, 0>)
  27. long Position = Context.Request.ReceiveBuff[0].Position;
  28. //0x40 bytes header
  29. Context.Memory.WriteInt32(Position + 0x4, 0xb0); //Behavior Out State Size? (note: this is the last section)
  30. Context.Memory.WriteInt32(Position + 0x8, 0x18e0); //Memory Pool Out State Size?
  31. Context.Memory.WriteInt32(Position + 0xc, 0x600); //Voice Out State Size?
  32. Context.Memory.WriteInt32(Position + 0x14, 0xe0); //Effect Out State Size?
  33. Context.Memory.WriteInt32(Position + 0x1c, 0x20); //Sink Out State Size?
  34. Context.Memory.WriteInt32(Position + 0x20, 0x10); //Performance Out State Size?
  35. Context.Memory.WriteInt32(Position + 0x3c, 0x20e0); //Total Size (including 0x40 bytes header)
  36. for (int Offset = 0x40; Offset < 0x40 + 0x18e0; Offset += 0x10)
  37. {
  38. Context.Memory.WriteInt32(Position + Offset, 5);
  39. }
  40. //TODO: We shouldn't be signaling this here.
  41. UpdateEvent.WaitEvent.Set();
  42. return 0;
  43. }
  44. public long StartAudioRenderer(ServiceCtx Context)
  45. {
  46. Context.Ns.Log.PrintStub(LogClass.ServiceAudio, "Stubbed.");
  47. return 0;
  48. }
  49. public long StopAudioRenderer(ServiceCtx Context)
  50. {
  51. Context.Ns.Log.PrintStub(LogClass.ServiceAudio, "Stubbed.");
  52. return 0;
  53. }
  54. public long QuerySystemEvent(ServiceCtx Context)
  55. {
  56. int Handle = Context.Process.HandleTable.OpenHandle(UpdateEvent);
  57. Context.Response.HandleDesc = IpcHandleDesc.MakeCopy(Handle);
  58. return 0;
  59. }
  60. public void Dispose()
  61. {
  62. Dispose(true);
  63. }
  64. protected virtual void Dispose(bool Disposing)
  65. {
  66. if (Disposing)
  67. {
  68. UpdateEvent.Dispose();
  69. }
  70. }
  71. }
  72. }