Amadeus: Final Act (#1481)

* Amadeus: Final Act

This is my requiem, I present to you Amadeus, a complete reimplementation of the Audio Renderer!

This reimplementation is based on my reversing of every version of the audio system module that I carried for the past 10 months.
This supports every revision (at the time of writing REV1 to REV8 included) and all features proposed by the Audio Renderer on real hardware.

Because this component could be used outside an emulation context, and to avoid possible "inspirations" not crediting the project, I decided to license the Ryujinx.Audio.Renderer project under LGPLv3.

- FE3H voices in videos and chapter intro are not present.
- Games that use two audio renderer **at the same time** are probably going to have issues right now **until we rewrite the audio output interface** (Crash Team Racing is the only known game to use two renderer at the same time).

- Persona 5 Scrambler now goes ingame but audio is garbage. This is caused by the fact that the game engine is syncing audio and video in a really aggressive way. This will disappears the day this game run at full speed.

* Make timing more precise when sleeping on Windows

Improve precision to a 1ms resolution on Windows NT based OS.
This is used to avoid having totally erratic timings and unify all
Windows users to the same resolution.

NOTE: This is only active when emulation is running.
This commit is contained in:
Mary
2020-08-18 03:49:37 +02:00
committed by GitHub
parent 2a314f3c28
commit a389dd59bd
250 changed files with 23691 additions and 1512 deletions

View File

@ -0,0 +1,15 @@
using NUnit.Framework;
using Ryujinx.Audio.Renderer.Parameter;
using System.Runtime.CompilerServices;
namespace Ryujinx.Tests.Audio.Renderer
{
class AudioRendererConfigurationTests
{
[Test]
public void EnsureTypeSize()
{
Assert.AreEqual(0x34, Unsafe.SizeOf<AudioRendererConfiguration>());
}
}
}

View File

@ -0,0 +1,16 @@
using NUnit.Framework;
using Ryujinx.Audio.Renderer.Common;
using System.Runtime.CompilerServices;
namespace Ryujinx.Tests.Audio.Renderer
{
class BehaviourParameterTests
{
[Test]
public void EnsureTypeSize()
{
Assert.AreEqual(0x10, Unsafe.SizeOf<BehaviourParameter>());
Assert.AreEqual(0x10, Unsafe.SizeOf<BehaviourParameter.ErrorInfo>());
}
}
}

View File

@ -0,0 +1,15 @@
using NUnit.Framework;
using Ryujinx.Audio.Renderer.Parameter;
using System.Runtime.CompilerServices;
namespace Ryujinx.Tests.Audio.Renderer
{
class BiquadFilterParameterTests
{
[Test]
public void EnsureTypeSize()
{
Assert.AreEqual(0xC, Unsafe.SizeOf<BiquadFilterParameter>());
}
}
}

View File

@ -0,0 +1,15 @@
using NUnit.Framework;
using Ryujinx.Audio.Renderer.Common;
using System.Runtime.CompilerServices;
namespace Ryujinx.Tests.Audio.Renderer.Common
{
class UpdateDataHeaderTests
{
[Test]
public void EnsureTypeSize()
{
Assert.AreEqual(0x40, Unsafe.SizeOf<UpdateDataHeader>());
}
}
}

View File

@ -0,0 +1,15 @@
using NUnit.Framework;
using Ryujinx.Audio.Renderer.Common;
using System.Runtime.CompilerServices;
namespace Ryujinx.Tests.Audio.Renderer.Common
{
class VoiceUpdateStateTests
{
[Test]
public void EnsureTypeSize()
{
Assert.LessOrEqual(Unsafe.SizeOf<VoiceUpdateState>(), 0x100);
}
}
}

View File

@ -0,0 +1,15 @@
using NUnit.Framework;
using Ryujinx.Audio.Renderer.Common;
using System.Runtime.CompilerServices;
namespace Ryujinx.Tests.Audio.Renderer.Common
{
class WaveBufferTests
{
[Test]
public void EnsureTypeSize()
{
Assert.AreEqual(0x30, Unsafe.SizeOf<WaveBuffer>());
}
}
}

View File

@ -0,0 +1,15 @@
using NUnit.Framework;
using Ryujinx.Audio.Renderer.Parameter;
using System.Runtime.CompilerServices;
namespace Ryujinx.Tests.Audio.Renderer
{
class EffectInfoParameterTests
{
[Test]
public void EnsureTypeSize()
{
Assert.AreEqual(0xC0, Unsafe.SizeOf<EffectInParameter>());
}
}
}

View File

@ -0,0 +1,15 @@
using NUnit.Framework;
using Ryujinx.Audio.Renderer.Parameter;
using System.Runtime.CompilerServices;
namespace Ryujinx.Tests.Audio.Renderer
{
class EffectOutStatusTests
{
[Test]
public void EnsureTypeSize()
{
Assert.AreEqual(0x10, Unsafe.SizeOf<EffectOutStatus>());
}
}
}

View File

@ -0,0 +1,16 @@
using NUnit.Framework;
using Ryujinx.Audio.Renderer.Parameter;
using System.Runtime.CompilerServices;
namespace Ryujinx.Tests.Audio.Renderer
{
class MemoryPoolParameterTests
{
[Test]
public void EnsureTypeSize()
{
Assert.AreEqual(0x20, Unsafe.SizeOf<MemoryPoolInParameter>());
Assert.AreEqual(0x10, Unsafe.SizeOf<MemoryPoolOutStatus>());
}
}
}

View File

@ -0,0 +1,15 @@
using NUnit.Framework;
using Ryujinx.Audio.Renderer.Parameter;
using System.Runtime.CompilerServices;
namespace Ryujinx.Tests.Audio.Renderer.Parameter
{
class BehaviourErrorInfoOutStatusTests
{
[Test]
public void EnsureTypeSize()
{
Assert.AreEqual(0xB0, Unsafe.SizeOf<BehaviourErrorInfoOutStatus>());
}
}
}

View File

@ -0,0 +1,15 @@
using NUnit.Framework;
using Ryujinx.Audio.Renderer.Parameter.Effect;
using System.Runtime.CompilerServices;
namespace Ryujinx.Tests.Audio.Renderer.Parameter.Effect
{
class AuxParameterTests
{
[Test]
public void EnsureTypeSize()
{
Assert.AreEqual(0x6C, Unsafe.SizeOf<AuxiliaryBufferParameter>());
}
}
}

View File

@ -0,0 +1,15 @@
using NUnit.Framework;
using Ryujinx.Audio.Renderer.Parameter.Effect;
using System.Runtime.CompilerServices;
namespace Ryujinx.Tests.Audio.Renderer.Parameter.Effect
{
class BiquadFilterEffectParameterTests
{
[Test]
public void EnsureTypeSize()
{
Assert.AreEqual(0x18, Unsafe.SizeOf<BiquadFilterEffectParameter>());
}
}
}

View File

@ -0,0 +1,15 @@
using NUnit.Framework;
using Ryujinx.Audio.Renderer.Parameter.Effect;
using System.Runtime.CompilerServices;
namespace Ryujinx.Tests.Audio.Renderer.Parameter.Effect
{
class BufferMixerParameterTests
{
[Test]
public void EnsureTypeSize()
{
Assert.AreEqual(0x94, Unsafe.SizeOf<BufferMixParameter>());
}
}
}

View File

@ -0,0 +1,15 @@
using NUnit.Framework;
using Ryujinx.Audio.Renderer.Parameter.Effect;
using System.Runtime.CompilerServices;
namespace Ryujinx.Tests.Audio.Renderer.Parameter.Effect
{
class DelayParameterTests
{
[Test]
public void EnsureTypeSize()
{
Assert.AreEqual(0x35, Unsafe.SizeOf<DelayParameter>());
}
}
}

View File

@ -0,0 +1,15 @@
using NUnit.Framework;
using Ryujinx.Audio.Renderer.Parameter.Effect;
using System.Runtime.CompilerServices;
namespace Ryujinx.Tests.Audio.Renderer.Parameter.Effect
{
class Reverb3dParameterTests
{
[Test]
public void EnsureTypeSize()
{
Assert.AreEqual(0x49, Unsafe.SizeOf<Reverb3dParameter>());
}
}
}

View File

@ -0,0 +1,15 @@
using NUnit.Framework;
using Ryujinx.Audio.Renderer.Parameter.Effect;
using System.Runtime.CompilerServices;
namespace Ryujinx.Tests.Audio.Renderer.Parameter.Effect
{
class ReverbParameterTests
{
[Test]
public void EnsureTypeSize()
{
Assert.AreEqual(0x41, Unsafe.SizeOf<ReverbParameter>());
}
}
}

View File

@ -0,0 +1,15 @@
using NUnit.Framework;
using Ryujinx.Audio.Renderer.Parameter;
using System.Runtime.CompilerServices;
namespace Ryujinx.Tests.Audio.Renderer.Parameter
{
class MixInParameterDirtyOnlyUpdateTests
{
[Test]
public void EnsureTypeSize()
{
Assert.AreEqual(0x20, Unsafe.SizeOf<MixInParameterDirtyOnlyUpdate>());
}
}
}

View File

@ -0,0 +1,15 @@
using NUnit.Framework;
using Ryujinx.Audio.Renderer.Parameter;
using System.Runtime.CompilerServices;
namespace Ryujinx.Tests.Audio.Renderer.Parameter
{
class MixParameterTests
{
[Test]
public void EnsureTypeSize()
{
Assert.AreEqual(0x930, Unsafe.SizeOf<MixParameter>());
}
}
}

View File

@ -0,0 +1,15 @@
using NUnit.Framework;
using Ryujinx.Audio.Renderer.Parameter.Performance;
using System.Runtime.CompilerServices;
namespace Ryujinx.Tests.Audio.Renderer.Parameter
{
class PerformanceInParameterTests
{
[Test]
public void EnsureTypeSize()
{
Assert.AreEqual(0x10, Unsafe.SizeOf<PerformanceInParameter>());
}
}
}

View File

@ -0,0 +1,15 @@
using NUnit.Framework;
using Ryujinx.Audio.Renderer.Parameter.Performance;
using System.Runtime.CompilerServices;
namespace Ryujinx.Tests.Audio.Renderer.Parameter
{
class PerformanceOutStatusTests
{
[Test]
public void EnsureTypeSize()
{
Assert.AreEqual(0x10, Unsafe.SizeOf<PerformanceOutStatus>());
}
}
}

View File

@ -0,0 +1,15 @@
using NUnit.Framework;
using Ryujinx.Audio.Renderer.Parameter;
using System.Runtime.CompilerServices;
namespace Ryujinx.Tests.Audio.Renderer.Parameter
{
class RendererInfoOutStatusTests
{
[Test]
public void EnsureTypeSize()
{
Assert.AreEqual(0x10, Unsafe.SizeOf<RendererInfoOutStatus>());
}
}
}

View File

@ -0,0 +1,15 @@
using NUnit.Framework;
using Ryujinx.Audio.Renderer.Parameter.Sink;
using System.Runtime.CompilerServices;
namespace Ryujinx.Tests.Audio.Renderer.Parameter.Sink
{
class CircularBufferParameterTests
{
[Test]
public void EnsureTypeSize()
{
Assert.AreEqual(0x24, Unsafe.SizeOf<CircularBufferParameter>());
}
}
}

View File

@ -0,0 +1,15 @@
using NUnit.Framework;
using Ryujinx.Audio.Renderer.Parameter.Sink;
using System.Runtime.CompilerServices;
namespace Ryujinx.Tests.Audio.Renderer.Parameter.Sink
{
class DeviceParameterTests
{
[Test]
public void EnsureTypeSize()
{
Assert.AreEqual(0x11C, Unsafe.SizeOf<DeviceParameter>());
}
}
}

View File

@ -0,0 +1,15 @@
using NUnit.Framework;
using Ryujinx.Audio.Renderer.Parameter;
using System.Runtime.CompilerServices;
namespace Ryujinx.Tests.Audio.Renderer.Parameter
{
class SinkInParameterTests
{
[Test]
public void EnsureTypeSize()
{
Assert.AreEqual(0x140, Unsafe.SizeOf<SinkInParameter>());
}
}
}

View File

@ -0,0 +1,15 @@
using NUnit.Framework;
using Ryujinx.Audio.Renderer.Parameter;
using System.Runtime.CompilerServices;
namespace Ryujinx.Tests.Audio.Renderer.Parameter
{
class SinkOutStatusTests
{
[Test]
public void EnsureTypeSize()
{
Assert.AreEqual(0x20, Unsafe.SizeOf<SinkOutStatus>());
}
}
}

View File

@ -0,0 +1,15 @@
using NUnit.Framework;
using Ryujinx.Audio.Renderer.Parameter;
using System.Runtime.CompilerServices;
namespace Ryujinx.Tests.Audio.Renderer.Parameter
{
class SplitterInParamHeaderTests
{
[Test]
public void EnsureTypeSize()
{
Assert.AreEqual(0x20, Unsafe.SizeOf<SplitterInParameterHeader>());
}
}
}

View File

@ -0,0 +1,35 @@
using NUnit.Framework;
using Ryujinx.Audio.Renderer.Server.MemoryPool;
using System;
using System.Runtime.CompilerServices;
namespace Ryujinx.Tests.Audio.Renderer.Server
{
class AddressInfoTests
{
[Test]
public void EnsureTypeSize()
{
Assert.AreEqual(0x20, Unsafe.SizeOf<AddressInfo>());
}
[Test]
public void TestGetReference()
{
MemoryPoolState[] memoryPoolState = new MemoryPoolState[1];
memoryPoolState[0] = MemoryPoolState.Create(MemoryPoolState.LocationType.Cpu);
memoryPoolState[0].SetCpuAddress(0x1000000, 0x10000);
memoryPoolState[0].DspAddress = 0x4000000;
AddressInfo addressInfo = AddressInfo.Create(0x1000000, 0x1000);
addressInfo.ForceMappedDspAddress = 0x2000000;
Assert.AreEqual(0x2000000, addressInfo.GetReference(true));
addressInfo.SetupMemoryPool(memoryPoolState.AsSpan());
Assert.AreEqual(0x4000000, addressInfo.GetReference(true));
}
}
}

View File

@ -0,0 +1,228 @@
using NUnit.Framework;
using Ryujinx.Audio.Renderer.Server;
namespace Ryujinx.Tests.Audio.Renderer.Server
{
public class BehaviourContextTests
{
[Test]
public void TestCheckFeature()
{
int latestRevision = BehaviourContext.BaseRevisionMagic + BehaviourContext.LastRevision;
int previousRevision = BehaviourContext.BaseRevisionMagic + (BehaviourContext.LastRevision - 1);
int invalidRevision = BehaviourContext.BaseRevisionMagic + (BehaviourContext.LastRevision + 1);
Assert.IsTrue(BehaviourContext.CheckFeatureSupported(latestRevision, latestRevision));
Assert.IsFalse(BehaviourContext.CheckFeatureSupported(previousRevision, latestRevision));
Assert.IsTrue(BehaviourContext.CheckFeatureSupported(latestRevision, previousRevision));
// In case we get an invalid revision, this is supposed to auto default to REV1 internally.. idk what the hell Nintendo was thinking here..
Assert.IsTrue(BehaviourContext.CheckFeatureSupported(invalidRevision, latestRevision));
}
[Test]
public void TestsMemoryPoolForceMappingEnabled()
{
BehaviourContext behaviourContext = new BehaviourContext();
behaviourContext.SetUserRevision(BehaviourContext.BaseRevisionMagic + BehaviourContext.Revision1);
Assert.IsFalse(behaviourContext.IsMemoryPoolForceMappingEnabled());
behaviourContext.UpdateFlags(0x1);
Assert.IsTrue(behaviourContext.IsMemoryPoolForceMappingEnabled());
}
[Test]
public void TestRevision1()
{
BehaviourContext behaviourContext = new BehaviourContext();
behaviourContext.SetUserRevision(BehaviourContext.BaseRevisionMagic + BehaviourContext.Revision1);
Assert.IsFalse(behaviourContext.IsAdpcmLoopContextBugFixed());
Assert.IsFalse(behaviourContext.IsSplitterSupported());
Assert.IsFalse(behaviourContext.IsLongSizePreDelaySupported());
Assert.IsFalse(behaviourContext.IsAudioUsbDeviceOutputSupported());
Assert.IsFalse(behaviourContext.IsFlushVoiceWaveBuffersSupported());
Assert.IsFalse(behaviourContext.IsSplitterBugFixed());
Assert.IsFalse(behaviourContext.IsElapsedFrameCountSupported());
Assert.IsFalse(behaviourContext.IsDecodingBehaviourFlagSupported());
Assert.IsFalse(behaviourContext.IsBiquadFilterEffectStateClearBugFixed());
Assert.IsFalse(behaviourContext.IsMixInParameterDirtyOnlyUpdateSupported());
Assert.IsFalse(behaviourContext.IsWaveBufferVersion2Supported());
Assert.AreEqual(0.70f, behaviourContext.GetAudioRendererProcessingTimeLimit());
Assert.AreEqual(1, behaviourContext.GetCommandProcessingTimeEstimatorVersion());
Assert.AreEqual(1, behaviourContext.GetPerformanceMetricsDataFormat());
}
[Test]
public void TestRevision2()
{
BehaviourContext behaviourContext = new BehaviourContext();
behaviourContext.SetUserRevision(BehaviourContext.BaseRevisionMagic + BehaviourContext.Revision2);
Assert.IsTrue(behaviourContext.IsAdpcmLoopContextBugFixed());
Assert.IsTrue(behaviourContext.IsSplitterSupported());
Assert.IsFalse(behaviourContext.IsLongSizePreDelaySupported());
Assert.IsFalse(behaviourContext.IsAudioUsbDeviceOutputSupported());
Assert.IsFalse(behaviourContext.IsFlushVoiceWaveBuffersSupported());
Assert.IsFalse(behaviourContext.IsSplitterBugFixed());
Assert.IsFalse(behaviourContext.IsElapsedFrameCountSupported());
Assert.IsFalse(behaviourContext.IsDecodingBehaviourFlagSupported());
Assert.IsFalse(behaviourContext.IsBiquadFilterEffectStateClearBugFixed());
Assert.IsFalse(behaviourContext.IsMixInParameterDirtyOnlyUpdateSupported());
Assert.IsFalse(behaviourContext.IsWaveBufferVersion2Supported());
Assert.AreEqual(0.70f, behaviourContext.GetAudioRendererProcessingTimeLimit());
Assert.AreEqual(1, behaviourContext.GetCommandProcessingTimeEstimatorVersion());
Assert.AreEqual(1, behaviourContext.GetPerformanceMetricsDataFormat());
}
[Test]
public void TestRevision3()
{
BehaviourContext behaviourContext = new BehaviourContext();
behaviourContext.SetUserRevision(BehaviourContext.BaseRevisionMagic + BehaviourContext.Revision3);
Assert.IsTrue(behaviourContext.IsAdpcmLoopContextBugFixed());
Assert.IsTrue(behaviourContext.IsSplitterSupported());
Assert.IsTrue(behaviourContext.IsLongSizePreDelaySupported());
Assert.IsFalse(behaviourContext.IsAudioUsbDeviceOutputSupported());
Assert.IsFalse(behaviourContext.IsFlushVoiceWaveBuffersSupported());
Assert.IsFalse(behaviourContext.IsSplitterBugFixed());
Assert.IsFalse(behaviourContext.IsElapsedFrameCountSupported());
Assert.IsFalse(behaviourContext.IsDecodingBehaviourFlagSupported());
Assert.IsFalse(behaviourContext.IsBiquadFilterEffectStateClearBugFixed());
Assert.IsFalse(behaviourContext.IsMixInParameterDirtyOnlyUpdateSupported());
Assert.IsFalse(behaviourContext.IsWaveBufferVersion2Supported());
Assert.AreEqual(0.70f, behaviourContext.GetAudioRendererProcessingTimeLimit());
Assert.AreEqual(1, behaviourContext.GetCommandProcessingTimeEstimatorVersion());
Assert.AreEqual(1, behaviourContext.GetPerformanceMetricsDataFormat());
}
[Test]
public void TestRevision4()
{
BehaviourContext behaviourContext = new BehaviourContext();
behaviourContext.SetUserRevision(BehaviourContext.BaseRevisionMagic + BehaviourContext.Revision4);
Assert.IsTrue(behaviourContext.IsAdpcmLoopContextBugFixed());
Assert.IsTrue(behaviourContext.IsSplitterSupported());
Assert.IsTrue(behaviourContext.IsLongSizePreDelaySupported());
Assert.IsTrue(behaviourContext.IsAudioUsbDeviceOutputSupported());
Assert.IsFalse(behaviourContext.IsFlushVoiceWaveBuffersSupported());
Assert.IsFalse(behaviourContext.IsSplitterBugFixed());
Assert.IsFalse(behaviourContext.IsElapsedFrameCountSupported());
Assert.IsFalse(behaviourContext.IsDecodingBehaviourFlagSupported());
Assert.IsFalse(behaviourContext.IsBiquadFilterEffectStateClearBugFixed());
Assert.IsFalse(behaviourContext.IsMixInParameterDirtyOnlyUpdateSupported());
Assert.IsFalse(behaviourContext.IsWaveBufferVersion2Supported());
Assert.AreEqual(0.75f, behaviourContext.GetAudioRendererProcessingTimeLimit());
Assert.AreEqual(1, behaviourContext.GetCommandProcessingTimeEstimatorVersion());
Assert.AreEqual(1, behaviourContext.GetPerformanceMetricsDataFormat());
}
[Test]
public void TestRevision5()
{
BehaviourContext behaviourContext = new BehaviourContext();
behaviourContext.SetUserRevision(BehaviourContext.BaseRevisionMagic + BehaviourContext.Revision5);
Assert.IsTrue(behaviourContext.IsAdpcmLoopContextBugFixed());
Assert.IsTrue(behaviourContext.IsSplitterSupported());
Assert.IsTrue(behaviourContext.IsLongSizePreDelaySupported());
Assert.IsTrue(behaviourContext.IsAudioUsbDeviceOutputSupported());
Assert.IsTrue(behaviourContext.IsFlushVoiceWaveBuffersSupported());
Assert.IsTrue(behaviourContext.IsSplitterBugFixed());
Assert.IsTrue(behaviourContext.IsElapsedFrameCountSupported());
Assert.IsTrue(behaviourContext.IsDecodingBehaviourFlagSupported());
Assert.IsFalse(behaviourContext.IsBiquadFilterEffectStateClearBugFixed());
Assert.IsFalse(behaviourContext.IsMixInParameterDirtyOnlyUpdateSupported());
Assert.IsFalse(behaviourContext.IsWaveBufferVersion2Supported());
Assert.AreEqual(0.80f, behaviourContext.GetAudioRendererProcessingTimeLimit());
Assert.AreEqual(2, behaviourContext.GetCommandProcessingTimeEstimatorVersion());
Assert.AreEqual(2, behaviourContext.GetPerformanceMetricsDataFormat());
}
[Test]
public void TestRevision6()
{
BehaviourContext behaviourContext = new BehaviourContext();
behaviourContext.SetUserRevision(BehaviourContext.BaseRevisionMagic + BehaviourContext.Revision6);
Assert.IsTrue(behaviourContext.IsAdpcmLoopContextBugFixed());
Assert.IsTrue(behaviourContext.IsSplitterSupported());
Assert.IsTrue(behaviourContext.IsLongSizePreDelaySupported());
Assert.IsTrue(behaviourContext.IsAudioUsbDeviceOutputSupported());
Assert.IsTrue(behaviourContext.IsFlushVoiceWaveBuffersSupported());
Assert.IsTrue(behaviourContext.IsSplitterBugFixed());
Assert.IsTrue(behaviourContext.IsElapsedFrameCountSupported());
Assert.IsTrue(behaviourContext.IsDecodingBehaviourFlagSupported());
Assert.IsTrue(behaviourContext.IsBiquadFilterEffectStateClearBugFixed());
Assert.IsFalse(behaviourContext.IsMixInParameterDirtyOnlyUpdateSupported());
Assert.IsFalse(behaviourContext.IsWaveBufferVersion2Supported());
Assert.AreEqual(0.80f, behaviourContext.GetAudioRendererProcessingTimeLimit());
Assert.AreEqual(2, behaviourContext.GetCommandProcessingTimeEstimatorVersion());
Assert.AreEqual(2, behaviourContext.GetPerformanceMetricsDataFormat());
}
[Test]
public void TestRevision7()
{
BehaviourContext behaviourContext = new BehaviourContext();
behaviourContext.SetUserRevision(BehaviourContext.BaseRevisionMagic + BehaviourContext.Revision7);
Assert.IsTrue(behaviourContext.IsAdpcmLoopContextBugFixed());
Assert.IsTrue(behaviourContext.IsSplitterSupported());
Assert.IsTrue(behaviourContext.IsLongSizePreDelaySupported());
Assert.IsTrue(behaviourContext.IsAudioUsbDeviceOutputSupported());
Assert.IsTrue(behaviourContext.IsFlushVoiceWaveBuffersSupported());
Assert.IsTrue(behaviourContext.IsSplitterBugFixed());
Assert.IsTrue(behaviourContext.IsElapsedFrameCountSupported());
Assert.IsTrue(behaviourContext.IsDecodingBehaviourFlagSupported());
Assert.IsTrue(behaviourContext.IsBiquadFilterEffectStateClearBugFixed());
Assert.IsTrue(behaviourContext.IsMixInParameterDirtyOnlyUpdateSupported());
Assert.IsFalse(behaviourContext.IsWaveBufferVersion2Supported());
Assert.AreEqual(0.80f, behaviourContext.GetAudioRendererProcessingTimeLimit());
Assert.AreEqual(2, behaviourContext.GetCommandProcessingTimeEstimatorVersion());
Assert.AreEqual(2, behaviourContext.GetPerformanceMetricsDataFormat());
}
[Test]
public void TestRevision8()
{
BehaviourContext behaviourContext = new BehaviourContext();
behaviourContext.SetUserRevision(BehaviourContext.BaseRevisionMagic + BehaviourContext.Revision8);
Assert.IsTrue(behaviourContext.IsAdpcmLoopContextBugFixed());
Assert.IsTrue(behaviourContext.IsSplitterSupported());
Assert.IsTrue(behaviourContext.IsLongSizePreDelaySupported());
Assert.IsTrue(behaviourContext.IsAudioUsbDeviceOutputSupported());
Assert.IsTrue(behaviourContext.IsFlushVoiceWaveBuffersSupported());
Assert.IsTrue(behaviourContext.IsSplitterBugFixed());
Assert.IsTrue(behaviourContext.IsElapsedFrameCountSupported());
Assert.IsTrue(behaviourContext.IsDecodingBehaviourFlagSupported());
Assert.IsTrue(behaviourContext.IsBiquadFilterEffectStateClearBugFixed());
Assert.IsTrue(behaviourContext.IsMixInParameterDirtyOnlyUpdateSupported());
Assert.IsTrue(behaviourContext.IsWaveBufferVersion2Supported());
Assert.AreEqual(0.80f, behaviourContext.GetAudioRendererProcessingTimeLimit());
Assert.AreEqual(3, behaviourContext.GetCommandProcessingTimeEstimatorVersion());
Assert.AreEqual(2, behaviourContext.GetPerformanceMetricsDataFormat());
}
}
}

View File

@ -0,0 +1,62 @@
using NUnit.Framework;
using Ryujinx.Audio.Renderer.Server.MemoryPool;
using System.Runtime.CompilerServices;
namespace Ryujinx.Tests.Audio.Renderer.Server
{
class MemoryPoolStateTests
{
[Test]
public void EnsureTypeSize()
{
Assert.AreEqual(Unsafe.SizeOf<MemoryPoolState>(), 0x20);
}
[Test]
public void TestContains()
{
MemoryPoolState memoryPool = MemoryPoolState.Create(MemoryPoolState.LocationType.Cpu);
memoryPool.SetCpuAddress(0x1000000, 0x1000);
memoryPool.DspAddress = 0x2000000;
Assert.IsTrue(memoryPool.Contains(0x1000000, 0x10));
Assert.IsTrue(memoryPool.Contains(0x1000FE0, 0x10));
Assert.IsTrue(memoryPool.Contains(0x1000FFF, 0x1));
Assert.IsFalse(memoryPool.Contains(0x1000FFF, 0x2));
Assert.IsFalse(memoryPool.Contains(0x1001000, 0x10));
Assert.IsFalse(memoryPool.Contains(0x2000000, 0x10));
}
[Test]
public void TestTranslate()
{
MemoryPoolState memoryPool = MemoryPoolState.Create(MemoryPoolState.LocationType.Cpu);
memoryPool.SetCpuAddress(0x1000000, 0x1000);
memoryPool.DspAddress = 0x2000000;
Assert.AreEqual(0x2000FE0, memoryPool.Translate(0x1000FE0, 0x10));
Assert.AreEqual(0x2000FFF, memoryPool.Translate(0x1000FFF, 0x1));
Assert.AreEqual(0x0, memoryPool.Translate(0x1000FFF, 0x2));
Assert.AreEqual(0x0, memoryPool.Translate(0x1001000, 0x10));
Assert.AreEqual(0x0, memoryPool.Translate(0x2000000, 0x10));
}
[Test]
public void TestIsMapped()
{
MemoryPoolState memoryPool = MemoryPoolState.Create(MemoryPoolState.LocationType.Cpu);
memoryPool.SetCpuAddress(0x1000000, 0x1000);
Assert.IsFalse(memoryPool.IsMapped());
memoryPool.DspAddress = 0x2000000;
Assert.IsTrue(memoryPool.IsMapped());
}
}
}

View File

@ -0,0 +1,15 @@
using NUnit.Framework;
using Ryujinx.Audio.Renderer.Server.Mix;
using System.Runtime.CompilerServices;
namespace Ryujinx.Tests.Audio.Renderer.Server
{
class MixStateTests
{
[Test]
public void EnsureTypeSize()
{
Assert.AreEqual(0x940, Unsafe.SizeOf<MixState>());
}
}
}

View File

@ -0,0 +1,135 @@
using NUnit.Framework;
using Ryujinx.Audio.Renderer;
using Ryujinx.Audio.Renderer.Server.MemoryPool;
using System;
using static Ryujinx.Audio.Renderer.Common.BehaviourParameter;
using CpuAddress = System.UInt64;
using DspAddress = System.UInt64;
namespace Ryujinx.Tests.Audio.Renderer.Server
{
class PoolMapperTests
{
private const uint DummyProcessHandle = 0xCAFEBABE;
[Test]
public void TestInitializeSystemPool()
{
PoolMapper poolMapper = new PoolMapper(DummyProcessHandle, true);
MemoryPoolState memoryPoolDsp = MemoryPoolState.Create(MemoryPoolState.LocationType.Dsp);
MemoryPoolState memoryPoolCpu = MemoryPoolState.Create(MemoryPoolState.LocationType.Cpu);
const CpuAddress CpuAddress = 0x20000;
const DspAddress DspAddress = CpuAddress; // TODO: DSP LLE
const ulong CpuSize = 0x1000;
Assert.IsFalse(poolMapper.InitializeSystemPool(ref memoryPoolCpu, CpuAddress, CpuSize));
Assert.IsTrue(poolMapper.InitializeSystemPool(ref memoryPoolDsp, CpuAddress, CpuSize));
Assert.AreEqual(CpuAddress, memoryPoolDsp.CpuAddress);
Assert.AreEqual(CpuSize, memoryPoolDsp.Size);
Assert.AreEqual(DspAddress, memoryPoolDsp.DspAddress);
}
[Test]
public void TestGetProcessHandle()
{
PoolMapper poolMapper = new PoolMapper(DummyProcessHandle, true);
MemoryPoolState memoryPoolDsp = MemoryPoolState.Create(MemoryPoolState.LocationType.Dsp);
MemoryPoolState memoryPoolCpu = MemoryPoolState.Create(MemoryPoolState.LocationType.Cpu);
Assert.AreEqual(0xFFFF8001, poolMapper.GetProcessHandle(ref memoryPoolCpu));
Assert.AreEqual(DummyProcessHandle, poolMapper.GetProcessHandle(ref memoryPoolDsp));
}
[Test]
public void TestMappings()
{
PoolMapper poolMapper = new PoolMapper(DummyProcessHandle, true);
MemoryPoolState memoryPoolDsp = MemoryPoolState.Create(MemoryPoolState.LocationType.Dsp);
MemoryPoolState memoryPoolCpu = MemoryPoolState.Create(MemoryPoolState.LocationType.Cpu);
const CpuAddress CpuAddress = 0x20000;
const DspAddress DspAddress = CpuAddress; // TODO: DSP LLE
const ulong CpuSize = 0x1000;
memoryPoolDsp.SetCpuAddress(CpuAddress, CpuSize);
memoryPoolCpu.SetCpuAddress(CpuAddress, CpuSize);
Assert.AreEqual(DspAddress, poolMapper.Map(ref memoryPoolCpu));
Assert.AreEqual(DspAddress, poolMapper.Map(ref memoryPoolDsp));
Assert.AreEqual(DspAddress, memoryPoolDsp.DspAddress);
Assert.IsTrue(poolMapper.Unmap(ref memoryPoolCpu));
memoryPoolDsp.IsUsed = true;
Assert.IsFalse(poolMapper.Unmap(ref memoryPoolDsp));
memoryPoolDsp.IsUsed = false;
Assert.IsTrue(poolMapper.Unmap(ref memoryPoolDsp));
}
[Test]
public void TestTryAttachBuffer()
{
const CpuAddress CpuAddress = 0x20000;
const DspAddress DspAddress = CpuAddress; // TODO: DSP LLE
const ulong CpuSize = 0x1000;
const int MemoryPoolStateArraySize = 0x10;
const CpuAddress CpuAddressRegionEnding = CpuAddress * MemoryPoolStateArraySize;
MemoryPoolState[] memoryPoolStateArray = new MemoryPoolState[MemoryPoolStateArraySize];
for (int i = 0; i < memoryPoolStateArray.Length; i++)
{
memoryPoolStateArray[i] = MemoryPoolState.Create(MemoryPoolState.LocationType.Cpu);
memoryPoolStateArray[i].SetCpuAddress(CpuAddress + (ulong)i * CpuSize, CpuSize);
}
ErrorInfo errorInfo;
AddressInfo addressInfo = AddressInfo.Create();
PoolMapper poolMapper = new PoolMapper(DummyProcessHandle, true);
Assert.IsTrue(poolMapper.TryAttachBuffer(out errorInfo, ref addressInfo, 0, 0));
Assert.AreEqual(ResultCode.InvalidAddressInfo, errorInfo.ErrorCode);
Assert.AreEqual(0, errorInfo.ExtraErrorInfo);
Assert.AreEqual(0, addressInfo.ForceMappedDspAddress);
Assert.IsTrue(poolMapper.TryAttachBuffer(out errorInfo, ref addressInfo, CpuAddress, CpuSize));
Assert.AreEqual(ResultCode.InvalidAddressInfo, errorInfo.ErrorCode);
Assert.AreEqual(CpuAddress, errorInfo.ExtraErrorInfo);
Assert.AreEqual(DspAddress, addressInfo.ForceMappedDspAddress);
poolMapper = new PoolMapper(DummyProcessHandle, false);
Assert.IsFalse(poolMapper.TryAttachBuffer(out errorInfo, ref addressInfo, 0, 0));
addressInfo.ForceMappedDspAddress = 0;
Assert.IsFalse(poolMapper.TryAttachBuffer(out errorInfo, ref addressInfo, CpuAddress, CpuSize));
Assert.AreEqual(ResultCode.InvalidAddressInfo, errorInfo.ErrorCode);
Assert.AreEqual(CpuAddress, errorInfo.ExtraErrorInfo);
Assert.AreEqual(0, addressInfo.ForceMappedDspAddress);
poolMapper = new PoolMapper(DummyProcessHandle, memoryPoolStateArray.AsMemory(), false);
Assert.IsFalse(poolMapper.TryAttachBuffer(out errorInfo, ref addressInfo, CpuAddressRegionEnding, CpuSize));
Assert.AreEqual(ResultCode.InvalidAddressInfo, errorInfo.ErrorCode);
Assert.AreEqual(CpuAddressRegionEnding, errorInfo.ExtraErrorInfo);
Assert.AreEqual(0, addressInfo.ForceMappedDspAddress);
Assert.IsFalse(addressInfo.HasMemoryPoolState);
Assert.IsTrue(poolMapper.TryAttachBuffer(out errorInfo, ref addressInfo, CpuAddress, CpuSize));
Assert.AreEqual(ResultCode.Success, errorInfo.ErrorCode);
Assert.AreEqual(0, errorInfo.ExtraErrorInfo);
Assert.AreEqual(0, addressInfo.ForceMappedDspAddress);
Assert.IsTrue(addressInfo.HasMemoryPoolState);
}
}
}

View File

@ -0,0 +1,15 @@
using NUnit.Framework;
using Ryujinx.Audio.Renderer.Server.Splitter;
using System.Runtime.CompilerServices;
namespace Ryujinx.Tests.Audio.Renderer.Server
{
class SplitterDestinationTests
{
[Test]
public void EnsureTypeSize()
{
Assert.AreEqual(0xE0, Unsafe.SizeOf<SplitterDestination>());
}
}
}

View File

@ -0,0 +1,15 @@
using NUnit.Framework;
using Ryujinx.Audio.Renderer.Server.Splitter;
using System.Runtime.CompilerServices;
namespace Ryujinx.Tests.Audio.Renderer.Server
{
class SplitterStateTests
{
[Test]
public void EnsureTypeSize()
{
Assert.AreEqual(0x20, Unsafe.SizeOf<SplitterState>());
}
}
}

View File

@ -0,0 +1,15 @@
using NUnit.Framework;
using Ryujinx.Audio.Renderer.Server.Voice;
using System.Runtime.CompilerServices;
namespace Ryujinx.Tests.Audio.Renderer.Server
{
class VoiceChannelResourceTests
{
[Test]
public void EnsureTypeSize()
{
Assert.AreEqual(0xD0, Unsafe.SizeOf<VoiceChannelResource>());
}
}
}

View File

@ -0,0 +1,15 @@
using NUnit.Framework;
using Ryujinx.Audio.Renderer.Server.Voice;
using System.Runtime.CompilerServices;
namespace Ryujinx.Tests.Audio.Renderer.Server
{
class VoiceStateTests
{
[Test]
public void EnsureTypeSize()
{
Assert.LessOrEqual(Unsafe.SizeOf<VoiceState>(), 0x220);
}
}
}

View File

@ -0,0 +1,15 @@
using NUnit.Framework;
using Ryujinx.Audio.Renderer.Server.Voice;
using System.Runtime.CompilerServices;
namespace Ryujinx.Tests.Audio.Renderer.Server
{
class WaveBufferTests
{
[Test]
public void EnsureTypeSize()
{
Assert.AreEqual(0x58, Unsafe.SizeOf<WaveBuffer>());
}
}
}

View File

@ -0,0 +1,15 @@
using NUnit.Framework;
using Ryujinx.Audio.Renderer.Parameter;
using System.Runtime.CompilerServices;
namespace Ryujinx.Tests.Audio.Renderer
{
class VoiceChannelResourceInParameterTests
{
[Test]
public void EnsureTypeSize()
{
Assert.AreEqual(0x70, Unsafe.SizeOf<VoiceChannelResourceInParameter>());
}
}
}

View File

@ -0,0 +1,15 @@
using NUnit.Framework;
using Ryujinx.Audio.Renderer.Parameter;
using System.Runtime.CompilerServices;
namespace Ryujinx.Tests.Audio.Renderer
{
class VoiceInParameterTests
{
[Test]
public void EnsureTypeSize()
{
Assert.AreEqual(0x170, Unsafe.SizeOf<VoiceInParameter>());
}
}
}

View File

@ -0,0 +1,15 @@
using NUnit.Framework;
using Ryujinx.Audio.Renderer.Parameter;
using System.Runtime.CompilerServices;
namespace Ryujinx.Tests.Audio.Renderer
{
class VoiceOutStatusTests
{
[Test]
public void EnsureTypeSize()
{
Assert.AreEqual(0x10, Unsafe.SizeOf<VoiceOutStatus>());
}
}
}

View File

@ -34,6 +34,7 @@
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Ryujinx.Audio.Renderer\Ryujinx.Audio.Renderer.csproj" />
<ProjectReference Include="..\Ryujinx.Cpu\Ryujinx.Cpu.csproj" />
<ProjectReference Include="..\Ryujinx.Memory\Ryujinx.Memory.csproj" />
<ProjectReference Include="..\Ryujinx.Tests.Unicorn\Ryujinx.Tests.Unicorn.csproj" />