[Ryujinx.Audio] Address dotnet-format issues (#5362)
* dotnet format style --severity info Some changes were manually reverted. * dotnet format analyzers --serverity info Some changes have been minimally adapted. * Restore a few unused methods and variables * Silence dotnet format IDE0060 warnings * Silence dotnet format IDE0052 warnings * Address dotnet format CA1816 warnings * Address or silence dotnet format CA2208 warnings * Address or silence dotnet format CA2211 warnings * Address review comments * Address most dotnet format whitespace warnings * Apply dotnet format whitespace formatting A few of them have been manually reverted and the corresponding warning was silenced * Format if-blocks correctly * Run dotnet format whitespace after rebase * Run dotnet format after rebase and remove unused usings - analyzers - style - whitespace * Add comments to disabled warnings * Remove a few unused parameters * Simplify properties and array initialization, Use const when possible, Remove trailing commas * Start working on disabled warnings * Fix and silence a few dotnet-format warnings again * Address IDE0251 warnings * Silence IDE0060 in .editorconfig * Revert "Simplify properties and array initialization, Use const when possible, Remove trailing commas" This reverts commit 9462e4136c0a2100dc28b20cf9542e06790aa67e. * dotnet format whitespace after rebase * Fix naming rule violations, remove redundant code and fix build issues * Apply suggestions from code review Co-authored-by: Ac_K <Acoustik666@gmail.com> * Add trailing commas * Apply suggestions from code review Co-authored-by: Ac_K <Acoustik666@gmail.com> * Address review feedback --------- Co-authored-by: Ac_K <Acoustik666@gmail.com>
This commit is contained in:
@@ -19,7 +19,6 @@ using System;
|
||||
using System.Buffers;
|
||||
using System.Diagnostics;
|
||||
using System.Threading;
|
||||
|
||||
using CpuAddress = System.UInt64;
|
||||
|
||||
namespace Ryujinx.Audio.Renderer.Server
|
||||
@@ -30,19 +29,21 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||
|
||||
private AudioRendererRenderingDevice _renderingDevice;
|
||||
private AudioRendererExecutionMode _executionMode;
|
||||
private IWritableEvent _systemEvent;
|
||||
private readonly IWritableEvent _systemEvent;
|
||||
private MemoryPoolState _dspMemoryPoolState;
|
||||
private VoiceContext _voiceContext;
|
||||
private MixContext _mixContext;
|
||||
private SinkContext _sinkContext;
|
||||
private SplitterContext _splitterContext;
|
||||
private EffectContext _effectContext;
|
||||
private readonly VoiceContext _voiceContext;
|
||||
private readonly MixContext _mixContext;
|
||||
private readonly SinkContext _sinkContext;
|
||||
private readonly SplitterContext _splitterContext;
|
||||
private readonly EffectContext _effectContext;
|
||||
private PerformanceManager _performanceManager;
|
||||
private UpsamplerManager _upsamplerManager;
|
||||
private bool _isActive;
|
||||
private BehaviourContext _behaviourContext;
|
||||
#pragma warning disable IDE0052 // Remove unread private member
|
||||
private ulong _totalElapsedTicksUpdating;
|
||||
private ulong _totalElapsedTicks;
|
||||
#pragma warning restore IDE0052
|
||||
private int _sessionId;
|
||||
private Memory<MemoryPoolState> _memoryPools;
|
||||
|
||||
@@ -75,7 +76,7 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||
private ulong _elapsedFrameCount;
|
||||
private ulong _renderingStartTick;
|
||||
|
||||
private AudioRendererManager _manager;
|
||||
private readonly AudioRendererManager _manager;
|
||||
|
||||
private int _disposeState;
|
||||
|
||||
@@ -143,12 +144,12 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||
|
||||
WorkBufferAllocator workBufferAllocator;
|
||||
|
||||
workBufferMemory.Span.Fill(0);
|
||||
workBufferMemory.Span.Clear();
|
||||
_workBufferMemoryPin = workBufferMemory.Pin();
|
||||
|
||||
workBufferAllocator = new WorkBufferAllocator(workBufferMemory);
|
||||
|
||||
PoolMapper poolMapper = new PoolMapper(processHandle, false);
|
||||
PoolMapper poolMapper = new(processHandle, false);
|
||||
poolMapper.InitializeSystemPool(ref _dspMemoryPoolState, workBuffer, workBufferSize);
|
||||
|
||||
_mixBuffer = workBufferAllocator.Allocate<float>(_sampleCount * (_voiceChannelCountMax + _mixBufferCount), 0x10);
|
||||
@@ -244,9 +245,9 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||
|
||||
foreach (ref MixState mix in mixes.Span)
|
||||
{
|
||||
mix = new MixState(effectProcessingOrderArray.Slice(0, (int)parameter.EffectCount), ref _behaviourContext);
|
||||
mix = new MixState(effectProcessingOrderArray[..(int)parameter.EffectCount], ref _behaviourContext);
|
||||
|
||||
effectProcessingOrderArray = effectProcessingOrderArray.Slice((int)parameter.EffectCount);
|
||||
effectProcessingOrderArray = effectProcessingOrderArray[(int)parameter.EffectCount..];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -341,26 +342,15 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||
_elapsedFrameCount = 0;
|
||||
_voiceDropParameter = 1.0f;
|
||||
|
||||
switch (_behaviourContext.GetCommandProcessingTimeEstimatorVersion())
|
||||
_commandProcessingTimeEstimator = _behaviourContext.GetCommandProcessingTimeEstimatorVersion() switch
|
||||
{
|
||||
case 1:
|
||||
_commandProcessingTimeEstimator = new CommandProcessingTimeEstimatorVersion1(_sampleCount, _mixBufferCount);
|
||||
break;
|
||||
case 2:
|
||||
_commandProcessingTimeEstimator = new CommandProcessingTimeEstimatorVersion2(_sampleCount, _mixBufferCount);
|
||||
break;
|
||||
case 3:
|
||||
_commandProcessingTimeEstimator = new CommandProcessingTimeEstimatorVersion3(_sampleCount, _mixBufferCount);
|
||||
break;
|
||||
case 4:
|
||||
_commandProcessingTimeEstimator = new CommandProcessingTimeEstimatorVersion4(_sampleCount, _mixBufferCount);
|
||||
break;
|
||||
case 5:
|
||||
_commandProcessingTimeEstimator = new CommandProcessingTimeEstimatorVersion5(_sampleCount, _mixBufferCount);
|
||||
break;
|
||||
default:
|
||||
throw new NotImplementedException($"Unsupported processing time estimator version {_behaviourContext.GetCommandProcessingTimeEstimatorVersion()}.");
|
||||
}
|
||||
1 => new CommandProcessingTimeEstimatorVersion1(_sampleCount, _mixBufferCount),
|
||||
2 => new CommandProcessingTimeEstimatorVersion2(_sampleCount, _mixBufferCount),
|
||||
3 => new CommandProcessingTimeEstimatorVersion3(_sampleCount, _mixBufferCount),
|
||||
4 => new CommandProcessingTimeEstimatorVersion4(_sampleCount, _mixBufferCount),
|
||||
5 => new CommandProcessingTimeEstimatorVersion5(_sampleCount, _mixBufferCount),
|
||||
_ => throw new NotImplementedException($"Unsupported processing time estimator version {_behaviourContext.GetCommandProcessingTimeEstimatorVersion()}."),
|
||||
};
|
||||
|
||||
return ResultCode.Success;
|
||||
}
|
||||
@@ -402,9 +392,9 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||
{
|
||||
ulong updateStartTicks = GetSystemTicks();
|
||||
|
||||
output.Span.Fill(0);
|
||||
output.Span.Clear();
|
||||
|
||||
StateUpdater stateUpdater = new StateUpdater(input, output, _processHandle, _behaviourContext);
|
||||
StateUpdater stateUpdater = new(input, output, _processHandle, _behaviourContext);
|
||||
|
||||
ResultCode result;
|
||||
|
||||
@@ -609,9 +599,9 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||
_renderingStartTick = 0;
|
||||
}
|
||||
|
||||
CommandBuffer commandBuffer = new CommandBuffer(commandList, _commandProcessingTimeEstimator);
|
||||
CommandBuffer commandBuffer = new(commandList, _commandProcessingTimeEstimator);
|
||||
|
||||
CommandGenerator commandGenerator = new CommandGenerator(commandBuffer, GetContext(), _voiceContext, _mixContext, _effectContext, _sinkContext, _splitterContext, _performanceManager);
|
||||
CommandGenerator commandGenerator = new(commandBuffer, GetContext(), _voiceContext, _mixContext, _effectContext, _sinkContext, _splitterContext, _performanceManager);
|
||||
|
||||
_voiceContext.Sort();
|
||||
commandGenerator.GenerateVoices();
|
||||
@@ -731,7 +721,7 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||
DepopBuffer = _depopBuffer,
|
||||
MixBufferCount = GetMixBufferCount(),
|
||||
SessionId = _sessionId,
|
||||
UpsamplerManager = _upsamplerManager
|
||||
UpsamplerManager = _upsamplerManager,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -742,7 +732,7 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||
|
||||
public static ulong GetWorkBufferSize(ref AudioRendererConfiguration parameter)
|
||||
{
|
||||
BehaviourContext behaviourContext = new BehaviourContext();
|
||||
BehaviourContext behaviourContext = new();
|
||||
|
||||
behaviourContext.SetUserRevision(parameter.Revision);
|
||||
|
||||
@@ -813,6 +803,8 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
GC.SuppressFinalize(this);
|
||||
|
||||
if (Interlocked.CompareExchange(ref _disposeState, 1, 0) == 0)
|
||||
{
|
||||
Dispose(true);
|
||||
@@ -828,7 +820,7 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||
Stop();
|
||||
}
|
||||
|
||||
PoolMapper mapper = new PoolMapper(_processHandle, false);
|
||||
PoolMapper mapper = new(_processHandle, false);
|
||||
mapper.Unmap(ref _dspMemoryPoolState);
|
||||
|
||||
PoolMapper.ClearUsageState(_memoryPools);
|
||||
@@ -876,4 +868,4 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||
return ResultCode.UnsupportedOperation;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||
/// <summary>
|
||||
/// The session ids allocation table.
|
||||
/// </summary>
|
||||
private int[] _sessionIds;
|
||||
private readonly int[] _sessionIds;
|
||||
|
||||
/// <summary>
|
||||
/// The events linked to each session.
|
||||
@@ -39,7 +39,7 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||
/// <summary>
|
||||
/// The <see cref="AudioRenderSystem"/> sessions instances.
|
||||
/// </summary>
|
||||
private AudioRenderSystem[] _sessions;
|
||||
private readonly AudioRenderSystem[] _sessions;
|
||||
|
||||
/// <summary>
|
||||
/// The count of active sessions.
|
||||
@@ -186,7 +186,7 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||
|
||||
_workerThread = new Thread(SendCommands)
|
||||
{
|
||||
Name = "AudioRendererManager.Worker"
|
||||
Name = "AudioRendererManager.Worker",
|
||||
};
|
||||
|
||||
_workerThread.Start();
|
||||
@@ -317,7 +317,7 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||
{
|
||||
int sessionId = AcquireSessionId();
|
||||
|
||||
AudioRenderSystem audioRenderer = new AudioRenderSystem(this, _sessionsSystemEvent[sessionId]);
|
||||
AudioRenderSystem audioRenderer = new(this, _sessionsSystemEvent[sessionId]);
|
||||
|
||||
// TODO: Eventually, we should try to use the guest supplied work buffer instead of allocating
|
||||
// our own. However, it was causing problems on some applications that would unmap the memory
|
||||
@@ -367,6 +367,8 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
GC.SuppressFinalize(this);
|
||||
|
||||
if (Interlocked.CompareExchange(ref _disposeState, 1, 0) == 0)
|
||||
{
|
||||
Dispose(true);
|
||||
@@ -402,4 +404,4 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -125,7 +125,7 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||
/// <summary>
|
||||
/// Error storage.
|
||||
/// </summary>
|
||||
private ErrorInfo[] _errorInfos;
|
||||
private readonly ErrorInfo[] _errorInfos;
|
||||
|
||||
/// <summary>
|
||||
/// Current position in the <see cref="_errorInfos"/> array.
|
||||
@@ -254,7 +254,8 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||
{
|
||||
return 0.80f;
|
||||
}
|
||||
else if (CheckFeatureSupported(UserRevision, BaseRevisionMagic + Revision4))
|
||||
|
||||
if (CheckFeatureSupported(UserRevision, BaseRevisionMagic + Revision4))
|
||||
{
|
||||
return 0.75f;
|
||||
}
|
||||
@@ -299,10 +300,8 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -436,7 +435,7 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||
errorInfos[i] = new ErrorInfo
|
||||
{
|
||||
ErrorCode = 0,
|
||||
ExtraErrorInfo = 0
|
||||
ExtraErrorInfo = 0,
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -450,4 +449,4 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||
_errorIndex = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||
/// <summary>
|
||||
/// The command processing time estimator in use.
|
||||
/// </summary>
|
||||
private ICommandProcessingTimeEstimator _commandProcessingTimeEstimator;
|
||||
private readonly ICommandProcessingTimeEstimator _commandProcessingTimeEstimator;
|
||||
|
||||
/// <summary>
|
||||
/// The estimated total processing time.
|
||||
@@ -61,7 +61,7 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||
/// <param name="nodeId">The node id associated to this command.</param>
|
||||
public void GenerateClearMixBuffer(int nodeId)
|
||||
{
|
||||
ClearMixBufferCommand command = new ClearMixBufferCommand(nodeId);
|
||||
ClearMixBufferCommand command = new(nodeId);
|
||||
|
||||
command.EstimatedProcessingTime = _commandProcessingTimeEstimator.Estimate(command);
|
||||
|
||||
@@ -79,7 +79,7 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||
/// <param name="wasPlaying">Set to true if the voice was playing previously.</param>
|
||||
public void GenerateDepopPrepare(Memory<VoiceUpdateState> state, Memory<float> depopBuffer, uint bufferCount, uint bufferOffset, int nodeId, bool wasPlaying)
|
||||
{
|
||||
DepopPrepareCommand command = new DepopPrepareCommand(state, depopBuffer, bufferCount, bufferOffset, nodeId, wasPlaying);
|
||||
DepopPrepareCommand command = new(state, depopBuffer, bufferCount, bufferOffset, nodeId, wasPlaying);
|
||||
|
||||
command.EstimatedProcessingTime = _commandProcessingTimeEstimator.Estimate(command);
|
||||
|
||||
@@ -94,7 +94,7 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||
/// <param name="nodeId">The node id associated to this command.</param>
|
||||
public void GeneratePerformance(ref PerformanceEntryAddresses performanceEntryAddresses, PerformanceCommand.Type type, int nodeId)
|
||||
{
|
||||
PerformanceCommand command = new PerformanceCommand(ref performanceEntryAddresses, type, nodeId);
|
||||
PerformanceCommand command = new(ref performanceEntryAddresses, type, nodeId);
|
||||
|
||||
command.EstimatedProcessingTime = _commandProcessingTimeEstimator.Estimate(command);
|
||||
|
||||
@@ -110,7 +110,7 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||
/// <param name="nodeId">The node id associated to this command.</param>
|
||||
public void GenerateVolumeRamp(float previousVolume, float volume, uint bufferIndex, int nodeId)
|
||||
{
|
||||
VolumeRampCommand command = new VolumeRampCommand(previousVolume, volume, bufferIndex, nodeId);
|
||||
VolumeRampCommand command = new(previousVolume, volume, bufferIndex, nodeId);
|
||||
|
||||
command.EstimatedProcessingTime = _commandProcessingTimeEstimator.Estimate(command);
|
||||
|
||||
@@ -127,7 +127,7 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||
/// <param name="nodeId">The node id associated to this command.</param>
|
||||
public void GenerateDataSourceVersion2(ref VoiceState voiceState, Memory<VoiceUpdateState> state, ushort outputBufferIndex, ushort channelIndex, int nodeId)
|
||||
{
|
||||
DataSourceVersion2Command command = new DataSourceVersion2Command(ref voiceState, state, outputBufferIndex, channelIndex, nodeId);
|
||||
DataSourceVersion2Command command = new(ref voiceState, state, outputBufferIndex, channelIndex, nodeId);
|
||||
|
||||
command.EstimatedProcessingTime = _commandProcessingTimeEstimator.Estimate(command);
|
||||
|
||||
@@ -144,7 +144,7 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||
/// <param name="nodeId">The node id associated to this command.</param>
|
||||
public void GeneratePcmInt16DataSourceVersion1(ref VoiceState voiceState, Memory<VoiceUpdateState> state, ushort outputBufferIndex, ushort channelIndex, int nodeId)
|
||||
{
|
||||
PcmInt16DataSourceCommandVersion1 command = new PcmInt16DataSourceCommandVersion1(ref voiceState, state, outputBufferIndex, channelIndex, nodeId);
|
||||
PcmInt16DataSourceCommandVersion1 command = new(ref voiceState, state, outputBufferIndex, channelIndex, nodeId);
|
||||
|
||||
command.EstimatedProcessingTime = _commandProcessingTimeEstimator.Estimate(command);
|
||||
|
||||
@@ -161,7 +161,7 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||
/// <param name="nodeId">The node id associated to this command.</param>
|
||||
public void GeneratePcmFloatDataSourceVersion1(ref VoiceState voiceState, Memory<VoiceUpdateState> state, ushort outputBufferIndex, ushort channelIndex, int nodeId)
|
||||
{
|
||||
PcmFloatDataSourceCommandVersion1 command = new PcmFloatDataSourceCommandVersion1(ref voiceState, state, outputBufferIndex, channelIndex, nodeId);
|
||||
PcmFloatDataSourceCommandVersion1 command = new(ref voiceState, state, outputBufferIndex, channelIndex, nodeId);
|
||||
|
||||
command.EstimatedProcessingTime = _commandProcessingTimeEstimator.Estimate(command);
|
||||
|
||||
@@ -177,7 +177,7 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||
/// <param name="nodeId">The node id associated to this command.</param>
|
||||
public void GenerateAdpcmDataSourceVersion1(ref VoiceState voiceState, Memory<VoiceUpdateState> state, ushort outputBufferIndex, int nodeId)
|
||||
{
|
||||
AdpcmDataSourceCommandVersion1 command = new AdpcmDataSourceCommandVersion1(ref voiceState, state, outputBufferIndex, nodeId);
|
||||
AdpcmDataSourceCommandVersion1 command = new(ref voiceState, state, outputBufferIndex, nodeId);
|
||||
|
||||
command.EstimatedProcessingTime = _commandProcessingTimeEstimator.Estimate(command);
|
||||
|
||||
@@ -196,7 +196,7 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||
/// <param name="nodeId">The node id associated to this command.</param>
|
||||
public void GenerateBiquadFilter(int baseIndex, ref BiquadFilterParameter filter, Memory<BiquadFilterState> biquadFilterStateMemory, int inputBufferOffset, int outputBufferOffset, bool needInitialization, int nodeId)
|
||||
{
|
||||
BiquadFilterCommand command = new BiquadFilterCommand(baseIndex, ref filter, biquadFilterStateMemory, inputBufferOffset, outputBufferOffset, needInitialization, nodeId);
|
||||
BiquadFilterCommand command = new(baseIndex, ref filter, biquadFilterStateMemory, inputBufferOffset, outputBufferOffset, needInitialization, nodeId);
|
||||
|
||||
command.EstimatedProcessingTime = _commandProcessingTimeEstimator.Estimate(command);
|
||||
|
||||
@@ -215,7 +215,7 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||
/// <param name="nodeId">The node id associated to this command.</param>
|
||||
public void GenerateGroupedBiquadFilter(int baseIndex, ReadOnlySpan<BiquadFilterParameter> filters, Memory<BiquadFilterState> biquadFilterStatesMemory, int inputBufferOffset, int outputBufferOffset, ReadOnlySpan<bool> isInitialized, int nodeId)
|
||||
{
|
||||
GroupedBiquadFilterCommand command = new GroupedBiquadFilterCommand(baseIndex, filters, biquadFilterStatesMemory, inputBufferOffset, outputBufferOffset, isInitialized, nodeId);
|
||||
GroupedBiquadFilterCommand command = new(baseIndex, filters, biquadFilterStatesMemory, inputBufferOffset, outputBufferOffset, isInitialized, nodeId);
|
||||
|
||||
command.EstimatedProcessingTime = _commandProcessingTimeEstimator.Estimate(command);
|
||||
|
||||
@@ -234,7 +234,7 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||
/// <param name="nodeId">The node id associated to this command.</param>
|
||||
public void GenerateMixRampGrouped(uint mixBufferCount, uint inputBufferIndex, uint outputBufferIndex, Span<float> previousVolume, Span<float> volume, Memory<VoiceUpdateState> state, int nodeId)
|
||||
{
|
||||
MixRampGroupedCommand command = new MixRampGroupedCommand(mixBufferCount, inputBufferIndex, outputBufferIndex, previousVolume, volume, state, nodeId);
|
||||
MixRampGroupedCommand command = new(mixBufferCount, inputBufferIndex, outputBufferIndex, previousVolume, volume, state, nodeId);
|
||||
|
||||
command.EstimatedProcessingTime = _commandProcessingTimeEstimator.Estimate(command);
|
||||
|
||||
@@ -253,7 +253,7 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||
/// <param name="nodeId">The node id associated to this command.</param>
|
||||
public void GenerateMixRamp(float previousVolume, float volume, uint inputBufferIndex, uint outputBufferIndex, int lastSampleIndex, Memory<VoiceUpdateState> state, int nodeId)
|
||||
{
|
||||
MixRampCommand command = new MixRampCommand(previousVolume, volume, inputBufferIndex, outputBufferIndex, lastSampleIndex, state, nodeId);
|
||||
MixRampCommand command = new(previousVolume, volume, inputBufferIndex, outputBufferIndex, lastSampleIndex, state, nodeId);
|
||||
|
||||
command.EstimatedProcessingTime = _commandProcessingTimeEstimator.Estimate(command);
|
||||
|
||||
@@ -270,7 +270,7 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||
/// <param name="sampleRate">The target sample rate in use.</param>
|
||||
public void GenerateDepopForMixBuffersCommand(Memory<float> depopBuffer, uint bufferOffset, uint bufferCount, int nodeId, uint sampleRate)
|
||||
{
|
||||
DepopForMixBuffersCommand command = new DepopForMixBuffersCommand(depopBuffer, bufferOffset, bufferCount, nodeId, sampleRate);
|
||||
DepopForMixBuffersCommand command = new(depopBuffer, bufferOffset, bufferCount, nodeId, sampleRate);
|
||||
|
||||
command.EstimatedProcessingTime = _commandProcessingTimeEstimator.Estimate(command);
|
||||
|
||||
@@ -285,7 +285,7 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||
/// <param name="nodeId">The node id associated to this command.</param>
|
||||
public void GenerateCopyMixBuffer(uint inputBufferIndex, uint outputBufferIndex, int nodeId)
|
||||
{
|
||||
CopyMixBufferCommand command = new CopyMixBufferCommand(inputBufferIndex, outputBufferIndex, nodeId);
|
||||
CopyMixBufferCommand command = new(inputBufferIndex, outputBufferIndex, nodeId);
|
||||
|
||||
command.EstimatedProcessingTime = _commandProcessingTimeEstimator.Estimate(command);
|
||||
|
||||
@@ -301,7 +301,7 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||
/// <param name="volume">The mix volume.</param>
|
||||
public void GenerateMix(uint inputBufferIndex, uint outputBufferIndex, int nodeId, float volume)
|
||||
{
|
||||
MixCommand command = new MixCommand(inputBufferIndex, outputBufferIndex, nodeId, volume);
|
||||
MixCommand command = new(inputBufferIndex, outputBufferIndex, nodeId, volume);
|
||||
|
||||
command.EstimatedProcessingTime = _commandProcessingTimeEstimator.Estimate(command);
|
||||
|
||||
@@ -323,7 +323,7 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||
{
|
||||
if (parameter.IsChannelCountValid())
|
||||
{
|
||||
ReverbCommand command = new ReverbCommand(bufferOffset, parameter, state, isEnabled, workBuffer, nodeId, isLongSizePreDelaySupported, newEffectChannelMappingSupported);
|
||||
ReverbCommand command = new(bufferOffset, parameter, state, isEnabled, workBuffer, nodeId, isLongSizePreDelaySupported, newEffectChannelMappingSupported);
|
||||
|
||||
command.EstimatedProcessingTime = _commandProcessingTimeEstimator.Estimate(command);
|
||||
|
||||
@@ -345,7 +345,7 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||
{
|
||||
if (parameter.IsChannelCountValid())
|
||||
{
|
||||
Reverb3dCommand command = new Reverb3dCommand(bufferOffset, parameter, state, isEnabled, workBuffer, nodeId, newEffectChannelMappingSupported);
|
||||
Reverb3dCommand command = new(bufferOffset, parameter, state, isEnabled, workBuffer, nodeId, newEffectChannelMappingSupported);
|
||||
|
||||
command.EstimatedProcessingTime = _commandProcessingTimeEstimator.Estimate(command);
|
||||
|
||||
@@ -368,7 +368,7 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||
{
|
||||
if (parameter.IsChannelCountValid())
|
||||
{
|
||||
DelayCommand command = new DelayCommand(bufferOffset, parameter, state, isEnabled, workBuffer, nodeId, newEffectChannelMappingSupported);
|
||||
DelayCommand command = new(bufferOffset, parameter, state, isEnabled, workBuffer, nodeId, newEffectChannelMappingSupported);
|
||||
|
||||
command.EstimatedProcessingTime = _commandProcessingTimeEstimator.Estimate(command);
|
||||
|
||||
@@ -389,7 +389,7 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||
{
|
||||
if (parameter.IsChannelCountValid())
|
||||
{
|
||||
LimiterCommandVersion1 command = new LimiterCommandVersion1(bufferOffset, parameter, state, isEnabled, workBuffer, nodeId);
|
||||
LimiterCommandVersion1 command = new(bufferOffset, parameter, state, isEnabled, workBuffer, nodeId);
|
||||
|
||||
command.EstimatedProcessingTime = _commandProcessingTimeEstimator.Estimate(command);
|
||||
|
||||
@@ -411,7 +411,7 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||
{
|
||||
if (parameter.IsChannelCountValid())
|
||||
{
|
||||
LimiterCommandVersion2 command = new LimiterCommandVersion2(bufferOffset, parameter, state, effectResultState, isEnabled, workBuffer, nodeId);
|
||||
LimiterCommandVersion2 command = new(bufferOffset, parameter, state, effectResultState, isEnabled, workBuffer, nodeId);
|
||||
|
||||
command.EstimatedProcessingTime = _commandProcessingTimeEstimator.Estimate(command);
|
||||
|
||||
@@ -437,7 +437,7 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||
{
|
||||
if (state.SendBufferInfoBase != 0 && state.ReturnBufferInfoBase != 0)
|
||||
{
|
||||
AuxiliaryBufferCommand command = new AuxiliaryBufferCommand(bufferOffset, inputBufferOffset, outputBufferOffset, ref state, isEnabled, countMax, outputBuffer, inputBuffer, updateCount, writeOffset, nodeId);
|
||||
AuxiliaryBufferCommand command = new(bufferOffset, inputBufferOffset, outputBufferOffset, ref state, isEnabled, countMax, outputBuffer, inputBuffer, updateCount, writeOffset, nodeId);
|
||||
|
||||
command.EstimatedProcessingTime = _commandProcessingTimeEstimator.Estimate(command);
|
||||
|
||||
@@ -461,7 +461,7 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||
{
|
||||
if (sendBufferInfo != 0)
|
||||
{
|
||||
CaptureBufferCommand command = new CaptureBufferCommand(bufferOffset, inputBufferOffset, sendBufferInfo, isEnabled, countMax, outputBuffer, updateCount, writeOffset, nodeId);
|
||||
CaptureBufferCommand command = new(bufferOffset, inputBufferOffset, sendBufferInfo, isEnabled, countMax, outputBuffer, updateCount, writeOffset, nodeId);
|
||||
|
||||
command.EstimatedProcessingTime = _commandProcessingTimeEstimator.Estimate(command);
|
||||
|
||||
@@ -473,7 +473,7 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||
{
|
||||
if (parameter.IsChannelCountValid())
|
||||
{
|
||||
CompressorCommand command = new CompressorCommand(bufferOffset, parameter, state, isEnabled, nodeId);
|
||||
CompressorCommand command = new(bufferOffset, parameter, state, isEnabled, nodeId);
|
||||
|
||||
command.EstimatedProcessingTime = _commandProcessingTimeEstimator.Estimate(command);
|
||||
|
||||
@@ -489,7 +489,7 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||
/// <param name="nodeId">The node id associated to this command.</param>
|
||||
public void GenerateVolume(float volume, uint bufferOffset, int nodeId)
|
||||
{
|
||||
VolumeCommand command = new VolumeCommand(volume, bufferOffset, nodeId);
|
||||
VolumeCommand command = new(volume, bufferOffset, nodeId);
|
||||
|
||||
command.EstimatedProcessingTime = _commandProcessingTimeEstimator.Estimate(command);
|
||||
|
||||
@@ -504,7 +504,7 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||
/// <param name="nodeId">The node id associated to this command.</param>
|
||||
public void GenerateCircularBuffer(uint bufferOffset, CircularBufferSink sink, int nodeId)
|
||||
{
|
||||
CircularBufferSinkCommand command = new CircularBufferSinkCommand(bufferOffset, ref sink.Parameter, ref sink.CircularBufferAddressInfo, sink.CurrentWriteOffset, nodeId);
|
||||
CircularBufferSinkCommand command = new(bufferOffset, ref sink.Parameter, ref sink.CircularBufferAddressInfo, sink.CurrentWriteOffset, nodeId);
|
||||
|
||||
command.EstimatedProcessingTime = _commandProcessingTimeEstimator.Estimate(command);
|
||||
|
||||
@@ -521,7 +521,7 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||
/// <param name="nodeId">The node id associated to this command.</param>
|
||||
public void GenerateDownMixSurroundToStereo(uint bufferOffset, Span<byte> inputBufferOffset, Span<byte> outputBufferOffset, float[] downMixParameter, int nodeId)
|
||||
{
|
||||
DownMixSurroundToStereoCommand command = new DownMixSurroundToStereoCommand(bufferOffset, inputBufferOffset, outputBufferOffset, downMixParameter, nodeId);
|
||||
DownMixSurroundToStereoCommand command = new(bufferOffset, inputBufferOffset, outputBufferOffset, downMixParameter, nodeId);
|
||||
|
||||
command.EstimatedProcessingTime = _commandProcessingTimeEstimator.Estimate(command);
|
||||
|
||||
@@ -541,7 +541,7 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||
/// <param name="nodeId">The node id associated to this command.</param>
|
||||
public void GenerateUpsample(uint bufferOffset, UpsamplerState upsampler, uint inputCount, Span<byte> inputBufferOffset, uint bufferCountPerSample, uint sampleCount, uint sampleRate, int nodeId)
|
||||
{
|
||||
UpsampleCommand command = new UpsampleCommand(bufferOffset, upsampler, inputCount, inputBufferOffset, bufferCountPerSample, sampleCount, sampleRate, nodeId);
|
||||
UpsampleCommand command = new(bufferOffset, upsampler, inputCount, inputBufferOffset, bufferCountPerSample, sampleCount, sampleRate, nodeId);
|
||||
|
||||
command.EstimatedProcessingTime = _commandProcessingTimeEstimator.Estimate(command);
|
||||
|
||||
@@ -558,11 +558,11 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||
/// <param name="nodeId">The node id associated to this command.</param>
|
||||
public void GenerateDeviceSink(uint bufferOffset, DeviceSink sink, int sessionId, Memory<float> buffer, int nodeId)
|
||||
{
|
||||
DeviceSinkCommand command = new DeviceSinkCommand(bufferOffset, sink, sessionId, buffer, nodeId);
|
||||
DeviceSinkCommand command = new(bufferOffset, sink, sessionId, buffer, nodeId);
|
||||
|
||||
command.EstimatedProcessingTime = _commandProcessingTimeEstimator.Estimate(command);
|
||||
|
||||
AddCommand(command);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,14 +17,14 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||
{
|
||||
public class CommandGenerator
|
||||
{
|
||||
private CommandBuffer _commandBuffer;
|
||||
private RendererSystemContext _rendererContext;
|
||||
private VoiceContext _voiceContext;
|
||||
private MixContext _mixContext;
|
||||
private EffectContext _effectContext;
|
||||
private SinkContext _sinkContext;
|
||||
private SplitterContext _splitterContext;
|
||||
private PerformanceManager _performanceManager;
|
||||
private readonly CommandBuffer _commandBuffer;
|
||||
private readonly RendererSystemContext _rendererContext;
|
||||
private readonly VoiceContext _voiceContext;
|
||||
private readonly MixContext _mixContext;
|
||||
private readonly EffectContext _effectContext;
|
||||
private readonly SinkContext _sinkContext;
|
||||
private readonly SplitterContext _splitterContext;
|
||||
private readonly PerformanceManager _performanceManager;
|
||||
|
||||
public CommandGenerator(CommandBuffer commandBuffer, RendererSystemContext rendererContext, VoiceContext voiceContext, MixContext mixContext, EffectContext effectContext, SinkContext sinkContext, SplitterContext splitterContext, PerformanceManager performanceManager)
|
||||
{
|
||||
@@ -138,7 +138,7 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||
|
||||
if (supportsOptimizedPath && voiceState.BiquadFilters[0].Enable && voiceState.BiquadFilters[1].Enable)
|
||||
{
|
||||
Memory<byte> biquadStateRawMemory = SpanMemoryManager<byte>.Cast(state).Slice(VoiceUpdateState.BiquadStateOffset, VoiceUpdateState.BiquadStateSize * Constants.VoiceBiquadFilterCount);
|
||||
Memory<byte> biquadStateRawMemory = SpanMemoryManager<byte>.Cast(state)[..(VoiceUpdateState.BiquadStateSize * Constants.VoiceBiquadFilterCount)];
|
||||
Memory<BiquadFilterState> stateMemory = SpanMemoryManager<BiquadFilterState>.Cast(biquadStateRawMemory);
|
||||
|
||||
_commandBuffer.GenerateGroupedBiquadFilter(baseIndex, voiceState.BiquadFilters.AsSpan(), stateMemory, bufferOffset, bufferOffset, voiceState.BiquadFilterNeedInitialization, nodeId);
|
||||
@@ -151,7 +151,7 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||
|
||||
if (filter.Enable)
|
||||
{
|
||||
Memory<byte> biquadStateRawMemory = SpanMemoryManager<byte>.Cast(state).Slice(VoiceUpdateState.BiquadStateOffset, VoiceUpdateState.BiquadStateSize * Constants.VoiceBiquadFilterCount);
|
||||
Memory<byte> biquadStateRawMemory = SpanMemoryManager<byte>.Cast(state)[..(VoiceUpdateState.BiquadStateSize * Constants.VoiceBiquadFilterCount)];
|
||||
|
||||
Memory<BiquadFilterState> stateMemory = SpanMemoryManager<BiquadFilterState>.Cast(biquadStateRawMemory);
|
||||
|
||||
@@ -224,7 +224,7 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||
|
||||
bool performanceInitialized = false;
|
||||
|
||||
PerformanceEntryAddresses performanceEntry = new PerformanceEntryAddresses();
|
||||
PerformanceEntryAddresses performanceEntry = new();
|
||||
|
||||
if (_performanceManager != null && _performanceManager.IsTargetNodeId(nodeId) && _performanceManager.GetNextEntry(out performanceEntry, dataSourceDetailType, PerformanceEntryType.Voice, nodeId))
|
||||
{
|
||||
@@ -371,7 +371,7 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||
{
|
||||
int nodeId = sortedState.NodeId;
|
||||
|
||||
PerformanceEntryAddresses performanceEntry = new PerformanceEntryAddresses();
|
||||
PerformanceEntryAddresses performanceEntry = new();
|
||||
|
||||
bool performanceInitialized = false;
|
||||
|
||||
@@ -502,9 +502,11 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||
bool needInitialization = effect.Parameter.Status == UsageState.Invalid ||
|
||||
(effect.Parameter.Status == UsageState.New && !_rendererContext.BehaviourContext.IsBiquadFilterEffectStateClearBugFixed());
|
||||
|
||||
BiquadFilterParameter parameter = new BiquadFilterParameter();
|
||||
BiquadFilterParameter parameter = new()
|
||||
{
|
||||
Enable = true,
|
||||
};
|
||||
|
||||
parameter.Enable = true;
|
||||
effect.Parameter.Denominator.AsSpan().CopyTo(parameter.Denominator.AsSpan());
|
||||
effect.Parameter.Numerator.AsSpan().CopyTo(parameter.Numerator.AsSpan());
|
||||
|
||||
@@ -623,7 +625,7 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||
|
||||
bool isFinalMix = mix.MixId == Constants.FinalMixId;
|
||||
|
||||
PerformanceEntryAddresses performanceEntry = new PerformanceEntryAddresses();
|
||||
PerformanceEntryAddresses performanceEntry = new();
|
||||
|
||||
bool performanceInitialized = false;
|
||||
|
||||
@@ -789,7 +791,7 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||
|
||||
GenerateEffects(ref subMix);
|
||||
|
||||
PerformanceEntryAddresses performanceEntry = new PerformanceEntryAddresses();
|
||||
PerformanceEntryAddresses performanceEntry = new();
|
||||
|
||||
int nodeId = subMix.NodeId;
|
||||
|
||||
@@ -820,7 +822,7 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||
{
|
||||
int nodeId = sortedState.NodeId;
|
||||
|
||||
PerformanceEntryAddresses performanceEntry = new PerformanceEntryAddresses();
|
||||
PerformanceEntryAddresses performanceEntry = new();
|
||||
|
||||
bool performanceInitialized = false;
|
||||
|
||||
@@ -853,7 +855,7 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||
|
||||
GenerateEffects(ref finalMix);
|
||||
|
||||
PerformanceEntryAddresses performanceEntry = new PerformanceEntryAddresses();
|
||||
PerformanceEntryAddresses performanceEntry = new();
|
||||
|
||||
int nodeId = finalMix.NodeId;
|
||||
|
||||
@@ -901,7 +903,7 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||
{
|
||||
int nodeId = _mixContext.GetFinalState().NodeId;
|
||||
|
||||
PerformanceEntryAddresses performanceEntry = new PerformanceEntryAddresses();
|
||||
PerformanceEntryAddresses performanceEntry = new();
|
||||
|
||||
bool performanceInitialized = false;
|
||||
|
||||
@@ -977,7 +979,7 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||
{
|
||||
bool performanceInitialized = false;
|
||||
|
||||
PerformanceEntryAddresses performanceEntry = new PerformanceEntryAddresses();
|
||||
PerformanceEntryAddresses performanceEntry = new();
|
||||
|
||||
if (_performanceManager != null && _performanceManager.GetNextEntry(out performanceEntry, PerformanceEntryType.Sink, sink.NodeId))
|
||||
{
|
||||
@@ -1025,4 +1027,4 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,8 +8,8 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||
/// </summary>
|
||||
public class CommandProcessingTimeEstimatorVersion1 : ICommandProcessingTimeEstimator
|
||||
{
|
||||
private uint _sampleCount;
|
||||
private uint _bufferCount;
|
||||
private readonly uint _sampleCount;
|
||||
private readonly uint _bufferCount;
|
||||
|
||||
public CommandProcessingTimeEstimatorVersion1(uint sampleCount, uint bufferCount)
|
||||
{
|
||||
@@ -185,4 +185,4 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,8 +9,8 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||
/// </summary>
|
||||
public class CommandProcessingTimeEstimatorVersion2 : ICommandProcessingTimeEstimator
|
||||
{
|
||||
private uint _sampleCount;
|
||||
private uint _bufferCount;
|
||||
private readonly uint _sampleCount;
|
||||
private readonly uint _bufferCount;
|
||||
|
||||
public CommandProcessingTimeEstimatorVersion2(uint sampleCount, uint bufferCount)
|
||||
{
|
||||
@@ -189,71 +189,47 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||
{
|
||||
if (command.Enabled)
|
||||
{
|
||||
switch (command.Parameter.ChannelCount)
|
||||
return command.Parameter.ChannelCount switch
|
||||
{
|
||||
case 1:
|
||||
return (uint)41636.0f;
|
||||
case 2:
|
||||
return (uint)97861.0f;
|
||||
case 4:
|
||||
return (uint)192520.0f;
|
||||
case 6:
|
||||
return (uint)301760.0f;
|
||||
default:
|
||||
throw new NotImplementedException($"{command.Parameter.ChannelCount}");
|
||||
}
|
||||
1 => (uint)41636.0f,
|
||||
2 => (uint)97861.0f,
|
||||
4 => (uint)192520.0f,
|
||||
6 => (uint)301760.0f,
|
||||
_ => throw new NotImplementedException($"{command.Parameter.ChannelCount}"),
|
||||
};
|
||||
}
|
||||
else
|
||||
|
||||
return command.Parameter.ChannelCount switch
|
||||
{
|
||||
switch (command.Parameter.ChannelCount)
|
||||
{
|
||||
case 1:
|
||||
return (uint)578.53f;
|
||||
case 2:
|
||||
return (uint)663.06f;
|
||||
case 4:
|
||||
return (uint)703.98f;
|
||||
case 6:
|
||||
return (uint)760.03f;
|
||||
default:
|
||||
throw new NotImplementedException($"{command.Parameter.ChannelCount}");
|
||||
}
|
||||
}
|
||||
1 => (uint)578.53f,
|
||||
2 => (uint)663.06f,
|
||||
4 => (uint)703.98f,
|
||||
6 => (uint)760.03f,
|
||||
_ => throw new NotImplementedException($"{command.Parameter.ChannelCount}"),
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
if (command.Enabled)
|
||||
{
|
||||
switch (command.Parameter.ChannelCount)
|
||||
return command.Parameter.ChannelCount switch
|
||||
{
|
||||
case 1:
|
||||
return (uint)8770.3f;
|
||||
case 2:
|
||||
return (uint)25741.0f;
|
||||
case 4:
|
||||
return (uint)47551.0f;
|
||||
case 6:
|
||||
return (uint)81629.0f;
|
||||
default:
|
||||
throw new NotImplementedException($"{command.Parameter.ChannelCount}");
|
||||
}
|
||||
1 => (uint)8770.3f,
|
||||
2 => (uint)25741.0f,
|
||||
4 => (uint)47551.0f,
|
||||
6 => (uint)81629.0f,
|
||||
_ => throw new NotImplementedException($"{command.Parameter.ChannelCount}"),
|
||||
};
|
||||
}
|
||||
else
|
||||
|
||||
return command.Parameter.ChannelCount switch
|
||||
{
|
||||
switch (command.Parameter.ChannelCount)
|
||||
{
|
||||
case 1:
|
||||
return (uint)521.28f;
|
||||
case 2:
|
||||
return (uint)585.4f;
|
||||
case 4:
|
||||
return (uint)629.88f;
|
||||
case 6:
|
||||
return (uint)713.57f;
|
||||
default:
|
||||
throw new NotImplementedException($"{command.Parameter.ChannelCount}");
|
||||
}
|
||||
}
|
||||
1 => (uint)521.28f,
|
||||
2 => (uint)585.4f,
|
||||
4 => (uint)629.88f,
|
||||
6 => (uint)713.57f,
|
||||
_ => throw new NotImplementedException($"{command.Parameter.ChannelCount}"),
|
||||
};
|
||||
}
|
||||
|
||||
public uint Estimate(ReverbCommand command)
|
||||
@@ -264,71 +240,47 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||
{
|
||||
if (command.Enabled)
|
||||
{
|
||||
switch (command.Parameter.ChannelCount)
|
||||
return command.Parameter.ChannelCount switch
|
||||
{
|
||||
case 1:
|
||||
return (uint)97192.0f;
|
||||
case 2:
|
||||
return (uint)103280.0f;
|
||||
case 4:
|
||||
return (uint)109580.0f;
|
||||
case 6:
|
||||
return (uint)115070.0f;
|
||||
default:
|
||||
throw new NotImplementedException($"{command.Parameter.ChannelCount}");
|
||||
}
|
||||
1 => (uint)97192.0f,
|
||||
2 => (uint)103280.0f,
|
||||
4 => (uint)109580.0f,
|
||||
6 => (uint)115070.0f,
|
||||
_ => throw new NotImplementedException($"{command.Parameter.ChannelCount}"),
|
||||
};
|
||||
}
|
||||
else
|
||||
|
||||
return command.Parameter.ChannelCount switch
|
||||
{
|
||||
switch (command.Parameter.ChannelCount)
|
||||
{
|
||||
case 1:
|
||||
return (uint)492.01f;
|
||||
case 2:
|
||||
return (uint)554.46f;
|
||||
case 4:
|
||||
return (uint)595.86f;
|
||||
case 6:
|
||||
return (uint)656.62f;
|
||||
default:
|
||||
throw new NotImplementedException($"{command.Parameter.ChannelCount}");
|
||||
}
|
||||
}
|
||||
1 => (uint)492.01f,
|
||||
2 => (uint)554.46f,
|
||||
4 => (uint)595.86f,
|
||||
6 => (uint)656.62f,
|
||||
_ => throw new NotImplementedException($"{command.Parameter.ChannelCount}"),
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
if (command.Enabled)
|
||||
{
|
||||
switch (command.Parameter.ChannelCount)
|
||||
return command.Parameter.ChannelCount switch
|
||||
{
|
||||
case 1:
|
||||
return (uint)136460.0f;
|
||||
case 2:
|
||||
return (uint)145750.0f;
|
||||
case 4:
|
||||
return (uint)154800.0f;
|
||||
case 6:
|
||||
return (uint)161970.0f;
|
||||
default:
|
||||
throw new NotImplementedException($"{command.Parameter.ChannelCount}");
|
||||
}
|
||||
1 => (uint)136460.0f,
|
||||
2 => (uint)145750.0f,
|
||||
4 => (uint)154800.0f,
|
||||
6 => (uint)161970.0f,
|
||||
_ => throw new NotImplementedException($"{command.Parameter.ChannelCount}"),
|
||||
};
|
||||
}
|
||||
else
|
||||
|
||||
return command.Parameter.ChannelCount switch
|
||||
{
|
||||
switch (command.Parameter.ChannelCount)
|
||||
{
|
||||
case 1:
|
||||
return (uint)495.79f;
|
||||
case 2:
|
||||
return (uint)527.16f;
|
||||
case 4:
|
||||
return (uint)598.75f;
|
||||
case 6:
|
||||
return (uint)666.03f;
|
||||
default:
|
||||
throw new NotImplementedException($"{command.Parameter.ChannelCount}");
|
||||
}
|
||||
}
|
||||
1 => (uint)495.79f,
|
||||
2 => (uint)527.16f,
|
||||
4 => (uint)598.75f,
|
||||
6 => (uint)666.03f,
|
||||
_ => throw new NotImplementedException($"{command.Parameter.ChannelCount}"),
|
||||
};
|
||||
}
|
||||
|
||||
public uint Estimate(Reverb3dCommand command)
|
||||
@@ -339,70 +291,46 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||
{
|
||||
if (command.Enabled)
|
||||
{
|
||||
switch (command.Parameter.ChannelCount)
|
||||
return command.Parameter.ChannelCount switch
|
||||
{
|
||||
case 1:
|
||||
return (uint)138840.0f;
|
||||
case 2:
|
||||
return (uint)135430.0f;
|
||||
case 4:
|
||||
return (uint)199180.0f;
|
||||
case 6:
|
||||
return (uint)247350.0f;
|
||||
default:
|
||||
throw new NotImplementedException($"{command.Parameter.ChannelCount}");
|
||||
}
|
||||
1 => (uint)138840.0f,
|
||||
2 => (uint)135430.0f,
|
||||
4 => (uint)199180.0f,
|
||||
6 => (uint)247350.0f,
|
||||
_ => throw new NotImplementedException($"{command.Parameter.ChannelCount}"),
|
||||
};
|
||||
}
|
||||
else
|
||||
|
||||
return command.Parameter.ChannelCount switch
|
||||
{
|
||||
switch (command.Parameter.ChannelCount)
|
||||
{
|
||||
case 1:
|
||||
return (uint)718.7f;
|
||||
case 2:
|
||||
return (uint)751.3f;
|
||||
case 4:
|
||||
return (uint)797.46f;
|
||||
case 6:
|
||||
return (uint)867.43f;
|
||||
default:
|
||||
throw new NotImplementedException($"{command.Parameter.ChannelCount}");
|
||||
}
|
||||
}
|
||||
1 => (uint)718.7f,
|
||||
2 => (uint)751.3f,
|
||||
4 => (uint)797.46f,
|
||||
6 => (uint)867.43f,
|
||||
_ => throw new NotImplementedException($"{command.Parameter.ChannelCount}"),
|
||||
};
|
||||
}
|
||||
|
||||
if (command.Enabled)
|
||||
{
|
||||
switch (command.Parameter.ChannelCount)
|
||||
return command.Parameter.ChannelCount switch
|
||||
{
|
||||
case 1:
|
||||
return (uint)199950.0f;
|
||||
case 2:
|
||||
return (uint)195200.0f;
|
||||
case 4:
|
||||
return (uint)290580.0f;
|
||||
case 6:
|
||||
return (uint)363490.0f;
|
||||
default:
|
||||
throw new NotImplementedException($"{command.Parameter.ChannelCount}");
|
||||
}
|
||||
1 => (uint)199950.0f,
|
||||
2 => (uint)195200.0f,
|
||||
4 => (uint)290580.0f,
|
||||
6 => (uint)363490.0f,
|
||||
_ => throw new NotImplementedException($"{command.Parameter.ChannelCount}"),
|
||||
};
|
||||
}
|
||||
else
|
||||
|
||||
return command.Parameter.ChannelCount switch
|
||||
{
|
||||
switch (command.Parameter.ChannelCount)
|
||||
{
|
||||
case 1:
|
||||
return (uint)534.24f;
|
||||
case 2:
|
||||
return (uint)570.87f;
|
||||
case 4:
|
||||
return (uint)660.93f;
|
||||
case 6:
|
||||
return (uint)694.6f;
|
||||
default:
|
||||
throw new NotImplementedException($"{command.Parameter.ChannelCount}");
|
||||
}
|
||||
}
|
||||
1 => (uint)534.24f,
|
||||
2 => (uint)570.87f,
|
||||
4 => (uint)660.93f,
|
||||
6 => (uint)694.6f,
|
||||
_ => throw new NotImplementedException($"{command.Parameter.ChannelCount}"),
|
||||
};
|
||||
}
|
||||
|
||||
public uint Estimate(AuxiliaryBufferCommand command)
|
||||
|
||||
@@ -12,20 +12,20 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||
/// </summary>
|
||||
public class CommandProcessingTimeEstimatorVersion3 : ICommandProcessingTimeEstimator
|
||||
{
|
||||
protected uint _sampleCount;
|
||||
protected uint _bufferCount;
|
||||
protected uint SampleCount;
|
||||
protected uint BufferCount;
|
||||
|
||||
public CommandProcessingTimeEstimatorVersion3(uint sampleCount, uint bufferCount)
|
||||
{
|
||||
_sampleCount = sampleCount;
|
||||
_bufferCount = bufferCount;
|
||||
SampleCount = sampleCount;
|
||||
BufferCount = bufferCount;
|
||||
}
|
||||
|
||||
public uint Estimate(PerformanceCommand command)
|
||||
{
|
||||
Debug.Assert(_sampleCount == 160 || _sampleCount == 240);
|
||||
Debug.Assert(SampleCount == 160 || SampleCount == 240);
|
||||
|
||||
if (_sampleCount == 160)
|
||||
if (SampleCount == 160)
|
||||
{
|
||||
return (uint)498.17f;
|
||||
}
|
||||
@@ -35,24 +35,24 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||
|
||||
public uint Estimate(ClearMixBufferCommand command)
|
||||
{
|
||||
Debug.Assert(_sampleCount == 160 || _sampleCount == 240);
|
||||
Debug.Assert(SampleCount == 160 || SampleCount == 240);
|
||||
|
||||
float costPerBuffer = 440.68f;
|
||||
float baseCost = 0;
|
||||
|
||||
if (_sampleCount == 160)
|
||||
if (SampleCount == 160)
|
||||
{
|
||||
costPerBuffer = 266.65f;
|
||||
}
|
||||
|
||||
return (uint)(baseCost + costPerBuffer * _bufferCount);
|
||||
return (uint)(baseCost + costPerBuffer * BufferCount);
|
||||
}
|
||||
|
||||
public uint Estimate(BiquadFilterCommand command)
|
||||
{
|
||||
Debug.Assert(_sampleCount == 160 || _sampleCount == 240);
|
||||
Debug.Assert(SampleCount == 160 || SampleCount == 240);
|
||||
|
||||
if (_sampleCount == 160)
|
||||
if (SampleCount == 160)
|
||||
{
|
||||
return (uint)4173.2f;
|
||||
}
|
||||
@@ -64,9 +64,9 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||
{
|
||||
float costPerSample = 6.4434f;
|
||||
|
||||
Debug.Assert(_sampleCount == 160 || _sampleCount == 240);
|
||||
Debug.Assert(SampleCount == 160 || SampleCount == 240);
|
||||
|
||||
if (_sampleCount == 160)
|
||||
if (SampleCount == 160)
|
||||
{
|
||||
costPerSample = 6.708f;
|
||||
}
|
||||
@@ -81,14 +81,14 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||
}
|
||||
}
|
||||
|
||||
return (uint)(_sampleCount * costPerSample * volumeCount);
|
||||
return (uint)(SampleCount * costPerSample * volumeCount);
|
||||
}
|
||||
|
||||
public uint Estimate(MixRampCommand command)
|
||||
{
|
||||
Debug.Assert(_sampleCount == 160 || _sampleCount == 240);
|
||||
Debug.Assert(SampleCount == 160 || SampleCount == 240);
|
||||
|
||||
if (_sampleCount == 160)
|
||||
if (SampleCount == 160)
|
||||
{
|
||||
return (uint)1968.7f;
|
||||
}
|
||||
@@ -103,9 +103,9 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||
|
||||
public uint Estimate(VolumeRampCommand command)
|
||||
{
|
||||
Debug.Assert(_sampleCount == 160 || _sampleCount == 240);
|
||||
Debug.Assert(SampleCount == 160 || SampleCount == 240);
|
||||
|
||||
if (_sampleCount == 160)
|
||||
if (SampleCount == 160)
|
||||
{
|
||||
return (uint)1425.3f;
|
||||
}
|
||||
@@ -115,41 +115,41 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||
|
||||
public uint Estimate(PcmInt16DataSourceCommandVersion1 command)
|
||||
{
|
||||
Debug.Assert(_sampleCount == 160 || _sampleCount == 240);
|
||||
Debug.Assert(SampleCount == 160 || SampleCount == 240);
|
||||
|
||||
float costPerSample = 710.143f;
|
||||
float baseCost = 7853.286f;
|
||||
|
||||
if (_sampleCount == 160)
|
||||
if (SampleCount == 160)
|
||||
{
|
||||
costPerSample = 427.52f;
|
||||
baseCost = 6329.442f;
|
||||
}
|
||||
|
||||
return (uint)(baseCost + (costPerSample * (((command.SampleRate / 200.0f) / _sampleCount) * (command.Pitch * 0.000030518f))));
|
||||
return (uint)(baseCost + (costPerSample * (((command.SampleRate / 200.0f) / SampleCount) * (command.Pitch * 0.000030518f))));
|
||||
}
|
||||
|
||||
public uint Estimate(AdpcmDataSourceCommandVersion1 command)
|
||||
{
|
||||
Debug.Assert(_sampleCount == 160 || _sampleCount == 240);
|
||||
Debug.Assert(SampleCount == 160 || SampleCount == 240);
|
||||
|
||||
float costPerSample = 3564.1f;
|
||||
float baseCost = 9736.702f;
|
||||
|
||||
if (_sampleCount == 160)
|
||||
if (SampleCount == 160)
|
||||
{
|
||||
costPerSample = 2125.6f;
|
||||
baseCost = 7913.808f;
|
||||
}
|
||||
|
||||
return (uint)(baseCost + (costPerSample * (((command.SampleRate / 200.0f) / _sampleCount) * (command.Pitch * 0.000030518f))));
|
||||
return (uint)(baseCost + (costPerSample * (((command.SampleRate / 200.0f) / SampleCount) * (command.Pitch * 0.000030518f))));
|
||||
}
|
||||
|
||||
public uint Estimate(DepopForMixBuffersCommand command)
|
||||
{
|
||||
Debug.Assert(_sampleCount == 160 || _sampleCount == 240);
|
||||
Debug.Assert(SampleCount == 160 || SampleCount == 240);
|
||||
|
||||
if (_sampleCount == 160)
|
||||
if (SampleCount == 160)
|
||||
{
|
||||
return (uint)739.64f;
|
||||
}
|
||||
@@ -159,9 +159,9 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||
|
||||
public uint Estimate(CopyMixBufferCommand command)
|
||||
{
|
||||
Debug.Assert(_sampleCount == 160 || _sampleCount == 240);
|
||||
Debug.Assert(SampleCount == 160 || SampleCount == 240);
|
||||
|
||||
if (_sampleCount == 160)
|
||||
if (SampleCount == 160)
|
||||
{
|
||||
return (uint)842.59f;
|
||||
}
|
||||
@@ -171,9 +171,9 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||
|
||||
public uint Estimate(MixCommand command)
|
||||
{
|
||||
Debug.Assert(_sampleCount == 160 || _sampleCount == 240);
|
||||
Debug.Assert(SampleCount == 160 || SampleCount == 240);
|
||||
|
||||
if (_sampleCount == 160)
|
||||
if (SampleCount == 160)
|
||||
{
|
||||
return (uint)1402.8f;
|
||||
}
|
||||
@@ -183,231 +183,159 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||
|
||||
public virtual uint Estimate(DelayCommand command)
|
||||
{
|
||||
Debug.Assert(_sampleCount == 160 || _sampleCount == 240);
|
||||
Debug.Assert(SampleCount == 160 || SampleCount == 240);
|
||||
|
||||
if (_sampleCount == 160)
|
||||
if (SampleCount == 160)
|
||||
{
|
||||
if (command.Enabled)
|
||||
{
|
||||
switch (command.Parameter.ChannelCount)
|
||||
return command.Parameter.ChannelCount switch
|
||||
{
|
||||
case 1:
|
||||
return (uint)8929.04f;
|
||||
case 2:
|
||||
return (uint)25500.75f;
|
||||
case 4:
|
||||
return (uint)47759.62f;
|
||||
case 6:
|
||||
return (uint)82203.07f;
|
||||
default:
|
||||
throw new NotImplementedException($"{command.Parameter.ChannelCount}");
|
||||
}
|
||||
1 => (uint)8929.04f,
|
||||
2 => (uint)25500.75f,
|
||||
4 => (uint)47759.62f,
|
||||
6 => (uint)82203.07f,
|
||||
_ => throw new NotImplementedException($"{command.Parameter.ChannelCount}"),
|
||||
};
|
||||
}
|
||||
else
|
||||
|
||||
return command.Parameter.ChannelCount switch
|
||||
{
|
||||
switch (command.Parameter.ChannelCount)
|
||||
{
|
||||
case 1:
|
||||
return (uint)1295.20f;
|
||||
case 2:
|
||||
return (uint)1213.60f;
|
||||
case 4:
|
||||
return (uint)942.03f;
|
||||
case 6:
|
||||
return (uint)1001.55f;
|
||||
default:
|
||||
throw new NotImplementedException($"{command.Parameter.ChannelCount}");
|
||||
}
|
||||
}
|
||||
1 => (uint)1295.20f,
|
||||
2 => (uint)1213.60f,
|
||||
4 => (uint)942.03f,
|
||||
6 => (uint)1001.55f,
|
||||
_ => throw new NotImplementedException($"{command.Parameter.ChannelCount}"),
|
||||
};
|
||||
}
|
||||
|
||||
if (command.Enabled)
|
||||
{
|
||||
switch (command.Parameter.ChannelCount)
|
||||
return command.Parameter.ChannelCount switch
|
||||
{
|
||||
case 1:
|
||||
return (uint)11941.05f;
|
||||
case 2:
|
||||
return (uint)37197.37f;
|
||||
case 4:
|
||||
return (uint)69749.84f;
|
||||
case 6:
|
||||
return (uint)120042.40f;
|
||||
default:
|
||||
throw new NotImplementedException($"{command.Parameter.ChannelCount}");
|
||||
}
|
||||
1 => (uint)11941.05f,
|
||||
2 => (uint)37197.37f,
|
||||
4 => (uint)69749.84f,
|
||||
6 => (uint)120042.40f,
|
||||
_ => throw new NotImplementedException($"{command.Parameter.ChannelCount}"),
|
||||
};
|
||||
}
|
||||
else
|
||||
|
||||
return command.Parameter.ChannelCount switch
|
||||
{
|
||||
switch (command.Parameter.ChannelCount)
|
||||
{
|
||||
case 1:
|
||||
return (uint)997.67f;
|
||||
case 2:
|
||||
return (uint)977.63f;
|
||||
case 4:
|
||||
return (uint)792.30f;
|
||||
case 6:
|
||||
return (uint)875.43f;
|
||||
default:
|
||||
throw new NotImplementedException($"{command.Parameter.ChannelCount}");
|
||||
}
|
||||
}
|
||||
1 => (uint)997.67f,
|
||||
2 => (uint)977.63f,
|
||||
4 => (uint)792.30f,
|
||||
6 => (uint)875.43f,
|
||||
_ => throw new NotImplementedException($"{command.Parameter.ChannelCount}"),
|
||||
};
|
||||
}
|
||||
|
||||
public virtual uint Estimate(ReverbCommand command)
|
||||
{
|
||||
Debug.Assert(_sampleCount == 160 || _sampleCount == 240);
|
||||
Debug.Assert(SampleCount == 160 || SampleCount == 240);
|
||||
|
||||
if (_sampleCount == 160)
|
||||
if (SampleCount == 160)
|
||||
{
|
||||
if (command.Enabled)
|
||||
{
|
||||
switch (command.Parameter.ChannelCount)
|
||||
return command.Parameter.ChannelCount switch
|
||||
{
|
||||
case 1:
|
||||
return (uint)81475.05f;
|
||||
case 2:
|
||||
return (uint)84975.0f;
|
||||
case 4:
|
||||
return (uint)91625.15f;
|
||||
case 6:
|
||||
return (uint)95332.27f;
|
||||
default:
|
||||
throw new NotImplementedException($"{command.Parameter.ChannelCount}");
|
||||
}
|
||||
1 => (uint)81475.05f,
|
||||
2 => (uint)84975.0f,
|
||||
4 => (uint)91625.15f,
|
||||
6 => (uint)95332.27f,
|
||||
_ => throw new NotImplementedException($"{command.Parameter.ChannelCount}"),
|
||||
};
|
||||
}
|
||||
else
|
||||
|
||||
return command.Parameter.ChannelCount switch
|
||||
{
|
||||
switch (command.Parameter.ChannelCount)
|
||||
{
|
||||
case 1:
|
||||
return (uint)536.30f;
|
||||
case 2:
|
||||
return (uint)588.70f;
|
||||
case 4:
|
||||
return (uint)643.70f;
|
||||
case 6:
|
||||
return (uint)706.0f;
|
||||
default:
|
||||
throw new NotImplementedException($"{command.Parameter.ChannelCount}");
|
||||
}
|
||||
}
|
||||
1 => (uint)536.30f,
|
||||
2 => (uint)588.70f,
|
||||
4 => (uint)643.70f,
|
||||
6 => (uint)706.0f,
|
||||
_ => throw new NotImplementedException($"{command.Parameter.ChannelCount}"),
|
||||
};
|
||||
}
|
||||
|
||||
if (command.Enabled)
|
||||
{
|
||||
switch (command.Parameter.ChannelCount)
|
||||
return command.Parameter.ChannelCount switch
|
||||
{
|
||||
case 1:
|
||||
return (uint)120174.47f;
|
||||
case 2:
|
||||
return (uint)25262.22f;
|
||||
case 4:
|
||||
return (uint)135751.23f;
|
||||
case 6:
|
||||
return (uint)141129.23f;
|
||||
default:
|
||||
throw new NotImplementedException($"{command.Parameter.ChannelCount}");
|
||||
}
|
||||
1 => (uint)120174.47f,
|
||||
2 => (uint)25262.22f,
|
||||
4 => (uint)135751.23f,
|
||||
6 => (uint)141129.23f,
|
||||
_ => throw new NotImplementedException($"{command.Parameter.ChannelCount}"),
|
||||
};
|
||||
}
|
||||
else
|
||||
|
||||
return command.Parameter.ChannelCount switch
|
||||
{
|
||||
switch (command.Parameter.ChannelCount)
|
||||
{
|
||||
case 1:
|
||||
return (uint)617.64f;
|
||||
case 2:
|
||||
return (uint)659.54f;
|
||||
case 4:
|
||||
return (uint)711.43f;
|
||||
case 6:
|
||||
return (uint)778.07f;
|
||||
default:
|
||||
throw new NotImplementedException($"{command.Parameter.ChannelCount}");
|
||||
}
|
||||
}
|
||||
1 => (uint)617.64f,
|
||||
2 => (uint)659.54f,
|
||||
4 => (uint)711.43f,
|
||||
6 => (uint)778.07f,
|
||||
_ => throw new NotImplementedException($"{command.Parameter.ChannelCount}"),
|
||||
};
|
||||
}
|
||||
|
||||
public virtual uint Estimate(Reverb3dCommand command)
|
||||
{
|
||||
Debug.Assert(_sampleCount == 160 || _sampleCount == 240);
|
||||
Debug.Assert(SampleCount == 160 || SampleCount == 240);
|
||||
|
||||
if (_sampleCount == 160)
|
||||
if (SampleCount == 160)
|
||||
{
|
||||
if (command.Enabled)
|
||||
{
|
||||
switch (command.Parameter.ChannelCount)
|
||||
return command.Parameter.ChannelCount switch
|
||||
{
|
||||
case 1:
|
||||
return (uint)116754.0f;
|
||||
case 2:
|
||||
return (uint)125912.05f;
|
||||
case 4:
|
||||
return (uint)146336.03f;
|
||||
case 6:
|
||||
return (uint)165812.66f;
|
||||
default:
|
||||
throw new NotImplementedException($"{command.Parameter.ChannelCount}");
|
||||
}
|
||||
1 => (uint)116754.0f,
|
||||
2 => (uint)125912.05f,
|
||||
4 => (uint)146336.03f,
|
||||
6 => (uint)165812.66f,
|
||||
_ => throw new NotImplementedException($"{command.Parameter.ChannelCount}"),
|
||||
};
|
||||
}
|
||||
else
|
||||
|
||||
return command.Parameter.ChannelCount switch
|
||||
{
|
||||
switch (command.Parameter.ChannelCount)
|
||||
{
|
||||
case 1:
|
||||
return (uint)734.0f;
|
||||
case 2:
|
||||
return (uint)766.62f;
|
||||
case 4:
|
||||
return (uint)797.46f;
|
||||
case 6:
|
||||
return (uint)867.43f;
|
||||
default:
|
||||
throw new NotImplementedException($"{command.Parameter.ChannelCount}");
|
||||
}
|
||||
}
|
||||
1 => (uint)734.0f,
|
||||
2 => (uint)766.62f,
|
||||
4 => (uint)797.46f,
|
||||
6 => (uint)867.43f,
|
||||
_ => throw new NotImplementedException($"{command.Parameter.ChannelCount}"),
|
||||
};
|
||||
}
|
||||
|
||||
if (command.Enabled)
|
||||
{
|
||||
switch (command.Parameter.ChannelCount)
|
||||
return command.Parameter.ChannelCount switch
|
||||
{
|
||||
case 1:
|
||||
return (uint)170292.34f;
|
||||
case 2:
|
||||
return (uint)183875.63f;
|
||||
case 4:
|
||||
return (uint)214696.19f;
|
||||
case 6:
|
||||
return (uint)243846.77f;
|
||||
default:
|
||||
throw new NotImplementedException($"{command.Parameter.ChannelCount}");
|
||||
}
|
||||
1 => (uint)170292.34f,
|
||||
2 => (uint)183875.63f,
|
||||
4 => (uint)214696.19f,
|
||||
6 => (uint)243846.77f,
|
||||
_ => throw new NotImplementedException($"{command.Parameter.ChannelCount}"),
|
||||
};
|
||||
}
|
||||
else
|
||||
|
||||
return command.Parameter.ChannelCount switch
|
||||
{
|
||||
switch (command.Parameter.ChannelCount)
|
||||
{
|
||||
case 1:
|
||||
return (uint)508.47f;
|
||||
case 2:
|
||||
return (uint)582.45f;
|
||||
case 4:
|
||||
return (uint)626.42f;
|
||||
case 6:
|
||||
return (uint)682.47f;
|
||||
default:
|
||||
throw new NotImplementedException($"{command.Parameter.ChannelCount}");
|
||||
}
|
||||
}
|
||||
1 => (uint)508.47f,
|
||||
2 => (uint)582.45f,
|
||||
4 => (uint)626.42f,
|
||||
6 => (uint)682.47f,
|
||||
_ => throw new NotImplementedException($"{command.Parameter.ChannelCount}"),
|
||||
};
|
||||
}
|
||||
|
||||
public uint Estimate(AuxiliaryBufferCommand command)
|
||||
{
|
||||
Debug.Assert(_sampleCount == 160 || _sampleCount == 240);
|
||||
Debug.Assert(SampleCount == 160 || SampleCount == 240);
|
||||
|
||||
if (_sampleCount == 160)
|
||||
if (SampleCount == 160)
|
||||
{
|
||||
if (command.Enabled)
|
||||
{
|
||||
@@ -427,9 +355,9 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||
|
||||
public uint Estimate(VolumeCommand command)
|
||||
{
|
||||
Debug.Assert(_sampleCount == 160 || _sampleCount == 240);
|
||||
Debug.Assert(SampleCount == 160 || SampleCount == 240);
|
||||
|
||||
if (_sampleCount == 160)
|
||||
if (SampleCount == 160)
|
||||
{
|
||||
return (uint)1311.1f;
|
||||
}
|
||||
@@ -439,12 +367,12 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||
|
||||
public uint Estimate(CircularBufferSinkCommand command)
|
||||
{
|
||||
Debug.Assert(_sampleCount == 160 || _sampleCount == 240);
|
||||
Debug.Assert(SampleCount == 160 || SampleCount == 240);
|
||||
|
||||
float costPerBuffer = 770.26f;
|
||||
float baseCost = 0f;
|
||||
|
||||
if (_sampleCount == 160)
|
||||
if (SampleCount == 160)
|
||||
{
|
||||
costPerBuffer = 531.07f;
|
||||
}
|
||||
@@ -454,9 +382,9 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||
|
||||
public uint Estimate(DownMixSurroundToStereoCommand command)
|
||||
{
|
||||
Debug.Assert(_sampleCount == 160 || _sampleCount == 240);
|
||||
Debug.Assert(SampleCount == 160 || SampleCount == 240);
|
||||
|
||||
if (_sampleCount == 160)
|
||||
if (SampleCount == 160)
|
||||
{
|
||||
return (uint)9949.7f;
|
||||
}
|
||||
@@ -466,9 +394,9 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||
|
||||
public uint Estimate(UpsampleCommand command)
|
||||
{
|
||||
Debug.Assert(_sampleCount == 160 || _sampleCount == 240);
|
||||
Debug.Assert(SampleCount == 160 || SampleCount == 240);
|
||||
|
||||
if (_sampleCount == 160)
|
||||
if (SampleCount == 160)
|
||||
{
|
||||
return (uint)312990.0f;
|
||||
}
|
||||
@@ -478,12 +406,12 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||
|
||||
public uint Estimate(DeviceSinkCommand command)
|
||||
{
|
||||
Debug.Assert(_sampleCount == 160 || _sampleCount == 240);
|
||||
Debug.Assert(SampleCount == 160 || SampleCount == 240);
|
||||
Debug.Assert(command.InputCount == 2 || command.InputCount == 6);
|
||||
|
||||
if (command.InputCount == 2)
|
||||
{
|
||||
if (_sampleCount == 160)
|
||||
if (SampleCount == 160)
|
||||
{
|
||||
return (uint)8980.0f;
|
||||
}
|
||||
@@ -491,7 +419,7 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||
return (uint)9221.9f;
|
||||
}
|
||||
|
||||
if (_sampleCount == 160)
|
||||
if (SampleCount == 160)
|
||||
{
|
||||
return (uint)9177.9f;
|
||||
}
|
||||
@@ -501,27 +429,27 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||
|
||||
public uint Estimate(PcmFloatDataSourceCommandVersion1 command)
|
||||
{
|
||||
Debug.Assert(_sampleCount == 160 || _sampleCount == 240);
|
||||
Debug.Assert(SampleCount == 160 || SampleCount == 240);
|
||||
|
||||
float costPerSample = 3490.9f;
|
||||
float baseCost = 10090.9f;
|
||||
|
||||
if (_sampleCount == 160)
|
||||
if (SampleCount == 160)
|
||||
{
|
||||
costPerSample = 2310.4f;
|
||||
baseCost = 7845.25f;
|
||||
}
|
||||
|
||||
return (uint)(baseCost + (costPerSample * (((command.SampleRate / 200.0f) / _sampleCount) * (command.Pitch * 0.000030518f))));
|
||||
return (uint)(baseCost + (costPerSample * (((command.SampleRate / 200.0f) / SampleCount) * (command.Pitch * 0.000030518f))));
|
||||
}
|
||||
|
||||
public uint Estimate(DataSourceVersion2Command command)
|
||||
{
|
||||
Debug.Assert(_sampleCount == 160 || _sampleCount == 240);
|
||||
Debug.Assert(SampleCount == 160 || SampleCount == 240);
|
||||
|
||||
(float baseCost, float costPerSample) = GetCostByFormat(_sampleCount, command.SampleFormat, command.SrcQuality);
|
||||
(float baseCost, float costPerSample) = GetCostByFormat(SampleCount, command.SampleFormat, command.SrcQuality);
|
||||
|
||||
return (uint)(baseCost + (costPerSample * (((command.SampleRate / 200.0f) / _sampleCount) * (command.Pitch * 0.000030518f) - 1.0f)));
|
||||
return (uint)(baseCost + (costPerSample * (((command.SampleRate / 200.0f) / SampleCount) * (command.Pitch * 0.000030518f) - 1.0f)));
|
||||
}
|
||||
|
||||
private static (float, float) GetCostByFormat(uint sampleCount, SampleFormat format, SampleRateConversionQuality quality)
|
||||
@@ -618,124 +546,90 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||
|
||||
private uint EstimateLimiterCommandCommon(LimiterParameter parameter, bool enabled)
|
||||
{
|
||||
Debug.Assert(_sampleCount == 160 || _sampleCount == 240);
|
||||
Debug.Assert(SampleCount == 160 || SampleCount == 240);
|
||||
|
||||
if (_sampleCount == 160)
|
||||
if (SampleCount == 160)
|
||||
{
|
||||
if (enabled)
|
||||
{
|
||||
switch (parameter.ChannelCount)
|
||||
return parameter.ChannelCount switch
|
||||
{
|
||||
case 1:
|
||||
return (uint)21392.0f;
|
||||
case 2:
|
||||
return (uint)26829.0f;
|
||||
case 4:
|
||||
return (uint)32405.0f;
|
||||
case 6:
|
||||
return (uint)52219.0f;
|
||||
default:
|
||||
throw new NotImplementedException($"{parameter.ChannelCount}");
|
||||
}
|
||||
1 => (uint)21392.0f,
|
||||
2 => (uint)26829.0f,
|
||||
4 => (uint)32405.0f,
|
||||
6 => (uint)52219.0f,
|
||||
_ => throw new NotImplementedException($"{parameter.ChannelCount}"),
|
||||
};
|
||||
}
|
||||
else
|
||||
|
||||
return parameter.ChannelCount switch
|
||||
{
|
||||
switch (parameter.ChannelCount)
|
||||
{
|
||||
case 1:
|
||||
return (uint)897.0f;
|
||||
case 2:
|
||||
return (uint)931.55f;
|
||||
case 4:
|
||||
return (uint)975.39f;
|
||||
case 6:
|
||||
return (uint)1016.8f;
|
||||
default:
|
||||
throw new NotImplementedException($"{parameter.ChannelCount}");
|
||||
}
|
||||
}
|
||||
1 => (uint)897.0f,
|
||||
2 => (uint)931.55f,
|
||||
4 => (uint)975.39f,
|
||||
6 => (uint)1016.8f,
|
||||
_ => throw new NotImplementedException($"{parameter.ChannelCount}"),
|
||||
};
|
||||
}
|
||||
|
||||
if (enabled)
|
||||
{
|
||||
switch (parameter.ChannelCount)
|
||||
return parameter.ChannelCount switch
|
||||
{
|
||||
case 1:
|
||||
return (uint)30556.0f;
|
||||
case 2:
|
||||
return (uint)39011.0f;
|
||||
case 4:
|
||||
return (uint)48270.0f;
|
||||
case 6:
|
||||
return (uint)76712.0f;
|
||||
default:
|
||||
throw new NotImplementedException($"{parameter.ChannelCount}");
|
||||
}
|
||||
1 => (uint)30556.0f,
|
||||
2 => (uint)39011.0f,
|
||||
4 => (uint)48270.0f,
|
||||
6 => (uint)76712.0f,
|
||||
_ => throw new NotImplementedException($"{parameter.ChannelCount}"),
|
||||
};
|
||||
}
|
||||
else
|
||||
|
||||
return parameter.ChannelCount switch
|
||||
{
|
||||
switch (parameter.ChannelCount)
|
||||
{
|
||||
case 1:
|
||||
return (uint)874.43f;
|
||||
case 2:
|
||||
return (uint)921.55f;
|
||||
case 4:
|
||||
return (uint)945.26f;
|
||||
case 6:
|
||||
return (uint)992.26f;
|
||||
default:
|
||||
throw new NotImplementedException($"{parameter.ChannelCount}");
|
||||
}
|
||||
}
|
||||
1 => (uint)874.43f,
|
||||
2 => (uint)921.55f,
|
||||
4 => (uint)945.26f,
|
||||
6 => (uint)992.26f,
|
||||
_ => throw new NotImplementedException($"{parameter.ChannelCount}"),
|
||||
};
|
||||
}
|
||||
|
||||
public uint Estimate(LimiterCommandVersion1 command)
|
||||
{
|
||||
Debug.Assert(_sampleCount == 160 || _sampleCount == 240);
|
||||
Debug.Assert(SampleCount == 160 || SampleCount == 240);
|
||||
|
||||
return EstimateLimiterCommandCommon(command.Parameter, command.IsEffectEnabled);
|
||||
}
|
||||
|
||||
public uint Estimate(LimiterCommandVersion2 command)
|
||||
{
|
||||
Debug.Assert(_sampleCount == 160 || _sampleCount == 240);
|
||||
Debug.Assert(SampleCount == 160 || SampleCount == 240);
|
||||
|
||||
if (!command.Parameter.StatisticsEnabled || !command.IsEffectEnabled)
|
||||
{
|
||||
return EstimateLimiterCommandCommon(command.Parameter, command.IsEffectEnabled);
|
||||
}
|
||||
|
||||
if (_sampleCount == 160)
|
||||
if (SampleCount == 160)
|
||||
{
|
||||
switch (command.Parameter.ChannelCount)
|
||||
return command.Parameter.ChannelCount switch
|
||||
{
|
||||
case 1:
|
||||
return (uint)23309.0f;
|
||||
case 2:
|
||||
return (uint)29954.0f;
|
||||
case 4:
|
||||
return (uint)35807.0f;
|
||||
case 6:
|
||||
return (uint)58340.0f;
|
||||
default:
|
||||
throw new NotImplementedException($"{command.Parameter.ChannelCount}");
|
||||
}
|
||||
1 => (uint)23309.0f,
|
||||
2 => (uint)29954.0f,
|
||||
4 => (uint)35807.0f,
|
||||
6 => (uint)58340.0f,
|
||||
_ => throw new NotImplementedException($"{command.Parameter.ChannelCount}"),
|
||||
};
|
||||
}
|
||||
|
||||
switch (command.Parameter.ChannelCount)
|
||||
return command.Parameter.ChannelCount switch
|
||||
{
|
||||
case 1:
|
||||
return (uint)33526.0f;
|
||||
case 2:
|
||||
return (uint)43549.0f;
|
||||
case 4:
|
||||
return (uint)52190.0f;
|
||||
case 6:
|
||||
return (uint)85527.0f;
|
||||
default:
|
||||
throw new NotImplementedException($"{command.Parameter.ChannelCount}");
|
||||
}
|
||||
1 => (uint)33526.0f,
|
||||
2 => (uint)43549.0f,
|
||||
4 => (uint)52190.0f,
|
||||
6 => (uint)85527.0f,
|
||||
_ => throw new NotImplementedException($"{command.Parameter.ChannelCount}"),
|
||||
};
|
||||
}
|
||||
|
||||
public virtual uint Estimate(GroupedBiquadFilterCommand command)
|
||||
@@ -753,4 +647,4 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,9 +12,9 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||
|
||||
public override uint Estimate(GroupedBiquadFilterCommand command)
|
||||
{
|
||||
Debug.Assert(_sampleCount == 160 || _sampleCount == 240);
|
||||
Debug.Assert(SampleCount == 160 || SampleCount == 240);
|
||||
|
||||
if (_sampleCount == 160)
|
||||
if (SampleCount == 160)
|
||||
{
|
||||
return (uint)7424.5f;
|
||||
}
|
||||
@@ -24,9 +24,9 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||
|
||||
public override uint Estimate(CaptureBufferCommand command)
|
||||
{
|
||||
Debug.Assert(_sampleCount == 160 || _sampleCount == 240);
|
||||
Debug.Assert(SampleCount == 160 || SampleCount == 240);
|
||||
|
||||
if (_sampleCount == 160)
|
||||
if (SampleCount == 160)
|
||||
{
|
||||
if (command.Enabled)
|
||||
{
|
||||
@@ -44,4 +44,4 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||
return (uint)435.2f;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,298 +13,202 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||
|
||||
public override uint Estimate(DelayCommand command)
|
||||
{
|
||||
Debug.Assert(_sampleCount == 160 || _sampleCount == 240);
|
||||
Debug.Assert(SampleCount == 160 || SampleCount == 240);
|
||||
|
||||
if (_sampleCount == 160)
|
||||
if (SampleCount == 160)
|
||||
{
|
||||
if (command.Enabled)
|
||||
{
|
||||
switch (command.Parameter.ChannelCount)
|
||||
return command.Parameter.ChannelCount switch
|
||||
{
|
||||
case 1:
|
||||
return 8929;
|
||||
case 2:
|
||||
return 25501;
|
||||
case 4:
|
||||
return 47760;
|
||||
case 6:
|
||||
return 82203;
|
||||
default:
|
||||
throw new NotImplementedException($"{command.Parameter.ChannelCount}");
|
||||
}
|
||||
1 => 8929,
|
||||
2 => 25501,
|
||||
4 => 47760,
|
||||
6 => 82203,
|
||||
_ => throw new NotImplementedException($"{command.Parameter.ChannelCount}"),
|
||||
};
|
||||
}
|
||||
else
|
||||
|
||||
return command.Parameter.ChannelCount switch
|
||||
{
|
||||
switch (command.Parameter.ChannelCount)
|
||||
{
|
||||
case 1:
|
||||
return (uint)1295.20f;
|
||||
case 2:
|
||||
return (uint)1213.60f;
|
||||
case 4:
|
||||
return (uint)942.03f;
|
||||
case 6:
|
||||
return (uint)1001.6f;
|
||||
default:
|
||||
throw new NotImplementedException($"{command.Parameter.ChannelCount}");
|
||||
}
|
||||
}
|
||||
1 => (uint)1295.20f,
|
||||
2 => (uint)1213.60f,
|
||||
4 => (uint)942.03f,
|
||||
6 => (uint)1001.6f,
|
||||
_ => throw new NotImplementedException($"{command.Parameter.ChannelCount}"),
|
||||
};
|
||||
}
|
||||
|
||||
if (command.Enabled)
|
||||
{
|
||||
switch (command.Parameter.ChannelCount)
|
||||
return command.Parameter.ChannelCount switch
|
||||
{
|
||||
case 1:
|
||||
return 11941;
|
||||
case 2:
|
||||
return 37197;
|
||||
case 4:
|
||||
return 69750;
|
||||
case 6:
|
||||
return 12004;
|
||||
default:
|
||||
throw new NotImplementedException($"{command.Parameter.ChannelCount}");
|
||||
}
|
||||
1 => 11941,
|
||||
2 => 37197,
|
||||
4 => 69750,
|
||||
6 => 12004,
|
||||
_ => throw new NotImplementedException($"{command.Parameter.ChannelCount}"),
|
||||
};
|
||||
}
|
||||
else
|
||||
|
||||
return command.Parameter.ChannelCount switch
|
||||
{
|
||||
switch (command.Parameter.ChannelCount)
|
||||
{
|
||||
case 1:
|
||||
return (uint)997.67f;
|
||||
case 2:
|
||||
return (uint)977.63f;
|
||||
case 4:
|
||||
return (uint)792.31f;
|
||||
case 6:
|
||||
return (uint)875.43f;
|
||||
default:
|
||||
throw new NotImplementedException($"{command.Parameter.ChannelCount}");
|
||||
}
|
||||
}
|
||||
1 => (uint)997.67f,
|
||||
2 => (uint)977.63f,
|
||||
4 => (uint)792.31f,
|
||||
6 => (uint)875.43f,
|
||||
_ => throw new NotImplementedException($"{command.Parameter.ChannelCount}"),
|
||||
};
|
||||
}
|
||||
|
||||
public override uint Estimate(ReverbCommand command)
|
||||
{
|
||||
Debug.Assert(_sampleCount == 160 || _sampleCount == 240);
|
||||
Debug.Assert(SampleCount == 160 || SampleCount == 240);
|
||||
|
||||
if (_sampleCount == 160)
|
||||
if (SampleCount == 160)
|
||||
{
|
||||
if (command.Enabled)
|
||||
{
|
||||
switch (command.Parameter.ChannelCount)
|
||||
return command.Parameter.ChannelCount switch
|
||||
{
|
||||
case 1:
|
||||
return 81475;
|
||||
case 2:
|
||||
return 84975;
|
||||
case 4:
|
||||
return 91625;
|
||||
case 6:
|
||||
return 95332;
|
||||
default:
|
||||
throw new NotImplementedException($"{command.Parameter.ChannelCount}");
|
||||
}
|
||||
1 => 81475,
|
||||
2 => 84975,
|
||||
4 => 91625,
|
||||
6 => 95332,
|
||||
_ => throw new NotImplementedException($"{command.Parameter.ChannelCount}"),
|
||||
};
|
||||
}
|
||||
else
|
||||
|
||||
return command.Parameter.ChannelCount switch
|
||||
{
|
||||
switch (command.Parameter.ChannelCount)
|
||||
{
|
||||
case 1:
|
||||
return (uint)536.30f;
|
||||
case 2:
|
||||
return (uint)588.80f;
|
||||
case 4:
|
||||
return (uint)643.70f;
|
||||
case 6:
|
||||
return (uint)706.0f;
|
||||
default:
|
||||
throw new NotImplementedException($"{command.Parameter.ChannelCount}");
|
||||
}
|
||||
}
|
||||
1 => (uint)536.30f,
|
||||
2 => (uint)588.80f,
|
||||
4 => (uint)643.70f,
|
||||
6 => (uint)706.0f,
|
||||
_ => throw new NotImplementedException($"{command.Parameter.ChannelCount}"),
|
||||
};
|
||||
}
|
||||
|
||||
if (command.Enabled)
|
||||
{
|
||||
switch (command.Parameter.ChannelCount)
|
||||
return command.Parameter.ChannelCount switch
|
||||
{
|
||||
case 1:
|
||||
return 120170;
|
||||
case 2:
|
||||
return 125260;
|
||||
case 4:
|
||||
return 135750;
|
||||
case 6:
|
||||
return 141130;
|
||||
default:
|
||||
throw new NotImplementedException($"{command.Parameter.ChannelCount}");
|
||||
}
|
||||
1 => 120170,
|
||||
2 => 125260,
|
||||
4 => 135750,
|
||||
6 => 141130,
|
||||
_ => throw new NotImplementedException($"{command.Parameter.ChannelCount}"),
|
||||
};
|
||||
}
|
||||
else
|
||||
|
||||
return command.Parameter.ChannelCount switch
|
||||
{
|
||||
switch (command.Parameter.ChannelCount)
|
||||
{
|
||||
case 1:
|
||||
return (uint)617.64f;
|
||||
case 2:
|
||||
return (uint)659.54f;
|
||||
case 4:
|
||||
return (uint)711.44f;
|
||||
case 6:
|
||||
return (uint)778.07f;
|
||||
default:
|
||||
throw new NotImplementedException($"{command.Parameter.ChannelCount}");
|
||||
}
|
||||
}
|
||||
1 => (uint)617.64f,
|
||||
2 => (uint)659.54f,
|
||||
4 => (uint)711.44f,
|
||||
6 => (uint)778.07f,
|
||||
_ => throw new NotImplementedException($"{command.Parameter.ChannelCount}"),
|
||||
};
|
||||
}
|
||||
|
||||
public override uint Estimate(Reverb3dCommand command)
|
||||
{
|
||||
Debug.Assert(_sampleCount == 160 || _sampleCount == 240);
|
||||
Debug.Assert(SampleCount == 160 || SampleCount == 240);
|
||||
|
||||
if (_sampleCount == 160)
|
||||
if (SampleCount == 160)
|
||||
{
|
||||
if (command.Enabled)
|
||||
{
|
||||
switch (command.Parameter.ChannelCount)
|
||||
return command.Parameter.ChannelCount switch
|
||||
{
|
||||
case 1:
|
||||
return 116750;
|
||||
case 2:
|
||||
return 125910;
|
||||
case 4:
|
||||
return 146340;
|
||||
case 6:
|
||||
return 165810;
|
||||
default:
|
||||
throw new NotImplementedException($"{command.Parameter.ChannelCount}");
|
||||
}
|
||||
1 => 116750,
|
||||
2 => 125910,
|
||||
4 => 146340,
|
||||
6 => 165810,
|
||||
_ => throw new NotImplementedException($"{command.Parameter.ChannelCount}"),
|
||||
};
|
||||
}
|
||||
else
|
||||
|
||||
return command.Parameter.ChannelCount switch
|
||||
{
|
||||
switch (command.Parameter.ChannelCount)
|
||||
{
|
||||
case 1:
|
||||
return 735;
|
||||
case 2:
|
||||
return (uint)766.62f;
|
||||
case 4:
|
||||
return (uint)834.07f;
|
||||
case 6:
|
||||
return (uint)875.44f;
|
||||
default:
|
||||
throw new NotImplementedException($"{command.Parameter.ChannelCount}");
|
||||
}
|
||||
}
|
||||
1 => 735,
|
||||
2 => (uint)766.62f,
|
||||
4 => (uint)834.07f,
|
||||
6 => (uint)875.44f,
|
||||
_ => throw new NotImplementedException($"{command.Parameter.ChannelCount}"),
|
||||
};
|
||||
}
|
||||
|
||||
if (command.Enabled)
|
||||
{
|
||||
switch (command.Parameter.ChannelCount)
|
||||
return command.Parameter.ChannelCount switch
|
||||
{
|
||||
case 1:
|
||||
return 170290;
|
||||
case 2:
|
||||
return 183880;
|
||||
case 4:
|
||||
return 214700;
|
||||
case 6:
|
||||
return 243850;
|
||||
default:
|
||||
throw new NotImplementedException($"{command.Parameter.ChannelCount}");
|
||||
}
|
||||
1 => 170290,
|
||||
2 => 183880,
|
||||
4 => 214700,
|
||||
6 => 243850,
|
||||
_ => throw new NotImplementedException($"{command.Parameter.ChannelCount}"),
|
||||
};
|
||||
}
|
||||
else
|
||||
|
||||
return command.Parameter.ChannelCount switch
|
||||
{
|
||||
switch (command.Parameter.ChannelCount)
|
||||
{
|
||||
case 1:
|
||||
return (uint)508.47f;
|
||||
case 2:
|
||||
return (uint)582.45f;
|
||||
case 4:
|
||||
return (uint)626.42f;
|
||||
case 6:
|
||||
return (uint)682.47f;
|
||||
default:
|
||||
throw new NotImplementedException($"{command.Parameter.ChannelCount}");
|
||||
}
|
||||
}
|
||||
1 => (uint)508.47f,
|
||||
2 => (uint)582.45f,
|
||||
4 => (uint)626.42f,
|
||||
6 => (uint)682.47f,
|
||||
_ => throw new NotImplementedException($"{command.Parameter.ChannelCount}"),
|
||||
};
|
||||
}
|
||||
|
||||
public override uint Estimate(CompressorCommand command)
|
||||
{
|
||||
Debug.Assert(_sampleCount == 160 || _sampleCount == 240);
|
||||
Debug.Assert(SampleCount == 160 || SampleCount == 240);
|
||||
|
||||
if (_sampleCount == 160)
|
||||
if (SampleCount == 160)
|
||||
{
|
||||
if (command.Enabled)
|
||||
{
|
||||
switch (command.Parameter.ChannelCount)
|
||||
return command.Parameter.ChannelCount switch
|
||||
{
|
||||
case 1:
|
||||
return 34431;
|
||||
case 2:
|
||||
return 44253;
|
||||
case 4:
|
||||
return 63827;
|
||||
case 6:
|
||||
return 83361;
|
||||
default:
|
||||
throw new NotImplementedException($"{command.Parameter.ChannelCount}");
|
||||
}
|
||||
1 => 34431,
|
||||
2 => 44253,
|
||||
4 => 63827,
|
||||
6 => 83361,
|
||||
_ => throw new NotImplementedException($"{command.Parameter.ChannelCount}"),
|
||||
};
|
||||
}
|
||||
else
|
||||
|
||||
return command.Parameter.ChannelCount switch
|
||||
{
|
||||
switch (command.Parameter.ChannelCount)
|
||||
{
|
||||
case 1:
|
||||
return (uint)630.12f;
|
||||
case 2:
|
||||
return (uint)638.27f;
|
||||
case 4:
|
||||
return (uint)705.86f;
|
||||
case 6:
|
||||
return (uint)782.02f;
|
||||
default:
|
||||
throw new NotImplementedException($"{command.Parameter.ChannelCount}");
|
||||
}
|
||||
}
|
||||
1 => (uint)630.12f,
|
||||
2 => (uint)638.27f,
|
||||
4 => (uint)705.86f,
|
||||
6 => (uint)782.02f,
|
||||
_ => throw new NotImplementedException($"{command.Parameter.ChannelCount}"),
|
||||
};
|
||||
}
|
||||
|
||||
if (command.Enabled)
|
||||
{
|
||||
switch (command.Parameter.ChannelCount)
|
||||
return command.Parameter.ChannelCount switch
|
||||
{
|
||||
case 1:
|
||||
return 51095;
|
||||
case 2:
|
||||
return 65693;
|
||||
case 4:
|
||||
return 95383;
|
||||
case 6:
|
||||
return 124510;
|
||||
default:
|
||||
throw new NotImplementedException($"{command.Parameter.ChannelCount}");
|
||||
}
|
||||
1 => 51095,
|
||||
2 => 65693,
|
||||
4 => 95383,
|
||||
6 => 124510,
|
||||
_ => throw new NotImplementedException($"{command.Parameter.ChannelCount}"),
|
||||
};
|
||||
}
|
||||
else
|
||||
|
||||
return command.Parameter.ChannelCount switch
|
||||
{
|
||||
switch (command.Parameter.ChannelCount)
|
||||
{
|
||||
case 1:
|
||||
return (uint)840.14f;
|
||||
case 2:
|
||||
return (uint)826.1f;
|
||||
case 4:
|
||||
return (uint)901.88f;
|
||||
case 6:
|
||||
return (uint)965.29f;
|
||||
default:
|
||||
throw new NotImplementedException($"{command.Parameter.ChannelCount}");
|
||||
}
|
||||
}
|
||||
1 => (uint)840.14f,
|
||||
2 => (uint)826.1f,
|
||||
4 => (uint)901.88f,
|
||||
6 => (uint)965.29f,
|
||||
_ => throw new NotImplementedException($"{command.Parameter.ChannelCount}"),
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@ namespace Ryujinx.Audio.Renderer.Server.Effect
|
||||
{
|
||||
ulong bufferSize = (ulong)Unsafe.SizeOf<int>() * Parameter.BufferStorageSize + (ulong)Unsafe.SizeOf<AuxiliaryBufferHeader>();
|
||||
|
||||
bool sendBufferUnmapped = !mapper.TryAttachBuffer(out updateErrorInfo, ref WorkBuffers[0], Parameter.SendBufferInfoAddress, bufferSize);
|
||||
bool sendBufferUnmapped = !mapper.TryAttachBuffer(out _, ref WorkBuffers[0], Parameter.SendBufferInfoAddress, bufferSize);
|
||||
bool returnBufferUnmapped = !mapper.TryAttachBuffer(out updateErrorInfo, ref WorkBuffers[1], Parameter.ReturnBufferInfoAddress, bufferSize);
|
||||
|
||||
BufferUnmapped = sendBufferUnmapped && returnBufferUnmapped;
|
||||
@@ -82,4 +82,4 @@ namespace Ryujinx.Audio.Renderer.Server.Effect
|
||||
UpdateUsageStateForCommandGeneration();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -244,29 +244,19 @@ namespace Ryujinx.Audio.Renderer.Server.Effect
|
||||
/// <returns>The <see cref="PerformanceDetailType"/> associated to the <see cref="Type"/> of this effect.</returns>
|
||||
public PerformanceDetailType GetPerformanceDetailType()
|
||||
{
|
||||
switch (Type)
|
||||
return Type switch
|
||||
{
|
||||
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;
|
||||
case EffectType.Limiter:
|
||||
return PerformanceDetailType.Limiter;
|
||||
case EffectType.CaptureBuffer:
|
||||
return PerformanceDetailType.CaptureBuffer;
|
||||
case EffectType.Compressor:
|
||||
return PerformanceDetailType.Compressor;
|
||||
default:
|
||||
throw new NotImplementedException($"{Type}");
|
||||
}
|
||||
EffectType.BiquadFilter => PerformanceDetailType.BiquadFilter,
|
||||
EffectType.AuxiliaryBuffer => PerformanceDetailType.Aux,
|
||||
EffectType.Delay => PerformanceDetailType.Delay,
|
||||
EffectType.Reverb => PerformanceDetailType.Reverb,
|
||||
EffectType.Reverb3d => PerformanceDetailType.Reverb3d,
|
||||
EffectType.BufferMix => PerformanceDetailType.Mix,
|
||||
EffectType.Limiter => PerformanceDetailType.Limiter,
|
||||
EffectType.CaptureBuffer => PerformanceDetailType.CaptureBuffer,
|
||||
EffectType.Compressor => PerformanceDetailType.Compressor,
|
||||
_ => throw new NotImplementedException($"{Type}"),
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,4 +64,4 @@ namespace Ryujinx.Audio.Renderer.Server.Effect
|
||||
Parameter.Status = UsageState.Enabled;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,4 +46,4 @@ namespace Ryujinx.Audio.Renderer.Server.Effect
|
||||
UpdateUsageStateForCommandGeneration();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -79,4 +79,4 @@ namespace Ryujinx.Audio.Renderer.Server.Effect
|
||||
UpdateUsageStateForCommandGeneration();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -90,4 +90,4 @@ namespace Ryujinx.Audio.Renderer.Server.Effect
|
||||
Parameter.Status = UsageState.Enabled;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -120,4 +120,4 @@ namespace Ryujinx.Audio.Renderer.Server.Effect
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -92,4 +92,4 @@ namespace Ryujinx.Audio.Renderer.Server.Effect
|
||||
destState = srcState;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -89,4 +89,4 @@ namespace Ryujinx.Audio.Renderer.Server.Effect
|
||||
Parameter.ParameterStatus = UsageState.Enabled;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -92,4 +92,4 @@ namespace Ryujinx.Audio.Renderer.Server.Effect
|
||||
Parameter.Status = UsageState.Enabled;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,6 +23,6 @@ namespace Ryujinx.Audio.Renderer.Server.Effect
|
||||
/// <summary>
|
||||
/// The effect is disabled.
|
||||
/// </summary>
|
||||
Disabled
|
||||
Disabled,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,4 +37,4 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||
uint Estimate(CaptureBufferCommand command);
|
||||
uint Estimate(CompressorCommand command);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,9 +27,9 @@ namespace Ryujinx.Audio.Renderer.Server.MemoryPool
|
||||
/// </summary>
|
||||
public DspAddress ForceMappedDspAddress;
|
||||
|
||||
private unsafe ref MemoryPoolState MemoryPoolState => ref *_memoryPools;
|
||||
private readonly unsafe ref MemoryPoolState MemoryPoolState => ref *_memoryPools;
|
||||
|
||||
public unsafe bool HasMemoryPoolState => (IntPtr)_memoryPools != IntPtr.Zero;
|
||||
public readonly unsafe bool HasMemoryPoolState => (IntPtr)_memoryPools != IntPtr.Zero;
|
||||
|
||||
/// <summary>
|
||||
/// Create an new empty <see cref="AddressInfo"/>.
|
||||
@@ -55,7 +55,7 @@ namespace Ryujinx.Audio.Renderer.Server.MemoryPool
|
||||
CpuAddress = cpuAddress,
|
||||
_memoryPools = MemoryPoolState.Null,
|
||||
Size = size,
|
||||
ForceMappedDspAddress = 0
|
||||
ForceMappedDspAddress = 0,
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -105,7 +105,7 @@ namespace Ryujinx.Audio.Renderer.Server.MemoryPool
|
||||
/// Check if the <see cref="MemoryPoolState"/> is mapped.
|
||||
/// </summary>
|
||||
/// <returns>Returns true if the <see cref="MemoryPoolState"/> is mapped.</returns>
|
||||
public bool HasMappedMemoryPool()
|
||||
public readonly bool HasMappedMemoryPool()
|
||||
{
|
||||
return HasMemoryPoolState && MemoryPoolState.IsMapped();
|
||||
}
|
||||
@@ -115,7 +115,7 @@ namespace Ryujinx.Audio.Renderer.Server.MemoryPool
|
||||
/// </summary>
|
||||
/// <param name="markUsed">If true, mark the <see cref="MemoryPoolState"/> as used.</param>
|
||||
/// <returns>Returns the DSP address associated to the <see cref="AddressInfo"/>.</returns>
|
||||
public DspAddress GetReference(bool markUsed)
|
||||
public readonly DspAddress GetReference(bool markUsed)
|
||||
{
|
||||
if (!HasMappedMemoryPool())
|
||||
{
|
||||
@@ -130,4 +130,4 @@ namespace Ryujinx.Audio.Renderer.Server.MemoryPool
|
||||
return MemoryPoolState.Translate(CpuAddress, Size);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace Ryujinx.Audio.Renderer.Server.MemoryPool
|
||||
/// <summary>
|
||||
/// <see cref="MemoryPoolState"/> located on the DSP side for system use.
|
||||
/// </summary>
|
||||
Dsp
|
||||
Dsp,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -69,7 +69,7 @@ namespace Ryujinx.Audio.Renderer.Server.MemoryPool
|
||||
CpuAddress = 0,
|
||||
DspAddress = 0,
|
||||
Size = 0,
|
||||
Location = location
|
||||
Location = location,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -90,7 +90,7 @@ namespace Ryujinx.Audio.Renderer.Server.MemoryPool
|
||||
/// <param name="targetCpuAddress">The <see cref="CpuAddress"/>.</param>
|
||||
/// <param name="size">The size.</param>
|
||||
/// <returns>True if the <see cref="CpuAddress"/> is contained inside the <see cref="MemoryPoolState"/>.</returns>
|
||||
public bool Contains(CpuAddress targetCpuAddress, ulong size)
|
||||
public readonly bool Contains(CpuAddress targetCpuAddress, ulong size)
|
||||
{
|
||||
if (CpuAddress <= targetCpuAddress && size + targetCpuAddress <= Size + CpuAddress)
|
||||
{
|
||||
@@ -106,7 +106,7 @@ namespace Ryujinx.Audio.Renderer.Server.MemoryPool
|
||||
/// <param name="targetCpuAddress">The <see cref="CpuAddress"/>.</param>
|
||||
/// <param name="size">The size.</param>
|
||||
/// <returns>the target DSP address.</returns>
|
||||
public DspAddress Translate(CpuAddress targetCpuAddress, ulong size)
|
||||
public readonly DspAddress Translate(CpuAddress targetCpuAddress, ulong size)
|
||||
{
|
||||
if (Contains(targetCpuAddress, size) && IsMapped())
|
||||
{
|
||||
@@ -122,9 +122,9 @@ namespace Ryujinx.Audio.Renderer.Server.MemoryPool
|
||||
/// Is the <see cref="MemoryPoolState"/> mapped on the DSP?
|
||||
/// </summary>
|
||||
/// <returns>Returns true if the <see cref="MemoryPoolState"/> is mapped on the DSP.</returns>
|
||||
public bool IsMapped()
|
||||
public readonly bool IsMapped()
|
||||
{
|
||||
return DspAddress != 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,23 +40,23 @@ namespace Ryujinx.Audio.Renderer.Server.MemoryPool
|
||||
/// <summary>
|
||||
/// <see cref="Dsp.AudioProcessor"/> unmapping failed.
|
||||
/// </summary>
|
||||
UnmapError = 3
|
||||
UnmapError = 3,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The handle of the process owning the CPU memory manipulated.
|
||||
/// </summary>
|
||||
private uint _processHandle;
|
||||
private readonly uint _processHandle;
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="Memory{MemoryPoolState}"/> that will be manipulated.
|
||||
/// </summary>
|
||||
private Memory<MemoryPoolState> _memoryPools;
|
||||
private readonly Memory<MemoryPoolState> _memoryPools;
|
||||
|
||||
/// <summary>
|
||||
/// If set to true, this will try to force map memory pool even if their state are considered invalid.
|
||||
/// </summary>
|
||||
private bool _isForceMapEnabled;
|
||||
private readonly bool _isForceMapEnabled;
|
||||
|
||||
/// <summary>
|
||||
/// Create a new <see cref="PoolMapper"/> used for system mapping.
|
||||
@@ -125,7 +125,8 @@ namespace Ryujinx.Audio.Renderer.Server.MemoryPool
|
||||
{
|
||||
return CurrentProcessPseudoHandle;
|
||||
}
|
||||
else if (memoryPool.Location == MemoryPoolState.LocationType.Dsp)
|
||||
|
||||
if (memoryPool.Location == MemoryPoolState.LocationType.Dsp)
|
||||
{
|
||||
return _processHandle;
|
||||
}
|
||||
@@ -234,13 +235,11 @@ namespace Ryujinx.Audio.Renderer.Server.MemoryPool
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
errorInfo.ErrorCode = ResultCode.InvalidAddressInfo;
|
||||
errorInfo.ExtraErrorInfo = addressInfo.CpuAddress;
|
||||
|
||||
return _isForceMapEnabled;
|
||||
}
|
||||
errorInfo.ErrorCode = ResultCode.InvalidAddressInfo;
|
||||
errorInfo.ExtraErrorInfo = addressInfo.CpuAddress;
|
||||
|
||||
return _isForceMapEnabled;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -206,7 +206,7 @@ namespace Ryujinx.Audio.Renderer.Server.Mix
|
||||
{
|
||||
UpdateDistancesFromFinalMix();
|
||||
|
||||
int[] sortedMixesTemp = _sortedMixes.Slice(0, (int)GetCount()).ToArray();
|
||||
int[] sortedMixesTemp = _sortedMixes[..(int)GetCount()].ToArray();
|
||||
|
||||
Array.Sort(sortedMixesTemp, (a, b) =>
|
||||
{
|
||||
@@ -248,12 +248,10 @@ namespace Ryujinx.Audio.Renderer.Server.Mix
|
||||
|
||||
return isValid;
|
||||
}
|
||||
else
|
||||
{
|
||||
UpdateMixBufferOffset();
|
||||
|
||||
return true;
|
||||
}
|
||||
UpdateMixBufferOffset();
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,6 @@ using System;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
using static Ryujinx.Audio.Constants;
|
||||
|
||||
namespace Ryujinx.Audio.Renderer.Server.Mix
|
||||
@@ -66,7 +65,7 @@ namespace Ryujinx.Audio.Renderer.Server.Mix
|
||||
/// <summary>
|
||||
/// The effect processing order storage.
|
||||
/// </summary>
|
||||
private IntPtr _effectProcessingOrderArrayPointer;
|
||||
private readonly IntPtr _effectProcessingOrderArrayPointer;
|
||||
|
||||
/// <summary>
|
||||
/// The max element count that can be found in the effect processing order storage.
|
||||
@@ -120,7 +119,7 @@ namespace Ryujinx.Audio.Renderer.Server.Mix
|
||||
/// <summary>
|
||||
/// The array used to order effects associated to this mix.
|
||||
/// </summary>
|
||||
public Span<int> EffectProcessingOrderArray
|
||||
public readonly Span<int> EffectProcessingOrderArray
|
||||
{
|
||||
get
|
||||
{
|
||||
@@ -175,7 +174,7 @@ namespace Ryujinx.Audio.Renderer.Server.Mix
|
||||
/// <summary>
|
||||
/// Clear the <see cref="EffectProcessingOrderArray"/> to its default state.
|
||||
/// </summary>
|
||||
public void ClearEffectProcessingOrder()
|
||||
public readonly void ClearEffectProcessingOrder()
|
||||
{
|
||||
EffectProcessingOrderArray.Fill(-1);
|
||||
}
|
||||
@@ -184,7 +183,7 @@ namespace Ryujinx.Audio.Renderer.Server.Mix
|
||||
/// Return true if the mix has any destinations.
|
||||
/// </summary>
|
||||
/// <returns>True if the mix has any destinations.</returns>
|
||||
public bool HasAnyDestination()
|
||||
public readonly bool HasAnyDestination()
|
||||
{
|
||||
return DestinationMixId != UnusedMixId || DestinationSplitterId != UnusedSplitterId;
|
||||
}
|
||||
@@ -310,4 +309,4 @@ namespace Ryujinx.Audio.Renderer.Server.Mix
|
||||
return isDirty;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,4 +49,4 @@ namespace Ryujinx.Audio.Renderer.Server.Performance
|
||||
/// <param name="detailType">The type to use.</param>
|
||||
void SetDetailType(PerformanceDetailType detailType);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,4 +43,4 @@ namespace Ryujinx.Audio.Renderer.Server.Performance
|
||||
/// <param name="type">The type to use.</param>
|
||||
void SetEntryType(PerformanceEntryType type);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -77,4 +77,4 @@ namespace Ryujinx.Audio.Renderer.Server.Performance
|
||||
/// <param name="entryDetailCount">The total count of detailed entries in this frame.</param>
|
||||
void SetEntryDetailCount(int entryDetailCount);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,22 +34,22 @@ namespace Ryujinx.Audio.Renderer.Server.Performance
|
||||
/// </summary>
|
||||
public PerformanceEntryType EntryType;
|
||||
|
||||
public int GetProcessingTime()
|
||||
public readonly int GetProcessingTime()
|
||||
{
|
||||
return ProcessingTime;
|
||||
}
|
||||
|
||||
public int GetProcessingTimeOffset()
|
||||
public readonly int GetProcessingTimeOffset()
|
||||
{
|
||||
return 8;
|
||||
}
|
||||
|
||||
public int GetStartTime()
|
||||
public readonly int GetStartTime()
|
||||
{
|
||||
return StartTime;
|
||||
}
|
||||
|
||||
public int GetStartTimeOffset()
|
||||
public readonly int GetStartTimeOffset()
|
||||
{
|
||||
return 4;
|
||||
}
|
||||
@@ -69,4 +69,4 @@ namespace Ryujinx.Audio.Renderer.Server.Performance
|
||||
NodeId = nodeId;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,22 +34,22 @@ namespace Ryujinx.Audio.Renderer.Server.Performance
|
||||
/// </summary>
|
||||
public PerformanceEntryType EntryType;
|
||||
|
||||
public int GetProcessingTime()
|
||||
public readonly int GetProcessingTime()
|
||||
{
|
||||
return ProcessingTime;
|
||||
}
|
||||
|
||||
public int GetProcessingTimeOffset()
|
||||
public readonly int GetProcessingTimeOffset()
|
||||
{
|
||||
return 8;
|
||||
}
|
||||
|
||||
public int GetStartTime()
|
||||
public readonly int GetStartTime()
|
||||
{
|
||||
return StartTime;
|
||||
}
|
||||
|
||||
public int GetStartTimeOffset()
|
||||
public readonly int GetStartTimeOffset()
|
||||
{
|
||||
return 4;
|
||||
}
|
||||
@@ -69,4 +69,4 @@ namespace Ryujinx.Audio.Renderer.Server.Performance
|
||||
NodeId = nodeId;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,4 +53,4 @@ namespace Ryujinx.Audio.Renderer.Server.Performance
|
||||
BaseMemory.Span[(int)ProcessingTimeOffset / 4] = (int)(endTimeNano / 1000) - BaseMemory.Span[(int)StartTimeOffset / 4];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,22 +29,22 @@ namespace Ryujinx.Audio.Renderer.Server.Performance
|
||||
/// </summary>
|
||||
public PerformanceEntryType EntryType;
|
||||
|
||||
public int GetProcessingTime()
|
||||
public readonly int GetProcessingTime()
|
||||
{
|
||||
return ProcessingTime;
|
||||
}
|
||||
|
||||
public int GetProcessingTimeOffset()
|
||||
public readonly int GetProcessingTimeOffset()
|
||||
{
|
||||
return 8;
|
||||
}
|
||||
|
||||
public int GetStartTime()
|
||||
public readonly int GetStartTime()
|
||||
{
|
||||
return StartTime;
|
||||
}
|
||||
|
||||
public int GetStartTimeOffset()
|
||||
public readonly int GetStartTimeOffset()
|
||||
{
|
||||
return 4;
|
||||
}
|
||||
@@ -59,4 +59,4 @@ namespace Ryujinx.Audio.Renderer.Server.Performance
|
||||
NodeId = nodeId;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,22 +29,22 @@ namespace Ryujinx.Audio.Renderer.Server.Performance
|
||||
/// </summary>
|
||||
public PerformanceEntryType EntryType;
|
||||
|
||||
public int GetProcessingTime()
|
||||
public readonly int GetProcessingTime()
|
||||
{
|
||||
return ProcessingTime;
|
||||
}
|
||||
|
||||
public int GetProcessingTimeOffset()
|
||||
public readonly int GetProcessingTimeOffset()
|
||||
{
|
||||
return 8;
|
||||
}
|
||||
|
||||
public int GetStartTime()
|
||||
public readonly int GetStartTime()
|
||||
{
|
||||
return StartTime;
|
||||
}
|
||||
|
||||
public int GetStartTimeOffset()
|
||||
public readonly int GetStartTimeOffset()
|
||||
{
|
||||
return 4;
|
||||
}
|
||||
@@ -59,4 +59,4 @@ namespace Ryujinx.Audio.Renderer.Server.Performance
|
||||
NodeId = nodeId;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,22 +38,22 @@ namespace Ryujinx.Audio.Renderer.Server.Performance
|
||||
/// </summary>
|
||||
public uint VoiceDropCount;
|
||||
|
||||
public int GetEntryCount()
|
||||
public readonly int GetEntryCount()
|
||||
{
|
||||
return EntryCount;
|
||||
}
|
||||
|
||||
public int GetEntryCountOffset()
|
||||
public readonly int GetEntryCountOffset()
|
||||
{
|
||||
return 4;
|
||||
}
|
||||
|
||||
public int GetEntryDetailCount()
|
||||
public readonly int GetEntryDetailCount()
|
||||
{
|
||||
return EntryDetailCount;
|
||||
}
|
||||
|
||||
public void SetDspRunningBehind(bool isRunningBehind)
|
||||
public readonly void SetDspRunningBehind(bool isRunningBehind)
|
||||
{
|
||||
// NOTE: Not present in version 1
|
||||
}
|
||||
@@ -68,7 +68,7 @@ namespace Ryujinx.Audio.Renderer.Server.Performance
|
||||
EntryDetailCount = entryDetailCount;
|
||||
}
|
||||
|
||||
public void SetIndex(uint index)
|
||||
public readonly void SetIndex(uint index)
|
||||
{
|
||||
// NOTE: Not present in version 1
|
||||
}
|
||||
@@ -83,7 +83,7 @@ namespace Ryujinx.Audio.Renderer.Server.Performance
|
||||
NextOffset = nextOffset;
|
||||
}
|
||||
|
||||
public void SetStartRenderingTicks(ulong startTicks)
|
||||
public readonly void SetStartRenderingTicks(ulong startTicks)
|
||||
{
|
||||
// NOTE: not present in version 1
|
||||
}
|
||||
@@ -98,4 +98,4 @@ namespace Ryujinx.Audio.Renderer.Server.Performance
|
||||
VoiceDropCount = voiceCount;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,17 +54,17 @@ namespace Ryujinx.Audio.Renderer.Server.Performance
|
||||
[MarshalAs(UnmanagedType.I1)]
|
||||
public bool IsDspRunningBehind;
|
||||
|
||||
public int GetEntryCount()
|
||||
public readonly int GetEntryCount()
|
||||
{
|
||||
return EntryCount;
|
||||
}
|
||||
|
||||
public int GetEntryCountOffset()
|
||||
public readonly int GetEntryCountOffset()
|
||||
{
|
||||
return 4;
|
||||
}
|
||||
|
||||
public int GetEntryDetailCount()
|
||||
public readonly int GetEntryDetailCount()
|
||||
{
|
||||
return EntryDetailCount;
|
||||
}
|
||||
@@ -114,4 +114,4 @@ namespace Ryujinx.Audio.Renderer.Server.Performance
|
||||
VoiceDropCount = voiceCount;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,11 +22,12 @@ namespace Ryujinx.Audio.Renderer.Server.Performance
|
||||
PerformanceEntryVersion2,
|
||||
PerformanceDetailVersion2>.GetRequiredBufferSizeForPerformanceMetricsPerFrame(ref parameter);
|
||||
}
|
||||
else if (version == 1)
|
||||
|
||||
if (version == 1)
|
||||
{
|
||||
return (ulong)PerformanceManagerGeneric<PerformanceFrameHeaderVersion1,
|
||||
PerformanceEntryVersion1,
|
||||
PerformanceDetailVersion1>.GetRequiredBufferSizeForPerformanceMetricsPerFrame(ref parameter);
|
||||
PerformanceEntryVersion1,
|
||||
PerformanceDetailVersion1>.GetRequiredBufferSizeForPerformanceMetricsPerFrame(ref parameter);
|
||||
}
|
||||
|
||||
throw new NotImplementedException($"Unknown Performance metrics data format version {version}");
|
||||
@@ -90,17 +91,12 @@ namespace Ryujinx.Audio.Renderer.Server.Performance
|
||||
{
|
||||
uint version = behaviourContext.GetPerformanceMetricsDataFormat();
|
||||
|
||||
switch (version)
|
||||
return version switch
|
||||
{
|
||||
case 1:
|
||||
return new PerformanceManagerGeneric<PerformanceFrameHeaderVersion1, PerformanceEntryVersion1, PerformanceDetailVersion1>(performanceBuffer,
|
||||
ref parameter);
|
||||
case 2:
|
||||
return new PerformanceManagerGeneric<PerformanceFrameHeaderVersion2, PerformanceEntryVersion2, PerformanceDetailVersion2>(performanceBuffer,
|
||||
ref parameter);
|
||||
default:
|
||||
throw new NotImplementedException($"Unknown Performance metrics data format version {version}");
|
||||
}
|
||||
1 => new PerformanceManagerGeneric<PerformanceFrameHeaderVersion1, PerformanceEntryVersion1, PerformanceDetailVersion1>(performanceBuffer, ref parameter),
|
||||
2 => new PerformanceManagerGeneric<PerformanceFrameHeaderVersion2, PerformanceEntryVersion2, PerformanceDetailVersion2>(performanceBuffer, ref parameter),
|
||||
_ => throw new NotImplementedException($"Unknown Performance metrics data format version {version}"),
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,20 +25,20 @@ namespace Ryujinx.Audio.Renderer.Server.Performance
|
||||
/// </summary>
|
||||
private const int MaxFrameDetailCount = 100;
|
||||
|
||||
private Memory<byte> _buffer;
|
||||
private Memory<byte> _historyBuffer;
|
||||
private readonly Memory<byte> _buffer;
|
||||
private readonly Memory<byte> _historyBuffer;
|
||||
|
||||
private Memory<byte> CurrentBuffer => _buffer.Slice(0, _frameSize);
|
||||
private Memory<byte> CurrentBufferData => CurrentBuffer.Slice(Unsafe.SizeOf<THeader>());
|
||||
private Memory<byte> CurrentBuffer => _buffer[.._frameSize];
|
||||
private Memory<byte> CurrentBufferData => CurrentBuffer[Unsafe.SizeOf<THeader>()..];
|
||||
|
||||
private ref THeader CurrentHeader => ref MemoryMarshal.Cast<byte, THeader>(CurrentBuffer.Span)[0];
|
||||
|
||||
private Span<TEntry> Entries => MemoryMarshal.Cast<byte, TEntry>(CurrentBufferData.Span.Slice(0, GetEntriesSize()));
|
||||
private Span<TEntry> Entries => MemoryMarshal.Cast<byte, TEntry>(CurrentBufferData.Span[..GetEntriesSize()]);
|
||||
private Span<TEntryDetail> EntriesDetail => MemoryMarshal.Cast<byte, TEntryDetail>(CurrentBufferData.Span.Slice(GetEntriesSize(), GetEntriesDetailSize()));
|
||||
|
||||
private int _frameSize;
|
||||
private int _availableFrameCount;
|
||||
private int _entryCountPerFrame;
|
||||
private readonly int _frameSize;
|
||||
private readonly int _availableFrameCount;
|
||||
private readonly int _entryCountPerFrame;
|
||||
private int _detailTarget;
|
||||
private int _entryIndex;
|
||||
private int _entryDetailIndex;
|
||||
@@ -56,7 +56,7 @@ namespace Ryujinx.Audio.Renderer.Server.Performance
|
||||
|
||||
_historyFrameIndex = 0;
|
||||
|
||||
_historyBuffer = _buffer.Slice(_frameSize);
|
||||
_historyBuffer = _buffer[_frameSize..];
|
||||
|
||||
SetupNewHeader();
|
||||
}
|
||||
@@ -130,7 +130,7 @@ namespace Ryujinx.Audio.Renderer.Server.Performance
|
||||
Span<TEntry> inputEntries = GetEntriesFromBuffer(_historyBuffer.Span, _indexHistoryRead);
|
||||
Span<TEntryDetail> inputEntriesDetail = GetEntriesDetailFromBuffer(_historyBuffer.Span, _indexHistoryRead);
|
||||
|
||||
Span<byte> targetSpan = performanceOutput.Slice(nextOffset);
|
||||
Span<byte> targetSpan = performanceOutput[nextOffset..];
|
||||
|
||||
// NOTE: We check for the space for two headers for the final blank header.
|
||||
int requiredSpace = Unsafe.SizeOf<THeader>() + Unsafe.SizeOf<TEntry>() * inputHeader.GetEntryCount()
|
||||
@@ -146,7 +146,7 @@ namespace Ryujinx.Audio.Renderer.Server.Performance
|
||||
|
||||
nextOffset += Unsafe.SizeOf<THeader>();
|
||||
|
||||
Span<TEntry> outputEntries = MemoryMarshal.Cast<byte, TEntry>(performanceOutput.Slice(nextOffset));
|
||||
Span<TEntry> outputEntries = MemoryMarshal.Cast<byte, TEntry>(performanceOutput[nextOffset..]);
|
||||
|
||||
int totalProcessingTime = 0;
|
||||
|
||||
@@ -168,7 +168,7 @@ namespace Ryujinx.Audio.Renderer.Server.Performance
|
||||
}
|
||||
}
|
||||
|
||||
Span<TEntryDetail> outputEntriesDetail = MemoryMarshal.Cast<byte, TEntryDetail>(performanceOutput.Slice(nextOffset));
|
||||
Span<TEntryDetail> outputEntriesDetail = MemoryMarshal.Cast<byte, TEntryDetail>(performanceOutput[nextOffset..]);
|
||||
|
||||
int effectiveEntryDetailCount = 0;
|
||||
|
||||
@@ -198,7 +198,7 @@ namespace Ryujinx.Audio.Renderer.Server.Performance
|
||||
|
||||
if (nextOffset < performanceOutput.Length && (performanceOutput.Length - nextOffset) >= Unsafe.SizeOf<THeader>())
|
||||
{
|
||||
ref THeader outputHeader = ref MemoryMarshal.Cast<byte, THeader>(performanceOutput.Slice(nextOffset))[0];
|
||||
ref THeader outputHeader = ref MemoryMarshal.Cast<byte, THeader>(performanceOutput[nextOffset..])[0];
|
||||
|
||||
outputHeader = default;
|
||||
}
|
||||
@@ -208,9 +208,11 @@ namespace Ryujinx.Audio.Renderer.Server.Performance
|
||||
|
||||
public override bool GetNextEntry(out PerformanceEntryAddresses performanceEntry, PerformanceEntryType entryType, int nodeId)
|
||||
{
|
||||
performanceEntry = new PerformanceEntryAddresses();
|
||||
performanceEntry.BaseMemory = SpanMemoryManager<int>.Cast(CurrentBuffer);
|
||||
performanceEntry.EntryCountOffset = (uint)CurrentHeader.GetEntryCountOffset();
|
||||
performanceEntry = new PerformanceEntryAddresses
|
||||
{
|
||||
BaseMemory = SpanMemoryManager<int>.Cast(CurrentBuffer),
|
||||
EntryCountOffset = (uint)CurrentHeader.GetEntryCountOffset(),
|
||||
};
|
||||
|
||||
uint baseEntryOffset = (uint)(Unsafe.SizeOf<THeader>() + Unsafe.SizeOf<TEntry>() * _entryIndex);
|
||||
|
||||
@@ -237,9 +239,11 @@ namespace Ryujinx.Audio.Renderer.Server.Performance
|
||||
return false;
|
||||
}
|
||||
|
||||
performanceEntry = new PerformanceEntryAddresses();
|
||||
performanceEntry.BaseMemory = SpanMemoryManager<int>.Cast(CurrentBuffer);
|
||||
performanceEntry.EntryCountOffset = (uint)CurrentHeader.GetEntryCountOffset();
|
||||
performanceEntry = new PerformanceEntryAddresses
|
||||
{
|
||||
BaseMemory = SpanMemoryManager<int>.Cast(CurrentBuffer),
|
||||
EntryCountOffset = (uint)CurrentHeader.GetEntryCountOffset(),
|
||||
};
|
||||
|
||||
uint baseEntryOffset = (uint)(Unsafe.SizeOf<THeader>() + GetEntriesSize() + Unsafe.SizeOf<IPerformanceDetailEntry>() * _entryDetailIndex);
|
||||
|
||||
@@ -301,4 +305,4 @@ namespace Ryujinx.Audio.Renderer.Server.Performance
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,4 +45,4 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||
/// </remarks>
|
||||
public Memory<float> DepopBuffer;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -99,4 +99,4 @@ namespace Ryujinx.Audio.Renderer.Server.Sink
|
||||
errorInfo = new ErrorInfo();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -106,4 +106,4 @@ namespace Ryujinx.Audio.Renderer.Server.Sink
|
||||
base.CleanUp();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,4 +72,4 @@ namespace Ryujinx.Audio.Renderer.Server.Sink
|
||||
outStatus = new SinkOutStatus();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,4 +53,4 @@ namespace Ryujinx.Audio.Renderer.Server.Sink
|
||||
return ref _sinks[id];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -101,10 +101,8 @@ namespace Ryujinx.Audio.Renderer.Server.Splitter
|
||||
|
||||
return size;
|
||||
}
|
||||
else
|
||||
{
|
||||
return size;
|
||||
}
|
||||
|
||||
return size;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -164,10 +162,10 @@ namespace Ryujinx.Audio.Renderer.Server.Splitter
|
||||
{
|
||||
ref SplitterState splitter = ref GetState(parameter.Id);
|
||||
|
||||
splitter.Update(this, ref parameter, input.Slice(Unsafe.SizeOf<SplitterInParameter>()));
|
||||
splitter.Update(this, ref parameter, input[Unsafe.SizeOf<SplitterInParameter>()..]);
|
||||
}
|
||||
|
||||
input = input.Slice(0x1C + (int)parameter.DestinationCount * 4);
|
||||
input = input[(0x1C + parameter.DestinationCount * 4)..];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -194,7 +192,7 @@ namespace Ryujinx.Audio.Renderer.Server.Splitter
|
||||
destination.Update(parameter);
|
||||
}
|
||||
|
||||
input = input.Slice(Unsafe.SizeOf<SplitterDestinationInParameter>());
|
||||
input = input[Unsafe.SizeOf<SplitterDestinationInParameter>()..];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -229,12 +227,10 @@ namespace Ryujinx.Audio.Renderer.Server.Splitter
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
consumedSize = 0;
|
||||
|
||||
return false;
|
||||
}
|
||||
consumedSize = 0;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -300,4 +296,4 @@ namespace Ryujinx.Audio.Renderer.Server.Splitter
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,7 +65,7 @@ namespace Ryujinx.Audio.Renderer.Server.Splitter
|
||||
/// <summary>
|
||||
/// Get the <see cref="Span{SplitterDestination}"/> of the next element or <see cref="Span{SplitterDestination}.Empty"/> if not present.
|
||||
/// </summary>
|
||||
public Span<SplitterDestination> Next
|
||||
public readonly Span<SplitterDestination> Next
|
||||
{
|
||||
get
|
||||
{
|
||||
@@ -138,7 +138,7 @@ namespace Ryujinx.Audio.Renderer.Server.Splitter
|
||||
/// Return true if the <see cref="SplitterDestination"/> is used and has a destination.
|
||||
/// </summary>
|
||||
/// <returns>True if the <see cref="SplitterDestination"/> is used and has a destination.</returns>
|
||||
public bool IsConfigured()
|
||||
public readonly bool IsConfigured()
|
||||
{
|
||||
return IsUsed && DestinationId != Constants.UnusedMixId;
|
||||
}
|
||||
@@ -160,8 +160,8 @@ namespace Ryujinx.Audio.Renderer.Server.Splitter
|
||||
/// </summary>
|
||||
public void ClearVolumes()
|
||||
{
|
||||
MixBufferVolume.Fill(0);
|
||||
PreviousMixBufferVolume.Fill(0);
|
||||
MixBufferVolume.Clear();
|
||||
PreviousMixBufferVolume.Clear();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -190,4 +190,4 @@ namespace Ryujinx.Audio.Renderer.Server.Splitter
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ namespace Ryujinx.Audio.Renderer.Server.Splitter
|
||||
/// <summary>
|
||||
/// Span to the first element of the linked list of <see cref="SplitterDestination"/>.
|
||||
/// </summary>
|
||||
public Span<SplitterDestination> Destinations
|
||||
public readonly Span<SplitterDestination> Destinations
|
||||
{
|
||||
get
|
||||
{
|
||||
@@ -63,7 +63,7 @@ namespace Ryujinx.Audio.Renderer.Server.Splitter
|
||||
Id = id;
|
||||
}
|
||||
|
||||
public Span<SplitterDestination> GetData(int index)
|
||||
public readonly Span<SplitterDestination> GetData(int index)
|
||||
{
|
||||
int i = 0;
|
||||
|
||||
@@ -95,7 +95,7 @@ namespace Ryujinx.Audio.Renderer.Server.Splitter
|
||||
/// Utility function to apply a given <see cref="SpanAction{T, TArg}"/> to all <see cref="Destinations"/>.
|
||||
/// </summary>
|
||||
/// <param name="action">The action to execute on each elements.</param>
|
||||
private void ForEachDestination(SpanAction<SplitterDestination, int> action)
|
||||
private readonly void ForEachDestination(SpanAction<SplitterDestination, int> action)
|
||||
{
|
||||
Span<SplitterDestination> temp = Destinations;
|
||||
|
||||
@@ -183,7 +183,7 @@ namespace Ryujinx.Audio.Renderer.Server.Splitter
|
||||
/// <summary>
|
||||
/// Update the internal state of this instance.
|
||||
/// </summary>
|
||||
public void UpdateInternalState()
|
||||
public readonly void UpdateInternalState()
|
||||
{
|
||||
ForEachDestination((destination, _) => destination[0].UpdateInternalState());
|
||||
}
|
||||
@@ -218,4 +218,4 @@ namespace Ryujinx.Audio.Renderer.Server.Splitter
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,15 +22,15 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||
public class StateUpdater
|
||||
{
|
||||
private readonly ReadOnlyMemory<byte> _inputOrigin;
|
||||
private ReadOnlyMemory<byte> _outputOrigin;
|
||||
private readonly ReadOnlyMemory<byte> _outputOrigin;
|
||||
private ReadOnlyMemory<byte> _input;
|
||||
|
||||
private Memory<byte> _output;
|
||||
private uint _processHandle;
|
||||
private readonly uint _processHandle;
|
||||
private BehaviourContext _behaviourContext;
|
||||
|
||||
private UpdateDataHeader _inputHeader;
|
||||
private Memory<UpdateDataHeader> _outputHeader;
|
||||
private readonly Memory<UpdateDataHeader> _outputHeader;
|
||||
|
||||
private ref UpdateDataHeader OutputHeader => ref _outputHeader.Span[0];
|
||||
|
||||
@@ -45,9 +45,9 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||
|
||||
_inputHeader = SpanIOHelper.Read<UpdateDataHeader>(ref _input);
|
||||
|
||||
_outputHeader = SpanMemoryManager<UpdateDataHeader>.Cast(_output.Slice(0, Unsafe.SizeOf<UpdateDataHeader>()));
|
||||
_outputHeader = SpanMemoryManager<UpdateDataHeader>.Cast(_output[..Unsafe.SizeOf<UpdateDataHeader>()]);
|
||||
OutputHeader.Initialize(_behaviourContext.UserRevision);
|
||||
_output = _output.Slice(Unsafe.SizeOf<UpdateDataHeader>());
|
||||
_output = _output[Unsafe.SizeOf<UpdateDataHeader>()..];
|
||||
}
|
||||
|
||||
public ResultCode UpdateBehaviourContext()
|
||||
@@ -72,7 +72,7 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||
|
||||
public ResultCode UpdateMemoryPools(Span<MemoryPoolState> memoryPools)
|
||||
{
|
||||
PoolMapper mapper = new PoolMapper(_processHandle, _behaviourContext.IsMemoryPoolForceMappingEnabled());
|
||||
PoolMapper mapper = new(_processHandle, _behaviourContext.IsMemoryPoolForceMappingEnabled());
|
||||
|
||||
if (memoryPools.Length * Unsafe.SizeOf<MemoryPoolInParameter>() != _inputHeader.MemoryPoolsSize)
|
||||
{
|
||||
@@ -136,11 +136,11 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||
|
||||
int initialOutputSize = _output.Length;
|
||||
|
||||
ReadOnlySpan<VoiceInParameter> parameters = MemoryMarshal.Cast<byte, VoiceInParameter>(_input.Slice(0, (int)_inputHeader.VoicesSize).Span);
|
||||
ReadOnlySpan<VoiceInParameter> parameters = MemoryMarshal.Cast<byte, VoiceInParameter>(_input[..(int)_inputHeader.VoicesSize].Span);
|
||||
|
||||
_input = _input.Slice((int)_inputHeader.VoicesSize);
|
||||
_input = _input[(int)_inputHeader.VoicesSize..];
|
||||
|
||||
PoolMapper mapper = new PoolMapper(_processHandle, memoryPools, _behaviourContext.IsMemoryPoolForceMappingEnabled());
|
||||
PoolMapper mapper = new(_processHandle, memoryPools, _behaviourContext.IsMemoryPoolForceMappingEnabled());
|
||||
|
||||
// First make everything not in use.
|
||||
for (int i = 0; i < context.GetCount(); i++)
|
||||
@@ -151,7 +151,7 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||
}
|
||||
|
||||
Memory<VoiceUpdateState>[] voiceUpdateStatesArray = ArrayPool<Memory<VoiceUpdateState>>.Shared.Rent(Constants.VoiceChannelCountMax);
|
||||
|
||||
|
||||
Span<Memory<VoiceUpdateState>> voiceUpdateStates = voiceUpdateStatesArray.AsSpan(0, Constants.VoiceChannelCountMax);
|
||||
|
||||
// Start processing
|
||||
@@ -218,42 +218,20 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||
{
|
||||
effect.ForceUnmapBuffers(mapper);
|
||||
|
||||
switch (parameter.Type)
|
||||
effect = parameter.Type switch
|
||||
{
|
||||
case EffectType.Invalid:
|
||||
effect = new BaseEffect();
|
||||
break;
|
||||
case EffectType.BufferMix:
|
||||
effect = new BufferMixEffect();
|
||||
break;
|
||||
case EffectType.AuxiliaryBuffer:
|
||||
effect = new AuxiliaryBufferEffect();
|
||||
break;
|
||||
case EffectType.Delay:
|
||||
effect = new DelayEffect();
|
||||
break;
|
||||
case EffectType.Reverb:
|
||||
effect = new ReverbEffect();
|
||||
break;
|
||||
case EffectType.Reverb3d:
|
||||
effect = new Reverb3dEffect();
|
||||
break;
|
||||
case EffectType.BiquadFilter:
|
||||
effect = new BiquadFilterEffect();
|
||||
break;
|
||||
case EffectType.Limiter:
|
||||
effect = new LimiterEffect();
|
||||
break;
|
||||
case EffectType.CaptureBuffer:
|
||||
effect = new CaptureBufferEffect();
|
||||
break;
|
||||
case EffectType.Compressor:
|
||||
effect = new CompressorEffect();
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new NotImplementedException($"EffectType {parameter.Type} not implemented!");
|
||||
}
|
||||
EffectType.Invalid => new BaseEffect(),
|
||||
EffectType.BufferMix => new BufferMixEffect(),
|
||||
EffectType.AuxiliaryBuffer => new AuxiliaryBufferEffect(),
|
||||
EffectType.Delay => new DelayEffect(),
|
||||
EffectType.Reverb => new ReverbEffect(),
|
||||
EffectType.Reverb3d => new Reverb3dEffect(),
|
||||
EffectType.BiquadFilter => new BiquadFilterEffect(),
|
||||
EffectType.Limiter => new LimiterEffect(),
|
||||
EffectType.CaptureBuffer => new CaptureBufferEffect(),
|
||||
EffectType.Compressor => new CompressorEffect(),
|
||||
_ => throw new NotImplementedException($"EffectType {parameter.Type} not implemented!"),
|
||||
};
|
||||
}
|
||||
|
||||
public ResultCode UpdateEffects(EffectContext context, bool isAudioRendererActive, Memory<MemoryPoolState> memoryPools)
|
||||
@@ -262,10 +240,8 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||
{
|
||||
return UpdateEffectsVersion2(context, isAudioRendererActive, memoryPools);
|
||||
}
|
||||
else
|
||||
{
|
||||
return UpdateEffectsVersion1(context, isAudioRendererActive, memoryPools);
|
||||
}
|
||||
|
||||
return UpdateEffectsVersion1(context, isAudioRendererActive, memoryPools);
|
||||
}
|
||||
|
||||
public ResultCode UpdateEffectsVersion2(EffectContext context, bool isAudioRendererActive, Memory<MemoryPoolState> memoryPools)
|
||||
@@ -277,11 +253,11 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||
|
||||
int initialOutputSize = _output.Length;
|
||||
|
||||
ReadOnlySpan<EffectInParameterVersion2> parameters = MemoryMarshal.Cast<byte, EffectInParameterVersion2>(_input.Slice(0, (int)_inputHeader.EffectsSize).Span);
|
||||
ReadOnlySpan<EffectInParameterVersion2> parameters = MemoryMarshal.Cast<byte, EffectInParameterVersion2>(_input[..(int)_inputHeader.EffectsSize].Span);
|
||||
|
||||
_input = _input.Slice((int)_inputHeader.EffectsSize);
|
||||
_input = _input[(int)_inputHeader.EffectsSize..];
|
||||
|
||||
PoolMapper mapper = new PoolMapper(_processHandle, memoryPools, _behaviourContext.IsMemoryPoolForceMappingEnabled());
|
||||
PoolMapper mapper = new(_processHandle, memoryPools, _behaviourContext.IsMemoryPoolForceMappingEnabled());
|
||||
|
||||
for (int i = 0; i < context.GetCount(); i++)
|
||||
{
|
||||
@@ -333,11 +309,11 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||
|
||||
int initialOutputSize = _output.Length;
|
||||
|
||||
ReadOnlySpan<EffectInParameterVersion1> parameters = MemoryMarshal.Cast<byte, EffectInParameterVersion1>(_input.Slice(0, (int)_inputHeader.EffectsSize).Span);
|
||||
ReadOnlySpan<EffectInParameterVersion1> parameters = MemoryMarshal.Cast<byte, EffectInParameterVersion1>(_input[..(int)_inputHeader.EffectsSize].Span);
|
||||
|
||||
_input = _input.Slice((int)_inputHeader.EffectsSize);
|
||||
_input = _input[(int)_inputHeader.EffectsSize..];
|
||||
|
||||
PoolMapper mapper = new PoolMapper(_processHandle, memoryPools, _behaviourContext.IsMemoryPoolForceMappingEnabled());
|
||||
PoolMapper mapper = new(_processHandle, memoryPools, _behaviourContext.IsMemoryPoolForceMappingEnabled());
|
||||
|
||||
for (int i = 0; i < context.GetCount(); i++)
|
||||
{
|
||||
@@ -376,17 +352,15 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||
{
|
||||
if (context.Update(_input.Span, out int consumedSize))
|
||||
{
|
||||
_input = _input.Slice(consumedSize);
|
||||
_input = _input[consumedSize..];
|
||||
|
||||
return ResultCode.Success;
|
||||
}
|
||||
else
|
||||
{
|
||||
return ResultCode.InvalidUpdateInfo;
|
||||
}
|
||||
|
||||
return ResultCode.InvalidUpdateInfo;
|
||||
}
|
||||
|
||||
private bool CheckMixParametersValidity(MixContext mixContext, uint mixBufferCount, uint inputMixCount, ReadOnlySpan<MixParameter> parameters)
|
||||
private static bool CheckMixParametersValidity(MixContext mixContext, uint mixBufferCount, uint inputMixCount, ReadOnlySpan<MixParameter> parameters)
|
||||
{
|
||||
uint maxMixStateCount = mixContext.GetCount();
|
||||
uint totalRequiredMixBufferCount = 0;
|
||||
@@ -439,12 +413,12 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||
|
||||
if (_behaviourContext.IsMixInParameterDirtyOnlyUpdateSupported())
|
||||
{
|
||||
_input = _input.Slice(Unsafe.SizeOf<MixInParameterDirtyOnlyUpdate>());
|
||||
_input = _input[Unsafe.SizeOf<MixInParameterDirtyOnlyUpdate>()..];
|
||||
}
|
||||
|
||||
ReadOnlySpan<MixParameter> parameters = MemoryMarshal.Cast<byte, MixParameter>(_input.Span.Slice(0, (int)inputMixSize));
|
||||
ReadOnlySpan<MixParameter> parameters = MemoryMarshal.Cast<byte, MixParameter>(_input.Span[..(int)inputMixSize]);
|
||||
|
||||
_input = _input.Slice((int)inputMixSize);
|
||||
_input = _input[(int)inputMixSize..];
|
||||
|
||||
if (CheckMixParametersValidity(mixContext, mixBufferCount, mixCount, parameters))
|
||||
{
|
||||
@@ -506,25 +480,18 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||
{
|
||||
sink.CleanUp();
|
||||
|
||||
switch (parameter.Type)
|
||||
sink = parameter.Type switch
|
||||
{
|
||||
case SinkType.Invalid:
|
||||
sink = new BaseSink();
|
||||
break;
|
||||
case SinkType.CircularBuffer:
|
||||
sink = new CircularBufferSink();
|
||||
break;
|
||||
case SinkType.Device:
|
||||
sink = new DeviceSink();
|
||||
break;
|
||||
default:
|
||||
throw new NotImplementedException($"SinkType {parameter.Type} not implemented!");
|
||||
}
|
||||
SinkType.Invalid => new BaseSink(),
|
||||
SinkType.CircularBuffer => new CircularBufferSink(),
|
||||
SinkType.Device => new DeviceSink(),
|
||||
_ => throw new NotImplementedException($"SinkType {parameter.Type} not implemented!"),
|
||||
};
|
||||
}
|
||||
|
||||
public ResultCode UpdateSinks(SinkContext context, Memory<MemoryPoolState> memoryPools)
|
||||
{
|
||||
PoolMapper mapper = new PoolMapper(_processHandle, memoryPools, _behaviourContext.IsMemoryPoolForceMappingEnabled());
|
||||
PoolMapper mapper = new(_processHandle, memoryPools, _behaviourContext.IsMemoryPoolForceMappingEnabled());
|
||||
|
||||
if (context.GetCount() * Unsafe.SizeOf<SinkInParameter>() != _inputHeader.SinksSize)
|
||||
{
|
||||
@@ -533,9 +500,9 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||
|
||||
int initialOutputSize = _output.Length;
|
||||
|
||||
ReadOnlySpan<SinkInParameter> parameters = MemoryMarshal.Cast<byte, SinkInParameter>(_input.Slice(0, (int)_inputHeader.SinksSize).Span);
|
||||
ReadOnlySpan<SinkInParameter> parameters = MemoryMarshal.Cast<byte, SinkInParameter>(_input[..(int)_inputHeader.SinksSize].Span);
|
||||
|
||||
_input = _input.Slice((int)_inputHeader.SinksSize);
|
||||
_input = _input[(int)_inputHeader.SinksSize..];
|
||||
|
||||
for (int i = 0; i < context.GetCount(); i++)
|
||||
{
|
||||
@@ -640,4 +607,4 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||
return ResultCode.Success;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,6 +14,6 @@ namespace Ryujinx.Audio.Renderer.Server.Types
|
||||
/// Audio renderer operation needs to be done manually via ExecuteAudioRenderer.
|
||||
/// </summary>
|
||||
/// <remarks>This is not supported on the DSP and is as such stubbed.</remarks>
|
||||
Manual
|
||||
Manual,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,6 +19,6 @@ namespace Ryujinx.Audio.Renderer.Server.Types
|
||||
/// <remarks>
|
||||
/// Only supports <see cref="AudioRendererExecutionMode.Manual"/>.
|
||||
/// </remarks>
|
||||
Cpu
|
||||
Cpu,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,6 +34,6 @@ namespace Ryujinx.Audio.Renderer.Server.Types
|
||||
/// <remarks>
|
||||
/// The user can resume to the <see cref="Started"/> state.
|
||||
/// </remarks>
|
||||
Paused
|
||||
Paused,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,4 +11,4 @@ namespace Ryujinx.Audio.Renderer.Server.Upsampler
|
||||
public bool Initialized;
|
||||
public int Phase;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,22 +11,22 @@ namespace Ryujinx.Audio.Renderer.Server.Upsampler
|
||||
/// <summary>
|
||||
/// Work buffer for upsampler.
|
||||
/// </summary>
|
||||
private Memory<float> _upSamplerWorkBuffer;
|
||||
private readonly Memory<float> _upSamplerWorkBuffer;
|
||||
|
||||
/// <summary>
|
||||
/// Global lock of the object.
|
||||
/// </summary>
|
||||
private readonly object Lock = new();
|
||||
private readonly object _lock = new();
|
||||
|
||||
/// <summary>
|
||||
/// The upsamplers instances.
|
||||
/// </summary>
|
||||
private UpsamplerState[] _upsamplers;
|
||||
private readonly UpsamplerState[] _upsamplers;
|
||||
|
||||
/// <summary>
|
||||
/// The count of upsamplers.
|
||||
/// </summary>
|
||||
private uint _count;
|
||||
private readonly uint _count;
|
||||
|
||||
/// <summary>
|
||||
/// Create a new <see cref="UpsamplerManager"/>.
|
||||
@@ -49,7 +49,7 @@ namespace Ryujinx.Audio.Renderer.Server.Upsampler
|
||||
{
|
||||
int workBufferOffset = 0;
|
||||
|
||||
lock (Lock)
|
||||
lock (_lock)
|
||||
{
|
||||
for (int i = 0; i < _count; i++)
|
||||
{
|
||||
@@ -73,7 +73,7 @@ namespace Ryujinx.Audio.Renderer.Server.Upsampler
|
||||
/// <param name="index">The index of the <see cref="UpsamplerState"/> to free.</param>
|
||||
public void Free(int index)
|
||||
{
|
||||
lock (Lock)
|
||||
lock (_lock)
|
||||
{
|
||||
Debug.Assert(_upsamplers[index] != null);
|
||||
|
||||
@@ -81,4 +81,4 @@ namespace Ryujinx.Audio.Renderer.Server.Upsampler
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,12 +20,12 @@ namespace Ryujinx.Audio.Renderer.Server.Upsampler
|
||||
/// <summary>
|
||||
/// The index of the <see cref="UpsamplerState"/>. (used to free it)
|
||||
/// </summary>
|
||||
private int _index;
|
||||
private readonly int _index;
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="UpsamplerManager"/>.
|
||||
/// </summary>
|
||||
private UpsamplerManager _manager;
|
||||
private readonly UpsamplerManager _manager;
|
||||
|
||||
/// <summary>
|
||||
/// The source sample count.
|
||||
@@ -65,4 +65,4 @@ namespace Ryujinx.Audio.Renderer.Server.Upsampler
|
||||
_manager.Free(_index);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,4 +37,4 @@ namespace Ryujinx.Audio.Renderer.Server.Voice
|
||||
Mix.AsSpan().CopyTo(PreviousMix.AsSpan());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -126,7 +126,7 @@ namespace Ryujinx.Audio.Renderer.Server.Voice
|
||||
_sortedVoices.Span[i] = i;
|
||||
}
|
||||
|
||||
int[] sortedVoicesTemp = _sortedVoices.Slice(0, (int)GetCount()).ToArray();
|
||||
int[] sortedVoicesTemp = _sortedVoices[..(int)GetCount()].ToArray();
|
||||
|
||||
Array.Sort(sortedVoicesTemp, (a, b) =>
|
||||
{
|
||||
@@ -146,4 +146,4 @@ namespace Ryujinx.Audio.Renderer.Server.Voice
|
||||
sortedVoicesTemp.AsSpan().CopyTo(_sortedVoices.Span);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using Ryujinx.Audio.Common;
|
||||
using Ryujinx.Audio.Renderer.Common;
|
||||
using Ryujinx.Audio.Renderer.Dsp.State;
|
||||
using Ryujinx.Audio.Renderer.Parameter;
|
||||
using Ryujinx.Audio.Renderer.Server.MemoryPool;
|
||||
using Ryujinx.Common.Memory;
|
||||
@@ -9,6 +10,7 @@ using System.Diagnostics;
|
||||
using System.Runtime.InteropServices;
|
||||
using static Ryujinx.Audio.Renderer.Common.BehaviourParameter;
|
||||
using static Ryujinx.Audio.Renderer.Parameter.VoiceInParameter;
|
||||
using PlayState = Ryujinx.Audio.Renderer.Server.Types.PlayState;
|
||||
|
||||
namespace Ryujinx.Audio.Renderer.Server.Voice
|
||||
{
|
||||
@@ -65,12 +67,12 @@ namespace Ryujinx.Audio.Renderer.Server.Voice
|
||||
/// <summary>
|
||||
/// The current voice <see cref="Types.PlayState"/>.
|
||||
/// </summary>
|
||||
public Types.PlayState PlayState;
|
||||
public PlayState PlayState;
|
||||
|
||||
/// <summary>
|
||||
/// The previous voice <see cref="Types.PlayState"/>.
|
||||
/// </summary>
|
||||
public Types.PlayState PreviousPlayState;
|
||||
public PlayState PreviousPlayState;
|
||||
|
||||
/// <summary>
|
||||
/// The priority of the voice.
|
||||
@@ -192,7 +194,7 @@ namespace Ryujinx.Audio.Renderer.Server.Voice
|
||||
DataSourceStateUnmapped = false;
|
||||
BufferInfoUnmapped = false;
|
||||
FlushWaveBufferCount = 0;
|
||||
PlayState = Types.PlayState.Stopped;
|
||||
PlayState = PlayState.Stopped;
|
||||
Priority = Constants.VoiceLowestPriority;
|
||||
Id = 0;
|
||||
NodeId = 0;
|
||||
@@ -202,7 +204,7 @@ namespace Ryujinx.Audio.Renderer.Server.Voice
|
||||
Pitch = 0.0f;
|
||||
Volume = 0.0f;
|
||||
PreviousVolume = 0.0f;
|
||||
BiquadFilters.AsSpan().Fill(new BiquadFilterParameter());
|
||||
BiquadFilters.AsSpan().Clear();
|
||||
WaveBuffersCount = 0;
|
||||
WaveBuffersIndex = 0;
|
||||
MixId = Constants.UnusedMixId;
|
||||
@@ -233,7 +235,7 @@ namespace Ryujinx.Audio.Renderer.Server.Voice
|
||||
/// Check if the voice needs to be skipped.
|
||||
/// </summary>
|
||||
/// <returns>Returns true if the voice needs to be skipped.</returns>
|
||||
public bool ShouldSkip()
|
||||
public readonly bool ShouldSkip()
|
||||
{
|
||||
return !InUse || WaveBuffersCount == 0 || DataSourceStateUnmapped || BufferInfoUnmapped || VoiceDropFlag;
|
||||
}
|
||||
@@ -242,7 +244,7 @@ namespace Ryujinx.Audio.Renderer.Server.Voice
|
||||
/// Return true if the mix has any destinations.
|
||||
/// </summary>
|
||||
/// <returns>True if the mix has any destinations.</returns>
|
||||
public bool HasAnyDestination()
|
||||
public readonly bool HasAnyDestination()
|
||||
{
|
||||
return MixId != Constants.UnusedMixId || SplitterId != Constants.UnusedSplitterId;
|
||||
}
|
||||
@@ -252,7 +254,7 @@ namespace Ryujinx.Audio.Renderer.Server.Voice
|
||||
/// </summary>
|
||||
/// <param name="parameter">The user parameter.</param>
|
||||
/// <returns>Return true, if the server voice information needs to be updated.</returns>
|
||||
private bool ShouldUpdateParameters(ref VoiceInParameter parameter)
|
||||
private readonly bool ShouldUpdateParameters(ref VoiceInParameter parameter)
|
||||
{
|
||||
if (DataSourceStateAddressInfo.CpuAddress == parameter.DataSourceStateAddress)
|
||||
{
|
||||
@@ -338,31 +340,31 @@ namespace Ryujinx.Audio.Renderer.Server.Voice
|
||||
/// Update the internal play state from user play state.
|
||||
/// </summary>
|
||||
/// <param name="userPlayState">The target user play state.</param>
|
||||
public void UpdatePlayState(PlayState userPlayState)
|
||||
public void UpdatePlayState(Common.PlayState userPlayState)
|
||||
{
|
||||
Types.PlayState oldServerPlayState = PlayState;
|
||||
PlayState oldServerPlayState = PlayState;
|
||||
|
||||
PreviousPlayState = oldServerPlayState;
|
||||
|
||||
Types.PlayState newServerPlayState;
|
||||
PlayState newServerPlayState;
|
||||
|
||||
switch (userPlayState)
|
||||
{
|
||||
case Common.PlayState.Start:
|
||||
newServerPlayState = Types.PlayState.Started;
|
||||
newServerPlayState = PlayState.Started;
|
||||
break;
|
||||
|
||||
case Common.PlayState.Stop:
|
||||
if (oldServerPlayState == Types.PlayState.Stopped)
|
||||
if (oldServerPlayState == PlayState.Stopped)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
newServerPlayState = Types.PlayState.Stopping;
|
||||
newServerPlayState = PlayState.Stopping;
|
||||
break;
|
||||
|
||||
case Common.PlayState.Pause:
|
||||
newServerPlayState = Types.PlayState.Paused;
|
||||
newServerPlayState = PlayState.Paused;
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -434,7 +436,7 @@ namespace Ryujinx.Audio.Renderer.Server.Voice
|
||||
|
||||
for (int i = 0; i < parameter.ChannelCount; i++)
|
||||
{
|
||||
voiceUpdateStates[i].Span[0].IsWaveBufferValid.Fill(false);
|
||||
voiceUpdateStates[i].Span[0].IsWaveBufferValid.Clear();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -530,7 +532,7 @@ namespace Ryujinx.Audio.Renderer.Server.Voice
|
||||
|
||||
Memory<VoiceUpdateState> dspSharedState = context.GetUpdateStateForDsp(channelResourceId);
|
||||
|
||||
MemoryMarshal.Cast<VoiceUpdateState, byte>(dspSharedState.Span).Fill(0);
|
||||
MemoryMarshal.Cast<VoiceUpdateState, byte>(dspSharedState.Span).Clear();
|
||||
|
||||
voiceChannelResource.UpdateState();
|
||||
}
|
||||
@@ -579,7 +581,7 @@ namespace Ryujinx.Audio.Renderer.Server.Voice
|
||||
|
||||
switch (PlayState)
|
||||
{
|
||||
case Types.PlayState.Started:
|
||||
case PlayState.Started:
|
||||
for (int i = 0; i < WaveBuffers.Length; i++)
|
||||
{
|
||||
ref WaveBuffer wavebuffer = ref WaveBuffers[i];
|
||||
@@ -611,7 +613,7 @@ namespace Ryujinx.Audio.Renderer.Server.Voice
|
||||
|
||||
return false;
|
||||
|
||||
case Types.PlayState.Stopping:
|
||||
case PlayState.Stopping:
|
||||
for (int i = 0; i < WaveBuffers.Length; i++)
|
||||
{
|
||||
ref WaveBuffer wavebuffer = ref WaveBuffers[i];
|
||||
@@ -638,18 +640,18 @@ namespace Ryujinx.Audio.Renderer.Server.Voice
|
||||
|
||||
voiceUpdateState.Offset = 0;
|
||||
voiceUpdateState.PlayedSampleCount = 0;
|
||||
voiceUpdateState.Pitch.AsSpan().Fill(0);
|
||||
voiceUpdateState.Pitch.AsSpan().Clear();
|
||||
voiceUpdateState.Fraction = 0;
|
||||
voiceUpdateState.LoopContext = new Dsp.State.AdpcmLoopContext();
|
||||
voiceUpdateState.LoopContext = new AdpcmLoopContext();
|
||||
}
|
||||
|
||||
PlayState = Types.PlayState.Stopped;
|
||||
WasPlaying = PreviousPlayState == Types.PlayState.Started;
|
||||
PlayState = PlayState.Stopped;
|
||||
WasPlaying = PreviousPlayState == PlayState.Started;
|
||||
|
||||
return WasPlaying;
|
||||
|
||||
case Types.PlayState.Stopped:
|
||||
case Types.PlayState.Paused:
|
||||
case PlayState.Stopped:
|
||||
case PlayState.Paused:
|
||||
foreach (ref WaveBuffer wavebuffer in WaveBuffers.AsSpan())
|
||||
{
|
||||
wavebuffer.BufferAddressInfo.GetReference(true);
|
||||
@@ -664,7 +666,7 @@ namespace Ryujinx.Audio.Renderer.Server.Voice
|
||||
}
|
||||
}
|
||||
|
||||
WasPlaying = PreviousPlayState == Types.PlayState.Started;
|
||||
WasPlaying = PreviousPlayState == PlayState.Started;
|
||||
|
||||
return WasPlaying;
|
||||
default:
|
||||
@@ -696,4 +698,4 @@ namespace Ryujinx.Audio.Renderer.Server.Voice
|
||||
return UpdateParametersForCommandGeneration(voiceUpdateStates);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,10 +71,11 @@ namespace Ryujinx.Audio.Renderer.Server.Voice
|
||||
/// <returns>A new <see cref="Common.WaveBuffer"/> for use by the <see cref="Dsp.AudioProcessor"/>.</returns>
|
||||
public Common.WaveBuffer ToCommon(int version)
|
||||
{
|
||||
Common.WaveBuffer waveBuffer = new Common.WaveBuffer();
|
||||
|
||||
waveBuffer.Buffer = BufferAddressInfo.GetReference(true);
|
||||
waveBuffer.BufferSize = (uint)BufferAddressInfo.Size;
|
||||
Common.WaveBuffer waveBuffer = new()
|
||||
{
|
||||
Buffer = BufferAddressInfo.GetReference(true),
|
||||
BufferSize = (uint)BufferAddressInfo.Size,
|
||||
};
|
||||
|
||||
if (ContextAddressInfo.CpuAddress != 0)
|
||||
{
|
||||
@@ -101,4 +102,4 @@ namespace Ryujinx.Audio.Renderer.Server.Voice
|
||||
return waveBuffer;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user