From f556c80d0230056335632b60c71f1567e177239e Mon Sep 17 00:00:00 2001 From: Mary Date: Fri, 26 Feb 2021 01:11:56 +0100 Subject: Haydn: Part 1 (#2007) * Haydn: Part 1 Based on my reverse of audio 11.0.0. As always, core implementation under LGPLv3 for the same reasons as for Amadeus. This place the bases of a more flexible audio system while making audout & audin accurate. This have the following improvements: - Complete reimplementation of audout and audin. - Audin currently only have a dummy backend. - Dramatically reduce CPU usage by up to 50% in common cases (SoundIO and OpenAL). - Audio Renderer now can output to 5.1 devices when supported. - Audio Renderer init its backend on demand instead of keeping two up all the time. - All backends implementation are now in their own project. - Ryujinx.Audio.Renderer was renamed Ryujinx.Audio and was refactored because of this. As a note, games having issues with OpenAL haven't improved and will not because of OpenAL design (stopping when buffers finish playing causing possible audio "pops" when buffers are very small). * Update for latest hexkyz's edits on Switchbrew * audren: Rollback channel configuration changes * Address gdkchan's comments * Fix typo in OpenAL backend driver * Address last comments * Fix a nit * Address gdkchan's comments --- .../Server/Effect/AuxiliaryBufferEffect.cs | 92 -------- Ryujinx.Audio.Renderer/Server/Effect/BaseEffect.cs | 257 --------------------- .../Server/Effect/BiquadFilterEffect.cs | 74 ------ .../Server/Effect/BufferMixEffect.cs | 56 ----- .../Server/Effect/DelayEffect.cs | 100 -------- .../Server/Effect/EffectContext.cs | 82 ------- .../Server/Effect/Reverb3dEffect.cs | 99 -------- .../Server/Effect/ReverbEffect.cs | 102 -------- Ryujinx.Audio.Renderer/Server/Effect/UsageState.cs | 45 ---- 9 files changed, 907 deletions(-) delete mode 100644 Ryujinx.Audio.Renderer/Server/Effect/AuxiliaryBufferEffect.cs delete mode 100644 Ryujinx.Audio.Renderer/Server/Effect/BaseEffect.cs delete mode 100644 Ryujinx.Audio.Renderer/Server/Effect/BiquadFilterEffect.cs delete mode 100644 Ryujinx.Audio.Renderer/Server/Effect/BufferMixEffect.cs delete mode 100644 Ryujinx.Audio.Renderer/Server/Effect/DelayEffect.cs delete mode 100644 Ryujinx.Audio.Renderer/Server/Effect/EffectContext.cs delete mode 100644 Ryujinx.Audio.Renderer/Server/Effect/Reverb3dEffect.cs delete mode 100644 Ryujinx.Audio.Renderer/Server/Effect/ReverbEffect.cs delete mode 100644 Ryujinx.Audio.Renderer/Server/Effect/UsageState.cs (limited to 'Ryujinx.Audio.Renderer/Server/Effect') diff --git a/Ryujinx.Audio.Renderer/Server/Effect/AuxiliaryBufferEffect.cs b/Ryujinx.Audio.Renderer/Server/Effect/AuxiliaryBufferEffect.cs deleted file mode 100644 index df82945b..00000000 --- a/Ryujinx.Audio.Renderer/Server/Effect/AuxiliaryBufferEffect.cs +++ /dev/null @@ -1,92 +0,0 @@ -// -// Copyright (c) 2019-2021 Ryujinx -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with this program. If not, see . -// - -using Ryujinx.Audio.Renderer.Common; -using Ryujinx.Audio.Renderer.Dsp.State; -using Ryujinx.Audio.Renderer.Parameter; -using Ryujinx.Audio.Renderer.Parameter.Effect; -using Ryujinx.Audio.Renderer.Server.MemoryPool; -using System.Diagnostics; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -using DspAddress = System.UInt64; - -namespace Ryujinx.Audio.Renderer.Server.Effect -{ - /// - /// Server state for an auxiliary buffer effect. - /// - public class AuxiliaryBufferEffect : BaseEffect - { - /// - /// The auxiliary buffer parameter. - /// - public AuxiliaryBufferParameter Parameter; - - /// - /// Auxiliary buffer state. - /// - public AuxiliaryBufferAddresses State; - - public override EffectType TargetEffectType => EffectType.AuxiliaryBuffer; - - public override DspAddress GetWorkBuffer(int index) - { - return WorkBuffers[index].GetReference(true); - } - - public override void Update(out BehaviourParameter.ErrorInfo updateErrorInfo, ref EffectInParameter parameter, PoolMapper mapper) - { - Debug.Assert(IsTypeValid(ref parameter)); - - UpdateParameterBase(ref parameter); - - Parameter = MemoryMarshal.Cast(parameter.SpecificData)[0]; - IsEnabled = parameter.IsEnabled; - - updateErrorInfo = new BehaviourParameter.ErrorInfo(); - - if (BufferUnmapped || parameter.IsNew) - { - ulong bufferSize = (ulong)Unsafe.SizeOf() * Parameter.BufferStorageSize + (ulong)Unsafe.SizeOf() * 2; - - bool sendBufferUnmapped = !mapper.TryAttachBuffer(out updateErrorInfo, ref WorkBuffers[0], Parameter.SendBufferInfoAddress, bufferSize); - bool returnBufferUnmapped = !mapper.TryAttachBuffer(out updateErrorInfo, ref WorkBuffers[1], Parameter.ReturnBufferInfoAddress, bufferSize); - - BufferUnmapped = sendBufferUnmapped && returnBufferUnmapped; - - if (!BufferUnmapped) - { - DspAddress sendDspAddress = WorkBuffers[0].GetReference(false); - DspAddress returnDspAddress = WorkBuffers[1].GetReference(false); - - State.SendBufferInfo = sendDspAddress + (uint)Unsafe.SizeOf(); - State.SendBufferInfoBase = sendDspAddress + (uint)Unsafe.SizeOf() * 2; - - State.ReturnBufferInfo = returnDspAddress + (uint)Unsafe.SizeOf(); - State.ReturnBufferInfoBase = returnDspAddress + (uint)Unsafe.SizeOf() * 2; - } - } - } - - public override void UpdateForCommandGeneration() - { - UpdateUsageStateForCommandGeneration(); - } - } -} diff --git a/Ryujinx.Audio.Renderer/Server/Effect/BaseEffect.cs b/Ryujinx.Audio.Renderer/Server/Effect/BaseEffect.cs deleted file mode 100644 index 7c491fd1..00000000 --- a/Ryujinx.Audio.Renderer/Server/Effect/BaseEffect.cs +++ /dev/null @@ -1,257 +0,0 @@ -// -// Copyright (c) 2019-2021 Ryujinx -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with this program. If not, see . -// - -using Ryujinx.Audio.Renderer.Common; -using Ryujinx.Audio.Renderer.Parameter; -using Ryujinx.Audio.Renderer.Server.MemoryPool; -using Ryujinx.Audio.Renderer.Utils; -using System; -using System.Diagnostics; -using static Ryujinx.Audio.Renderer.Common.BehaviourParameter; - -using DspAddress = System.UInt64; - -namespace Ryujinx.Audio.Renderer.Server.Effect -{ - /// - /// Base class used as a server state for an effect. - /// - public class BaseEffect - { - /// - /// The of the effect. - /// - public EffectType Type; - - /// - /// Set to true if the effect must be active. - /// - public bool IsEnabled; - - /// - /// Set to true if the internal effect work buffers used wasn't mapped. - /// - public bool BufferUnmapped; - - /// - /// The current state of the effect. - /// - public UsageState UsageState; - - /// - /// The target mix id of the effect. - /// - public int MixId; - - /// - /// Position of the effect while processing effects. - /// - public uint ProcessingOrder; - - /// - /// Array of all the work buffer used by the effect. - /// - protected AddressInfo[] WorkBuffers; - - /// - /// Create a new . - /// - public BaseEffect() - { - Type = TargetEffectType; - UsageState = UsageState.Invalid; - - IsEnabled = false; - BufferUnmapped = false; - MixId = RendererConstants.UnusedMixId; - ProcessingOrder = uint.MaxValue; - - WorkBuffers = new AddressInfo[2]; - - foreach (ref AddressInfo info in WorkBuffers.AsSpan()) - { - info = AddressInfo.Create(); - } - } - - /// - /// The target handled by this . - /// - public virtual EffectType TargetEffectType => EffectType.Invalid; - - /// - /// Check if the sent by the user match the internal . - /// - /// The user parameter. - /// Returns true if the sent by the user matches the internal . - public bool IsTypeValid(ref EffectInParameter parameter) - { - return parameter.Type == TargetEffectType; - } - - /// - /// Update the usage state during command generation. - /// - protected void UpdateUsageStateForCommandGeneration() - { - UsageState = IsEnabled ? UsageState.Enabled : UsageState.Disabled; - } - - /// - /// Update the internal common parameters from a user parameter. - /// - /// The user parameter. - protected void UpdateParameterBase(ref EffectInParameter parameter) - { - MixId = parameter.MixId; - ProcessingOrder = parameter.ProcessingOrder; - } - - /// - /// Force unmap all the work buffers. - /// - /// The mapper to use. - public void ForceUnmapBuffers(PoolMapper mapper) - { - foreach (ref AddressInfo info in WorkBuffers.AsSpan()) - { - if (info.GetReference(false) != 0) - { - mapper.ForceUnmap(ref info); - } - } - } - - /// - /// Check if the effect needs to be skipped. - /// - /// Returns true if the effect needs to be skipped. - public bool ShouldSkip() - { - return BufferUnmapped; - } - - /// - /// Update the state during command generation. - /// - public virtual void UpdateForCommandGeneration() - { - Debug.Assert(Type == TargetEffectType); - } - - /// - /// Update the internal state from a user parameter. - /// - /// The possible that was generated. - /// The user parameter. - /// The mapper to use. - public virtual void Update(out ErrorInfo updateErrorInfo, ref EffectInParameter parameter, PoolMapper mapper) - { - Debug.Assert(IsTypeValid(ref parameter)); - - updateErrorInfo = new ErrorInfo(); - } - - /// - /// Get the work buffer DSP address at the given index. - /// - /// The index of the work buffer - /// The work buffer DSP address at the given index. - public virtual DspAddress GetWorkBuffer(int index) - { - throw new InvalidOperationException(); - } - - /// - /// Get the first work buffer DSP address. - /// - /// The first work buffer DSP address. - protected DspAddress GetSingleBuffer() - { - if (IsEnabled) - { - return WorkBuffers[0].GetReference(true); - } - - if (UsageState != UsageState.Disabled) - { - DspAddress address = WorkBuffers[0].GetReference(false); - ulong size = WorkBuffers[0].Size; - - if (address != 0 && size != 0) - { - AudioProcessorMemoryManager.InvalidateDataCache(address, size); - } - } - - return 0; - } - - /// - /// Store the output status to the given user output. - /// - /// The given user output. - /// If set to true, the is active. - public void StoreStatus(ref EffectOutStatus outStatus, bool isAudioRendererActive) - { - if (isAudioRendererActive) - { - if (UsageState == UsageState.Disabled) - { - outStatus.State = EffectOutStatus.EffectState.Disabled; - } - else - { - outStatus.State = EffectOutStatus.EffectState.Enabled; - } - } - else if (UsageState == UsageState.New) - { - outStatus.State = EffectOutStatus.EffectState.Enabled; - } - else - { - outStatus.State = EffectOutStatus.EffectState.Disabled; - } - } - - /// - /// Get the associated to the of this effect. - /// - /// The associated to the of this effect. - public PerformanceDetailType GetPerformanceDetailType() - { - switch (Type) - { - case EffectType.BiquadFilter: - return PerformanceDetailType.BiquadFilter; - case EffectType.AuxiliaryBuffer: - return PerformanceDetailType.Aux; - case EffectType.Delay: - return PerformanceDetailType.Delay; - case EffectType.Reverb: - return PerformanceDetailType.Reverb; - case EffectType.Reverb3d: - return PerformanceDetailType.Reverb3d; - case EffectType.BufferMix: - return PerformanceDetailType.Mix; - default: - throw new NotImplementedException($"{Type}"); - } - } - } -} diff --git a/Ryujinx.Audio.Renderer/Server/Effect/BiquadFilterEffect.cs b/Ryujinx.Audio.Renderer/Server/Effect/BiquadFilterEffect.cs deleted file mode 100644 index aadf2844..00000000 --- a/Ryujinx.Audio.Renderer/Server/Effect/BiquadFilterEffect.cs +++ /dev/null @@ -1,74 +0,0 @@ -// -// Copyright (c) 2019-2021 Ryujinx -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with this program. If not, see . -// - -using Ryujinx.Audio.Renderer.Common; -using Ryujinx.Audio.Renderer.Dsp.State; -using Ryujinx.Audio.Renderer.Parameter; -using Ryujinx.Audio.Renderer.Parameter.Effect; -using Ryujinx.Audio.Renderer.Server.MemoryPool; -using System; -using System.Diagnostics; -using System.Runtime.InteropServices; - -namespace Ryujinx.Audio.Renderer.Server.Effect -{ - /// - /// Server state for a biquad filter effect. - /// - public class BiquadFilterEffect : BaseEffect - { - /// - /// The biquad filter parameter. - /// - public BiquadFilterEffectParameter Parameter; - - /// - /// The biquad filter state. - /// - public Memory State { get; } - - /// - /// Create a new . - /// - public BiquadFilterEffect() - { - Parameter = new BiquadFilterEffectParameter(); - State = new BiquadFilterState[RendererConstants.ChannelCountMax]; - } - - public override EffectType TargetEffectType => EffectType.BiquadFilter; - - public override void Update(out BehaviourParameter.ErrorInfo updateErrorInfo, ref EffectInParameter parameter, PoolMapper mapper) - { - Debug.Assert(IsTypeValid(ref parameter)); - - UpdateParameterBase(ref parameter); - - Parameter = MemoryMarshal.Cast(parameter.SpecificData)[0]; - IsEnabled = parameter.IsEnabled; - - updateErrorInfo = new BehaviourParameter.ErrorInfo(); - } - - public override void UpdateForCommandGeneration() - { - UpdateUsageStateForCommandGeneration(); - - Parameter.Status = UsageState.Enabled; - } - } -} diff --git a/Ryujinx.Audio.Renderer/Server/Effect/BufferMixEffect.cs b/Ryujinx.Audio.Renderer/Server/Effect/BufferMixEffect.cs deleted file mode 100644 index 14ed3950..00000000 --- a/Ryujinx.Audio.Renderer/Server/Effect/BufferMixEffect.cs +++ /dev/null @@ -1,56 +0,0 @@ -// -// Copyright (c) 2019-2021 Ryujinx -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with this program. If not, see . -// - -using Ryujinx.Audio.Renderer.Common; -using Ryujinx.Audio.Renderer.Parameter; -using Ryujinx.Audio.Renderer.Parameter.Effect; -using Ryujinx.Audio.Renderer.Server.MemoryPool; -using System.Diagnostics; -using System.Runtime.InteropServices; - -namespace Ryujinx.Audio.Renderer.Server.Effect -{ - /// - /// Server state for a buffer mix effect. - /// - public class BufferMixEffect : BaseEffect - { - /// - /// The buffer mix parameter. - /// - public BufferMixParameter Parameter; - - public override EffectType TargetEffectType => EffectType.BufferMix; - - public override void Update(out BehaviourParameter.ErrorInfo updateErrorInfo, ref EffectInParameter parameter, PoolMapper mapper) - { - Debug.Assert(IsTypeValid(ref parameter)); - - UpdateParameterBase(ref parameter); - - Parameter = MemoryMarshal.Cast(parameter.SpecificData)[0]; - IsEnabled = parameter.IsEnabled; - - updateErrorInfo = new BehaviourParameter.ErrorInfo(); - } - - public override void UpdateForCommandGeneration() - { - UpdateUsageStateForCommandGeneration(); - } - } -} diff --git a/Ryujinx.Audio.Renderer/Server/Effect/DelayEffect.cs b/Ryujinx.Audio.Renderer/Server/Effect/DelayEffect.cs deleted file mode 100644 index df3e5ee7..00000000 --- a/Ryujinx.Audio.Renderer/Server/Effect/DelayEffect.cs +++ /dev/null @@ -1,100 +0,0 @@ -// -// Copyright (c) 2019-2021 Ryujinx -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with this program. If not, see . -// - -using Ryujinx.Audio.Renderer.Common; -using Ryujinx.Audio.Renderer.Dsp.State; -using Ryujinx.Audio.Renderer.Parameter; -using Ryujinx.Audio.Renderer.Parameter.Effect; -using Ryujinx.Audio.Renderer.Server.MemoryPool; -using System; -using System.Diagnostics; -using System.Runtime.InteropServices; -using DspAddress = System.UInt64; - -namespace Ryujinx.Audio.Renderer.Server.Effect -{ - /// - /// Server state for a delay effect. - /// - public class DelayEffect : BaseEffect - { - /// - /// The delay parameter. - /// - public DelayParameter Parameter; - - /// - /// The delay state. - /// - public Memory State { get; } - - public DelayEffect() - { - State = new DelayState[1]; - } - - public override EffectType TargetEffectType => EffectType.Delay; - - public override DspAddress GetWorkBuffer(int index) - { - return GetSingleBuffer(); - } - - public override void Update(out BehaviourParameter.ErrorInfo updateErrorInfo, ref EffectInParameter parameter, PoolMapper mapper) - { - Debug.Assert(IsTypeValid(ref parameter)); - - ref DelayParameter delayParameter = ref MemoryMarshal.Cast(parameter.SpecificData)[0]; - - updateErrorInfo = new BehaviourParameter.ErrorInfo(); - - if (delayParameter.IsChannelCountMaxValid()) - { - UpdateParameterBase(ref parameter); - - UsageState oldParameterStatus = Parameter.Status; - - Parameter = delayParameter; - - if (delayParameter.IsChannelCountValid()) - { - IsEnabled = parameter.IsEnabled; - - if (oldParameterStatus != UsageState.Enabled) - { - Parameter.Status = oldParameterStatus; - } - - if (BufferUnmapped || parameter.IsNew) - { - UsageState = UsageState.New; - Parameter.Status = UsageState.Invalid; - - BufferUnmapped = !mapper.TryAttachBuffer(out updateErrorInfo, ref WorkBuffers[0], parameter.BufferBase, parameter.BufferSize); - } - } - } - } - - public override void UpdateForCommandGeneration() - { - UpdateUsageStateForCommandGeneration(); - - Parameter.Status = UsageState.Enabled; - } - } -} diff --git a/Ryujinx.Audio.Renderer/Server/Effect/EffectContext.cs b/Ryujinx.Audio.Renderer/Server/Effect/EffectContext.cs deleted file mode 100644 index ff6051ae..00000000 --- a/Ryujinx.Audio.Renderer/Server/Effect/EffectContext.cs +++ /dev/null @@ -1,82 +0,0 @@ -// -// Copyright (c) 2019-2021 Ryujinx -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with this program. If not, see . -// - -using System.Diagnostics; - -namespace Ryujinx.Audio.Renderer.Server.Effect -{ - /// - /// Effect context. - /// - public class EffectContext - { - /// - /// Storage for . - /// - private BaseEffect[] _effects; - - /// - /// The total effect count. - /// - private uint _effectCount; - - /// - /// Create a new . - /// - public EffectContext() - { - _effects = null; - _effectCount = 0; - } - - /// - /// Initialize the . - /// - /// The total effect count. - public void Initialize(uint effectCount) - { - _effectCount = effectCount; - _effects = new BaseEffect[effectCount]; - - for (int i = 0; i < _effectCount; i++) - { - _effects[i] = new BaseEffect(); - } - } - - /// - /// Get the total effect count. - /// - /// The total effect count. - public uint GetCount() - { - return _effectCount; - } - - /// - /// Get a reference to a at the given . - /// - /// The index to use. - /// A reference to a at the given . - public ref BaseEffect GetEffect(int index) - { - Debug.Assert(index >= 0 && index < _effectCount); - - return ref _effects[index]; - } - } -} diff --git a/Ryujinx.Audio.Renderer/Server/Effect/Reverb3dEffect.cs b/Ryujinx.Audio.Renderer/Server/Effect/Reverb3dEffect.cs deleted file mode 100644 index d9f23799..00000000 --- a/Ryujinx.Audio.Renderer/Server/Effect/Reverb3dEffect.cs +++ /dev/null @@ -1,99 +0,0 @@ -// -// Copyright (c) 2019-2021 Ryujinx -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with this program. If not, see . -// - -using Ryujinx.Audio.Renderer.Common; -using Ryujinx.Audio.Renderer.Dsp.State; -using Ryujinx.Audio.Renderer.Parameter; -using Ryujinx.Audio.Renderer.Parameter.Effect; -using Ryujinx.Audio.Renderer.Server.MemoryPool; -using System; -using System.Diagnostics; -using System.Runtime.InteropServices; - -namespace Ryujinx.Audio.Renderer.Server.Effect -{ - /// - /// Server state for a 3D reverberation effect. - /// - public class Reverb3dEffect : BaseEffect - { - /// - /// The 3D reverberation parameter. - /// - public Reverb3dParameter Parameter; - - /// - /// The 3D reverberation state. - /// - public Memory State { get; } - - public Reverb3dEffect() - { - State = new Reverb3dState[1]; - } - - public override EffectType TargetEffectType => EffectType.Reverb3d; - - public override ulong GetWorkBuffer(int index) - { - return GetSingleBuffer(); - } - - public override void Update(out BehaviourParameter.ErrorInfo updateErrorInfo, ref EffectInParameter parameter, PoolMapper mapper) - { - Debug.Assert(IsTypeValid(ref parameter)); - - ref Reverb3dParameter reverbParameter = ref MemoryMarshal.Cast(parameter.SpecificData)[0]; - - updateErrorInfo = new BehaviourParameter.ErrorInfo(); - - if (reverbParameter.IsChannelCountMaxValid()) - { - UpdateParameterBase(ref parameter); - - UsageState oldParameterStatus = Parameter.ParameterStatus; - - Parameter = reverbParameter; - - if (reverbParameter.IsChannelCountValid()) - { - IsEnabled = parameter.IsEnabled; - - if (oldParameterStatus != UsageState.Enabled) - { - Parameter.ParameterStatus = oldParameterStatus; - } - - if (BufferUnmapped || parameter.IsNew) - { - UsageState = UsageState.New; - Parameter.ParameterStatus = UsageState.Invalid; - - BufferUnmapped = !mapper.TryAttachBuffer(out updateErrorInfo, ref WorkBuffers[0], parameter.BufferBase, parameter.BufferSize); - } - } - } - } - - public override void UpdateForCommandGeneration() - { - UpdateUsageStateForCommandGeneration(); - - Parameter.ParameterStatus = UsageState.Enabled; - } - } -} diff --git a/Ryujinx.Audio.Renderer/Server/Effect/ReverbEffect.cs b/Ryujinx.Audio.Renderer/Server/Effect/ReverbEffect.cs deleted file mode 100644 index 4c81f729..00000000 --- a/Ryujinx.Audio.Renderer/Server/Effect/ReverbEffect.cs +++ /dev/null @@ -1,102 +0,0 @@ -// -// Copyright (c) 2019-2021 Ryujinx -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with this program. If not, see . -// - -using Ryujinx.Audio.Renderer.Common; -using Ryujinx.Audio.Renderer.Dsp.State; -using Ryujinx.Audio.Renderer.Parameter; -using Ryujinx.Audio.Renderer.Parameter.Effect; -using Ryujinx.Audio.Renderer.Server.MemoryPool; -using System; -using System.Diagnostics; -using System.Runtime.InteropServices; - -namespace Ryujinx.Audio.Renderer.Server.Effect -{ - /// - /// Server state for a reverberation effect. - /// - public class ReverbEffect : BaseEffect - { - /// - /// The reverberation parameter. - /// - public ReverbParameter Parameter; - - /// - /// The reverberation state. - /// - public Memory State { get; } - - /// - /// Create a new . - /// - public ReverbEffect() - { - State = new ReverbState[1]; - } - - public override EffectType TargetEffectType => EffectType.Reverb; - - public override ulong GetWorkBuffer(int index) - { - return GetSingleBuffer(); - } - - public override void Update(out BehaviourParameter.ErrorInfo updateErrorInfo, ref EffectInParameter parameter, PoolMapper mapper) - { - Debug.Assert(IsTypeValid(ref parameter)); - - ref ReverbParameter reverbParameter = ref MemoryMarshal.Cast(parameter.SpecificData)[0]; - - updateErrorInfo = new BehaviourParameter.ErrorInfo(); - - if (reverbParameter.IsChannelCountMaxValid()) - { - UpdateParameterBase(ref parameter); - - UsageState oldParameterStatus = Parameter.Status; - - Parameter = reverbParameter; - - if (reverbParameter.IsChannelCountValid()) - { - IsEnabled = parameter.IsEnabled; - - if (oldParameterStatus != UsageState.Enabled) - { - Parameter.Status = oldParameterStatus; - } - - if (BufferUnmapped || parameter.IsNew) - { - UsageState = UsageState.New; - Parameter.Status = UsageState.Invalid; - - BufferUnmapped = !mapper.TryAttachBuffer(out updateErrorInfo, ref WorkBuffers[0], parameter.BufferBase, parameter.BufferSize); - } - } - } - } - - public override void UpdateForCommandGeneration() - { - UpdateUsageStateForCommandGeneration(); - - Parameter.Status = UsageState.Enabled; - } - } -} diff --git a/Ryujinx.Audio.Renderer/Server/Effect/UsageState.cs b/Ryujinx.Audio.Renderer/Server/Effect/UsageState.cs deleted file mode 100644 index a519acd4..00000000 --- a/Ryujinx.Audio.Renderer/Server/Effect/UsageState.cs +++ /dev/null @@ -1,45 +0,0 @@ -// -// Copyright (c) 2019-2021 Ryujinx -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with this program. If not, see . -// - -namespace Ryujinx.Audio.Renderer.Server.Effect -{ - /// - /// The usage state of an effect. - /// - public enum UsageState : byte - { - /// - /// The effect is in an invalid state. - /// - Invalid, - - /// - /// The effect is new. - /// - New, - - /// - /// The effect is enabled. - /// - Enabled, - - /// - /// The effect is disabled. - /// - Disabled - } -} -- cgit v1.2.3