using System.Diagnostics;
namespace Ryujinx.Audio.Renderer.Device
{
/// <summary>
/// Represents a virtual device used by IAudioDevice.
/// </summary>
public class VirtualDevice
/// All the defined virtual devices.
public static readonly VirtualDevice[] Devices = new VirtualDevice[5]
new VirtualDevice("AudioStereoJackOutput", 2, true),
new VirtualDevice("AudioBuiltInSpeakerOutput", 2, false),
new VirtualDevice("AudioTvOutput", 6, false),
new VirtualDevice("AudioUsbDeviceOutput", 2, true),
new VirtualDevice("AudioExternalOutput", 6, true),
};
/// The name of the <see cref="VirtualDevice"/>.
public string Name { get; }
/// The count of channels supported by the <see cref="VirtualDevice"/>.
public uint ChannelCount { get; }
/// The system master volume of the <see cref="VirtualDevice"/>.
public float MasterVolume { get; private set; }
/// Define if the <see cref="VirtualDevice"/> is provided by an external interface.
public bool IsExternalOutput { get; }
/// Create a new <see cref="VirtualDevice"/> instance.
/// <param name="name">The name of the <see cref="VirtualDevice"/>.</param>
/// <param name="channelCount">The count of channels supported by the <see cref="VirtualDevice"/>.</param>
/// <param name="isExternalOutput">Indicate if the <see cref="VirtualDevice"/> is provided by an external interface.</param>
private VirtualDevice(string name, uint channelCount, bool isExternalOutput)
Name = name;
ChannelCount = channelCount;
IsExternalOutput = isExternalOutput;
}
/// Update the master volume of the <see cref="VirtualDevice"/>.
/// <param name="volume">The new master volume.</param>
public void UpdateMasterVolume(float volume)
Debug.Assert(volume >= 0.0f && volume <= 1.0f);
MasterVolume = volume;
/// Check if the <see cref="VirtualDevice"/> is a usb device.
/// <returns>Returns true if the <see cref="VirtualDevice"/> is a usb device.</returns>
public bool IsUsbDevice()
return Name.Equals("AudioUsbDeviceOutput");
/// Get the output device name of the <see cref="VirtualDevice"/>.
/// <returns>The output device name of the <see cref="VirtualDevice"/>.</returns>
public string GetOutputDeviceName()
if (IsExternalOutput)
return "AudioExternalOutput";
return Name;