Ryujinx/src/Ryujinx.Horizon/Sdk/Audio/AudioEvent.cs
gdkchan d4d0a48bfe
Migrate Audio service to new IPC (#6285)
* Migrate audren to new IPC

* Migrate audout

* Migrate audin

* Migrate hwopus

* Bye bye old audio service

* Switch volume control to IHardwareDeviceDriver

* Somewhat unrelated changes

* Remove Concentus reference from HLE

* Implement OpenAudioRendererForManualExecution

* Remove SetVolume/GetVolume methods that are not necessary

* Remove SetVolume/GetVolume methods that are not necessary (2)

* Fix incorrect volume update

* PR feedback

* PR feedback

* Stub audrec

* Init outParameter

* Make FinalOutputRecorderParameter/Internal readonly

* Make FinalOutputRecorder IDisposable

* Fix HardwareOpusDecoderManager parameter buffers

* Opus work buffer size and error handling improvements

* Add AudioInProtocolName enum

* Fix potential divisions by zero
2024-02-22 16:58:33 -03:00

51 lines
1.3 KiB
C#

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);
}
}
}