aboutsummaryrefslogtreecommitdiff
path: root/src/Ryujinx.Horizon/Sdk/Audio/AudioEvent.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Ryujinx.Horizon/Sdk/Audio/AudioEvent.cs')
-rw-r--r--src/Ryujinx.Horizon/Sdk/Audio/AudioEvent.cs50
1 files changed, 50 insertions, 0 deletions
diff --git a/src/Ryujinx.Horizon/Sdk/Audio/AudioEvent.cs b/src/Ryujinx.Horizon/Sdk/Audio/AudioEvent.cs
new file mode 100644
index 00000000..efa8d5bc
--- /dev/null
+++ b/src/Ryujinx.Horizon/Sdk/Audio/AudioEvent.cs
@@ -0,0 +1,50 @@
+using Ryujinx.Audio.Integration;
+using Ryujinx.Horizon.Common;
+using Ryujinx.Horizon.Sdk.OsTypes;
+using System;
+
+namespace Ryujinx.Horizon.Sdk.Audio
+{
+ class AudioEvent : IWritableEvent, IDisposable
+ {
+ private SystemEventType _systemEvent;
+ private readonly IExternalEvent _externalEvent;
+
+ public AudioEvent()
+ {
+ Os.CreateSystemEvent(out _systemEvent, EventClearMode.ManualClear, interProcess: true);
+
+ // We need to do this because the event will be signalled from a different thread.
+ _externalEvent = HorizonStatic.Syscall.GetExternalEvent(Os.GetWritableHandleOfSystemEvent(ref _systemEvent));
+ }
+
+ public void Signal()
+ {
+ _externalEvent.Signal();
+ }
+
+ public void Clear()
+ {
+ _externalEvent.Clear();
+ }
+
+ public int GetReadableHandle()
+ {
+ return Os.GetReadableHandleOfSystemEvent(ref _systemEvent);
+ }
+
+ protected virtual void Dispose(bool disposing)
+ {
+ if (disposing)
+ {
+ Os.DestroySystemEvent(ref _systemEvent);
+ }
+ }
+
+ public void Dispose()
+ {
+ Dispose(disposing: true);
+ GC.SuppressFinalize(this);
+ }
+ }
+}