IAudioDevice.cs 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. using ChocolArm64.Memory;
  2. using Ryujinx.Core.OsHle.Ipc;
  3. using System.Collections.Generic;
  4. using System.Text;
  5. namespace Ryujinx.Core.OsHle.Services.Aud
  6. {
  7. class IAudioDevice : IpcService
  8. {
  9. private Dictionary<int, ServiceProcessRequest> m_Commands;
  10. public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands;
  11. public IAudioDevice()
  12. {
  13. m_Commands = new Dictionary<int, ServiceProcessRequest>()
  14. {
  15. { 0, ListAudioDeviceName },
  16. { 1, SetAudioDeviceOutputVolume },
  17. };
  18. }
  19. public long ListAudioDeviceName(ServiceCtx Context)
  20. {
  21. string[] Names = new string[] { "FIXME" };
  22. Context.ResponseData.Write(Names.Length);
  23. long Position = Context.Request.ReceiveBuff[0].Position;
  24. long Size = Context.Request.ReceiveBuff[0].Size;
  25. long BasePosition = Position;
  26. foreach (string Name in Names)
  27. {
  28. byte[] Buffer = Encoding.ASCII.GetBytes(Name + '\0');
  29. if ((Position - BasePosition) + Buffer.Length > Size)
  30. {
  31. break;
  32. }
  33. AMemoryHelper.WriteBytes(Context.Memory, Position, Buffer);
  34. Position += Buffer.Length;
  35. }
  36. return 0;
  37. }
  38. public long SetAudioDeviceOutputVolume(ServiceCtx Context)
  39. {
  40. float Volume = Context.RequestData.ReadSingle();
  41. long Position = Context.Request.SendBuff[0].Position;
  42. long Size = Context.Request.SendBuff[0].Size;
  43. string Name = AMemoryHelper.ReadAsciiString(Context.Memory, Position, Size);
  44. return 0;
  45. }
  46. }
  47. }