mirror of
https://git.naxdy.org/Mirror/Ryujinx.git
synced 2025-03-25 09:20:17 +00:00
* 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>
81 lines
2.9 KiB
C#
81 lines
2.9 KiB
C#
using Ryujinx.Audio.Integration;
|
|
using System.Collections.Generic;
|
|
|
|
namespace Ryujinx.Audio.Renderer.Device
|
|
{
|
|
/// <summary>
|
|
/// Represent an instance containing a registry of <see cref="VirtualDeviceSession"/>.
|
|
/// </summary>
|
|
public class VirtualDeviceSessionRegistry
|
|
{
|
|
/// <summary>
|
|
/// The session registry, used to store the sessions of a given AppletResourceId.
|
|
/// </summary>
|
|
private readonly Dictionary<ulong, VirtualDeviceSession[]> _sessionsRegistry = new();
|
|
|
|
/// <summary>
|
|
/// The default <see cref="VirtualDevice"/>.
|
|
/// </summary>
|
|
/// <remarks>This is used when the USB device is the default one on older revision.</remarks>
|
|
#pragma warning disable CA1822 // Mark member as static
|
|
public VirtualDevice DefaultDevice => VirtualDevice.Devices[0];
|
|
#pragma warning restore CA1822
|
|
|
|
/// <summary>
|
|
/// The current active <see cref="VirtualDevice"/>.
|
|
/// </summary>
|
|
// TODO: make this configurable
|
|
public VirtualDevice ActiveDevice { get; }
|
|
|
|
public VirtualDeviceSessionRegistry(IHardwareDeviceDriver driver)
|
|
{
|
|
uint channelCount;
|
|
|
|
if (driver.GetRealDeviceDriver().SupportsChannelCount(6))
|
|
{
|
|
channelCount = 6;
|
|
}
|
|
else
|
|
{
|
|
channelCount = 2;
|
|
}
|
|
|
|
ActiveDevice = new VirtualDevice("AudioTvOutput", channelCount, false);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Get the associated <see cref="T:VirtualDeviceSession[]"/> from an AppletResourceId.
|
|
/// </summary>
|
|
/// <param name="resourceAppletId">The AppletResourceId used.</param>
|
|
/// <returns>The associated <see cref="T:VirtualDeviceSession[]"/> from an AppletResourceId.</returns>
|
|
public VirtualDeviceSession[] GetSessionByAppletResourceId(ulong resourceAppletId)
|
|
{
|
|
if (_sessionsRegistry.TryGetValue(resourceAppletId, out VirtualDeviceSession[] result))
|
|
{
|
|
return result;
|
|
}
|
|
|
|
result = CreateSessionsFromBehaviourContext();
|
|
|
|
_sessionsRegistry.Add(resourceAppletId, result);
|
|
|
|
return result;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Create a new array of sessions for each <see cref="VirtualDevice"/>.
|
|
/// </summary>
|
|
/// <returns>A new array of sessions for each <see cref="VirtualDevice"/>.</returns>
|
|
private static VirtualDeviceSession[] CreateSessionsFromBehaviourContext()
|
|
{
|
|
VirtualDeviceSession[] virtualDeviceSession = new VirtualDeviceSession[VirtualDevice.Devices.Length];
|
|
|
|
for (int i = 0; i < virtualDeviceSession.Length; i++)
|
|
{
|
|
virtualDeviceSession[i] = new VirtualDeviceSession(VirtualDevice.Devices[i]);
|
|
}
|
|
|
|
return virtualDeviceSession;
|
|
}
|
|
}
|
|
}
|