From 8eebbc736e6a6117facb2321a5a8613f4502f92b Mon Sep 17 00:00:00 2001 From: gdkchan Date: Tue, 12 Feb 2019 14:05:05 -0300 Subject: [PATCH] Do not increment played wave buffers count for empty wave buffers (#568) * Do not increment played wave buffers count for empty wave buffers * Remove unused setter --- .../Aud/AudioRenderer/IAudioRenderer.cs | 2 +- .../Aud/AudioRenderer/VoiceContext.cs | 30 +++++++++++-------- 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/Ryujinx.HLE/HOS/Services/Aud/AudioRenderer/IAudioRenderer.cs b/Ryujinx.HLE/HOS/Services/Aud/AudioRenderer/IAudioRenderer.cs index 72839c2bff..8c98438501 100644 --- a/Ryujinx.HLE/HOS/Services/Aud/AudioRenderer/IAudioRenderer.cs +++ b/Ryujinx.HLE/HOS/Services/Aud/AudioRenderer/IAudioRenderer.cs @@ -312,7 +312,7 @@ namespace Ryujinx.HLE.HOS.Services.Aud.AudioRenderer foreach (VoiceContext voice in _voices) { - if (!voice.Playing) + if (!voice.Playing || voice.CurrentWaveBuffer.Size == 0) { continue; } diff --git a/Ryujinx.HLE/HOS/Services/Aud/AudioRenderer/VoiceContext.cs b/Ryujinx.HLE/HOS/Services/Aud/AudioRenderer/VoiceContext.cs index a877081d55..5de856122e 100644 --- a/Ryujinx.HLE/HOS/Services/Aud/AudioRenderer/VoiceContext.cs +++ b/Ryujinx.HLE/HOS/Services/Aud/AudioRenderer/VoiceContext.cs @@ -14,20 +14,24 @@ namespace Ryujinx.HLE.HOS.Services.Aud.AudioRenderer private int _bufferIndex; private int _offset; - public int SampleRate; - public int ChannelsCount; + public int SampleRate { get; set; } + public int ChannelsCount { get; set; } - public float Volume; + public float Volume { get; set; } - public PlayState PlayState; + public PlayState PlayState { get; set; } - public SampleFormat SampleFormat; + public SampleFormat SampleFormat { get; set; } - public AdpcmDecoderContext AdpcmCtx; + public AdpcmDecoderContext AdpcmCtx { get; set; } - public WaveBuffer[] WaveBuffers; + public WaveBuffer[] WaveBuffers { get; } - public VoiceOut OutStatus; + public WaveBuffer CurrentWaveBuffer => WaveBuffers[_bufferIndex]; + + private VoiceOut _outStatus; + + public VoiceOut OutStatus => _outStatus; private int[] _samples; @@ -56,9 +60,9 @@ namespace Ryujinx.HLE.HOS.Services.Aud.AudioRenderer _bufferIndex = 0; _offset = 0; - OutStatus.PlayedSamplesCount = 0; - OutStatus.PlayedWaveBuffersCount = 0; - OutStatus.VoiceDropsCount = 0; + _outStatus.PlayedSamplesCount = 0; + _outStatus.PlayedWaveBuffersCount = 0; + _outStatus.VoiceDropsCount = 0; } public int[] GetBufferData(MemoryManager memory, int maxSamples, out int samplesCount) @@ -94,7 +98,7 @@ namespace Ryujinx.HLE.HOS.Services.Aud.AudioRenderer samplesCount = size / AudioConsts.HostChannelsCount; - OutStatus.PlayedSamplesCount += samplesCount; + _outStatus.PlayedSamplesCount += samplesCount; _offset += size; @@ -107,7 +111,7 @@ namespace Ryujinx.HLE.HOS.Services.Aud.AudioRenderer SetBufferIndex((_bufferIndex + 1) & 3); } - OutStatus.PlayedWaveBuffersCount++; + _outStatus.PlayedWaveBuffersCount++; if (wb.LastBuffer != 0) {