DeliveryCacheProgressService.cs 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. using Ryujinx.Common.Logging;
  2. using Ryujinx.Horizon.Bcat.Ipc.Types;
  3. using Ryujinx.Horizon.Common;
  4. using Ryujinx.Horizon.Sdk.Bcat;
  5. using Ryujinx.Horizon.Sdk.OsTypes;
  6. using Ryujinx.Horizon.Sdk.Sf;
  7. using Ryujinx.Horizon.Sdk.Sf.Hipc;
  8. using System;
  9. using System.Threading;
  10. namespace Ryujinx.Horizon.Bcat.Ipc
  11. {
  12. partial class DeliveryCacheProgressService : IDeliveryCacheProgressService, IDisposable
  13. {
  14. private int _handle;
  15. private SystemEventType _systemEvent;
  16. private int _disposalState;
  17. [CmifCommand(0)]
  18. public Result GetEvent([CopyHandle] out int handle)
  19. {
  20. if (_handle == 0)
  21. {
  22. Os.CreateSystemEvent(out _systemEvent, EventClearMode.ManualClear, true).AbortOnFailure();
  23. _handle = Os.GetReadableHandleOfSystemEvent(ref _systemEvent);
  24. }
  25. handle = _handle;
  26. Logger.Stub?.PrintStub(LogClass.ServiceBcat);
  27. return Result.Success;
  28. }
  29. [CmifCommand(1)]
  30. public Result GetImpl([Buffer(HipcBufferFlags.Out | HipcBufferFlags.Pointer, 0x200)] out DeliveryCacheProgressImpl deliveryCacheProgressImpl)
  31. {
  32. deliveryCacheProgressImpl = new DeliveryCacheProgressImpl
  33. {
  34. State = DeliveryCacheProgressImpl.Status.Done,
  35. Result = 0
  36. };
  37. Logger.Stub?.PrintStub(LogClass.ServiceBcat);
  38. return Result.Success;
  39. }
  40. public void Dispose()
  41. {
  42. if (_handle != 0 && Interlocked.Exchange(ref _disposalState, 1) == 0)
  43. {
  44. Os.DestroySystemEvent(ref _systemEvent);
  45. }
  46. }
  47. }
  48. }