diff options
Diffstat (limited to 'Ryujinx.Audio/Renderer/Server')
4 files changed, 35 insertions, 8 deletions
diff --git a/Ryujinx.Audio/Renderer/Server/AudioRenderSystem.cs b/Ryujinx.Audio/Renderer/Server/AudioRenderSystem.cs index af163ae0..34fdef8a 100644 --- a/Ryujinx.Audio/Renderer/Server/AudioRenderSystem.cs +++ b/Ryujinx.Audio/Renderer/Server/AudioRenderSystem.cs @@ -28,6 +28,7 @@ namespace Ryujinx.Audio.Renderer.Server { private object _lock = new object(); + private AudioRendererRenderingDevice _renderingDevice; private AudioRendererExecutionMode _executionMode; private IWritableEvent _systemEvent; private ManualResetEvent _terminationEvent; @@ -63,6 +64,7 @@ namespace Ryujinx.Audio.Renderer.Server private uint _renderingTimeLimitPercent; private bool _voiceDropEnabled; private uint _voiceDropCount; + private float _voiceDropParameter; private bool _isDspRunningBehind; private ICommandProcessingTimeEstimator _commandProcessingTimeEstimator; @@ -95,6 +97,7 @@ namespace Ryujinx.Audio.Renderer.Server _totalElapsedTicksUpdating = 0; _sessionId = 0; + _voiceDropParameter = 1.0f; } public ResultCode Initialize( @@ -130,6 +133,7 @@ namespace Ryujinx.Audio.Renderer.Server _upsamplerCount = parameter.SinkCount + parameter.SubMixBufferCount; _appletResourceId = appletResourceId; _memoryPoolCount = parameter.EffectCount + parameter.VoiceCount * Constants.VoiceWaveBufferCount; + _renderingDevice = parameter.RenderingDevice; _executionMode = parameter.ExecutionMode; _sessionId = sessionId; MemoryManager = memoryManager; @@ -337,6 +341,7 @@ namespace Ryujinx.Audio.Renderer.Server _processHandle = processHandle; _elapsedFrameCount = 0; + _voiceDropParameter = 1.0f; switch (_behaviourContext.GetCommandProcessingTimeEstimatorVersion()) { @@ -515,7 +520,7 @@ namespace Ryujinx.Audio.Renderer.Server return (ulong)(_manager.TickSource.ElapsedSeconds * Constants.TargetTimerFrequency); } - private uint ComputeVoiceDrop(CommandBuffer commandBuffer, long voicesEstimatedTime, long deltaTimeDsp) + private uint ComputeVoiceDrop(CommandBuffer commandBuffer, uint voicesEstimatedTime, long deltaTimeDsp) { int i; @@ -584,7 +589,7 @@ namespace Ryujinx.Audio.Renderer.Server { command.Enabled = false; - voicesEstimatedTime -= (long)command.EstimatedProcessingTime; + voicesEstimatedTime -= (uint)(_voiceDropParameter * command.EstimatedProcessingTime); } } } @@ -618,13 +623,13 @@ namespace Ryujinx.Audio.Renderer.Server _voiceContext.Sort(); commandGenerator.GenerateVoices(); - long voicesEstimatedTime = (long)commandBuffer.EstimatedProcessingTime; + uint voicesEstimatedTime = (uint)(_voiceDropParameter * commandBuffer.EstimatedProcessingTime); commandGenerator.GenerateSubMixes(); commandGenerator.GenerateFinalMixes(); commandGenerator.GenerateSinks(); - long totalEstimatedTime = (long)commandBuffer.EstimatedProcessingTime; + uint totalEstimatedTime = (uint)(_voiceDropParameter * commandBuffer.EstimatedProcessingTime); if (_voiceDropEnabled) { @@ -856,5 +861,26 @@ namespace Ryujinx.Audio.Renderer.Server } } } + + public void SetVoiceDropParameter(float voiceDropParameter) + { + _voiceDropParameter = Math.Clamp(voiceDropParameter, 0.0f, 2.0f); + } + + public float GetVoiceDropParameter() + { + return _voiceDropParameter; + } + + public ResultCode ExecuteAudioRendererRendering() + { + if (_executionMode == AudioRendererExecutionMode.Manual && _renderingDevice == AudioRendererRenderingDevice.Cpu) + { + // NOTE: Here Nintendo aborts with this error code, we don't want that. + return ResultCode.InvalidExecutionContextOperation; + } + + return ResultCode.UnsupportedOperation; + } } }
\ No newline at end of file diff --git a/Ryujinx.Audio/Renderer/Server/BehaviourContext.cs b/Ryujinx.Audio/Renderer/Server/BehaviourContext.cs index 41720415..adf5294e 100644 --- a/Ryujinx.Audio/Renderer/Server/BehaviourContext.cs +++ b/Ryujinx.Audio/Renderer/Server/BehaviourContext.cs @@ -94,8 +94,9 @@ namespace Ryujinx.Audio.Renderer.Server /// REV11: /// The "legacy" effects (Delay, Reverb and Reverb 3D) were updated to match the standard channel mapping used by the audio renderer. /// A new version of the command estimator was added to address timing changes caused by the legacy effects changes. + /// A voice drop parameter was added in 15.0.0: This allows an application to amplify or attenuate the estimated time of DSP commands. /// </summary> - /// <remarks>This was added in system update 14.0.0</remarks> + /// <remarks>This was added in system update 14.0.0 but some changes were made in 15.0.0</remarks> public const int Revision11 = 11 << 24; /// <summary> diff --git a/Ryujinx.Audio/Renderer/Server/CommandBuffer.cs b/Ryujinx.Audio/Renderer/Server/CommandBuffer.cs index 3a3a981d..e0741cc6 100644 --- a/Ryujinx.Audio/Renderer/Server/CommandBuffer.cs +++ b/Ryujinx.Audio/Renderer/Server/CommandBuffer.cs @@ -25,7 +25,7 @@ namespace Ryujinx.Audio.Renderer.Server /// <summary> /// The estimated total processing time. /// </summary> - public ulong EstimatedProcessingTime { get; set; } + public uint EstimatedProcessingTime { get; set; } /// <summary> /// The command list that is populated by the <see cref="CommandBuffer"/>. diff --git a/Ryujinx.Audio/Renderer/Server/MemoryPool/PoolMapper.cs b/Ryujinx.Audio/Renderer/Server/MemoryPool/PoolMapper.cs index cf0fc067..6c79da15 100644 --- a/Ryujinx.Audio/Renderer/Server/MemoryPool/PoolMapper.cs +++ b/Ryujinx.Audio/Renderer/Server/MemoryPool/PoolMapper.cs @@ -263,12 +263,12 @@ namespace Ryujinx.Audio.Renderer.Server.MemoryPool return UpdateResult.Success; } - if (inParameter.CpuAddress == 0 || (inParameter.CpuAddress & (pageSize - 1)) != 0) + if (inParameter.CpuAddress == 0 || (inParameter.CpuAddress % pageSize) != 0) { return UpdateResult.InvalidParameter; } - if (inParameter.Size == 0 || (inParameter.Size & (pageSize - 1)) != 0) + if (inParameter.Size == 0 || (inParameter.Size % pageSize) != 0) { return UpdateResult.InvalidParameter; } |