From 595e7716d8c1be786e7067c85b129827a2f89742 Mon Sep 17 00:00:00 2001 From: gdkchan Date: Fri, 17 Jan 2020 06:07:27 -0300 Subject: [PATCH] Support audio effect output status (#890) * Support audio effect output status * Remove extra line --- .../AudioRendererManager/EffectContext.cs | 7 +++++ .../AudioRendererManager/IAudioRenderer.cs | 27 ++++++++++++++++--- .../AudioRendererManager/Types/EffectIn.cs | 12 +++++++++ .../AudioRendererManager/Types/EffectOut.cs | 11 ++++++++ .../AudioRendererManager/Types/EffectState.cs | 8 ++++++ 5 files changed, 61 insertions(+), 4 deletions(-) create mode 100644 Ryujinx.HLE/HOS/Services/Audio/AudioRendererManager/EffectContext.cs create mode 100644 Ryujinx.HLE/HOS/Services/Audio/AudioRendererManager/Types/EffectIn.cs create mode 100644 Ryujinx.HLE/HOS/Services/Audio/AudioRendererManager/Types/EffectOut.cs create mode 100644 Ryujinx.HLE/HOS/Services/Audio/AudioRendererManager/Types/EffectState.cs diff --git a/Ryujinx.HLE/HOS/Services/Audio/AudioRendererManager/EffectContext.cs b/Ryujinx.HLE/HOS/Services/Audio/AudioRendererManager/EffectContext.cs new file mode 100644 index 000000000..88f087ed1 --- /dev/null +++ b/Ryujinx.HLE/HOS/Services/Audio/AudioRendererManager/EffectContext.cs @@ -0,0 +1,7 @@ +namespace Ryujinx.HLE.HOS.Services.Audio.AudioRendererManager +{ + class EffectContext + { + public EffectOut OutStatus; + } +} diff --git a/Ryujinx.HLE/HOS/Services/Audio/AudioRendererManager/IAudioRenderer.cs b/Ryujinx.HLE/HOS/Services/Audio/AudioRendererManager/IAudioRenderer.cs index aa9b6e516..379cf2dfb 100644 --- a/Ryujinx.HLE/HOS/Services/Audio/AudioRendererManager/IAudioRenderer.cs +++ b/Ryujinx.HLE/HOS/Services/Audio/AudioRendererManager/IAudioRenderer.cs @@ -34,6 +34,8 @@ namespace Ryujinx.HLE.HOS.Services.Audio.AudioRendererManager private VoiceContext[] _voices; + private EffectContext[] _effects; + private int _track; private PlayState _playState; @@ -42,22 +44,24 @@ namespace Ryujinx.HLE.HOS.Services.Audio.AudioRendererManager Horizon system, MemoryManager memory, IAalOutput audioOut, - AudioRendererParameter Params) + AudioRendererParameter rendererParams) { _updateEvent = new KEvent(system); _memory = memory; _audioOut = audioOut; - _params = Params; + _params = rendererParams; _track = audioOut.OpenTrack( AudioRendererConsts.HostSampleRate, AudioRendererConsts.HostChannelsCount, AudioCallback); - _memoryPools = CreateArray(Params.EffectCount + Params.VoiceCount * 4); + _memoryPools = CreateArray(rendererParams.EffectCount + rendererParams.VoiceCount * 4); - _voices = CreateArray(Params.VoiceCount); + _voices = CreateArray(rendererParams.VoiceCount); + + _effects = CreateArray(rendererParams.EffectCount); InitializeAudioOut(); @@ -205,6 +209,16 @@ namespace Ryujinx.HLE.HOS.Services.Audio.AudioRendererManager voiceCtx.PlayState = voice.PlayState; } + EffectIn[] effectsIn = reader.Read(inputHeader.EffectSize); + + for (int index = 0; index < effectsIn.Length; index++) + { + if (effectsIn[index].IsNew != 0) + { + _effects[index].OutStatus.State = EffectState.New; + } + } + UpdateAudio(); UpdateDataHeader outputHeader = new UpdateDataHeader(); @@ -245,6 +259,11 @@ namespace Ryujinx.HLE.HOS.Services.Audio.AudioRendererManager writer.Write(voice.OutStatus); } + foreach (EffectContext effect in _effects) + { + writer.Write(effect.OutStatus); + } + return ResultCode.Success; } diff --git a/Ryujinx.HLE/HOS/Services/Audio/AudioRendererManager/Types/EffectIn.cs b/Ryujinx.HLE/HOS/Services/Audio/AudioRendererManager/Types/EffectIn.cs new file mode 100644 index 000000000..035204753 --- /dev/null +++ b/Ryujinx.HLE/HOS/Services/Audio/AudioRendererManager/Types/EffectIn.cs @@ -0,0 +1,12 @@ +using System.Runtime.InteropServices; + +namespace Ryujinx.HLE.HOS.Services.Audio.AudioRendererManager +{ + [StructLayout(LayoutKind.Sequential, Size = 0xc0, Pack = 1)] + unsafe struct EffectIn + { + public byte Unknown0x0; + public byte IsNew; + public fixed byte Unknown[0xbe]; + } +} diff --git a/Ryujinx.HLE/HOS/Services/Audio/AudioRendererManager/Types/EffectOut.cs b/Ryujinx.HLE/HOS/Services/Audio/AudioRendererManager/Types/EffectOut.cs new file mode 100644 index 000000000..5106ad9e3 --- /dev/null +++ b/Ryujinx.HLE/HOS/Services/Audio/AudioRendererManager/Types/EffectOut.cs @@ -0,0 +1,11 @@ +using System.Runtime.InteropServices; + +namespace Ryujinx.HLE.HOS.Services.Audio.AudioRendererManager +{ + [StructLayout(LayoutKind.Sequential, Size = 0x10, Pack = 1)] + unsafe struct EffectOut + { + public EffectState State; + public fixed byte Reserved[15]; + } +} diff --git a/Ryujinx.HLE/HOS/Services/Audio/AudioRendererManager/Types/EffectState.cs b/Ryujinx.HLE/HOS/Services/Audio/AudioRendererManager/Types/EffectState.cs new file mode 100644 index 000000000..ed6766844 --- /dev/null +++ b/Ryujinx.HLE/HOS/Services/Audio/AudioRendererManager/Types/EffectState.cs @@ -0,0 +1,8 @@ +namespace Ryujinx.HLE.HOS.Services.Audio.AudioRendererManager +{ + enum EffectState : byte + { + None = 0, + New = 1 + } +}