// // Copyright (c) 2019-2021 Ryujinx // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Lesser General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with this program. If not, see . // using System.Diagnostics; namespace Ryujinx.Audio.Renderer.Device { /// /// Represents a virtual device used by IAudioDevice. /// 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 . /// public string Name { get; } /// /// The count of channels supported by the . /// public uint ChannelCount { get; } /// /// The system master volume of the . /// public float MasterVolume { get; private set; } /// /// Define if the is provided by an external interface. /// public bool IsExternalOutput { get; } /// /// Create a new instance. /// /// The name of the . /// The count of channels supported by the . /// Indicate if the is provided by an external interface. private VirtualDevice(string name, uint channelCount, bool isExternalOutput) { Name = name; ChannelCount = channelCount; IsExternalOutput = isExternalOutput; } /// /// Update the master volume of the . /// /// The new master volume. public void UpdateMasterVolume(float volume) { Debug.Assert(volume >= 0.0f && volume <= 1.0f); MasterVolume = volume; } /// /// Check if the is a usb device. /// /// Returns true if the is a usb device. public bool IsUsbDevice() { return Name.Equals("AudioUsbDeviceOutput"); } /// /// Get the output device name of the . /// /// The output device name of the . public string GetOutputDeviceName() { if (IsExternalOutput) { return "AudioExternalOutput"; } return Name; } } }