diff --git a/osu.Framework/Audio/AudioManager.cs b/osu.Framework/Audio/AudioManager.cs index 8b0381ab89..1d5803ce73 100644 --- a/osu.Framework/Audio/AudioManager.cs +++ b/osu.Framework/Audio/AudioManager.cs @@ -69,7 +69,7 @@ public class AudioManager : AudioCollectionManager public readonly AudioMixer SampleMixer; /// - /// The names of all available audio devices. + /// All available audio device names along with their driver names. /// /// /// @@ -80,7 +80,7 @@ public class AudioManager : AudioCollectionManager /// Consumers should provide a "Default" audio device entry which sets to an empty string. /// /// - public IEnumerable AudioDeviceNames => audioDeviceNames; + public IEnumerable<(string Name, string Driver)> AudioDeviceNames => audioDeviceNames; /// /// Is fired whenever a new audio device is discovered and provides its name. @@ -153,7 +153,7 @@ public class AudioManager : AudioCollectionManager // Mutated by multiple threads, must be thread safe. private ImmutableArray audioDevices = ImmutableArray.Empty; - private ImmutableList audioDeviceNames = ImmutableList.Empty; + private ImmutableList<(string Name, string Driver)> audioDeviceNames = ImmutableList<(string Name, string Driver)>.Empty; private Scheduler scheduler => thread.Scheduler; @@ -335,7 +335,7 @@ private void initCurrentDevice() string deviceName = AudioDevice.Value; // try using the specified device - int deviceIndex = audioDeviceNames.FindIndex(d => d == deviceName); + int deviceIndex = audioDeviceNames.FindIndex(d => d.Name == deviceName); if (deviceIndex >= 0 && trySetDevice(BASS_INTERNAL_DEVICE_COUNT + deviceIndex)) return; // try using the system default if there is any device present. @@ -480,7 +480,10 @@ private void syncAudioDevices() Trace.Assert(audioDevices.Length >= BASS_INTERNAL_DEVICE_COUNT, "Bass did not provide any audio devices."); var oldDeviceNames = audioDeviceNames; - var newDeviceNames = audioDeviceNames = audioDevices.Skip(BASS_INTERNAL_DEVICE_COUNT).Where(d => d.IsEnabled).Select(d => d.Name).ToImmutableList(); + var newDeviceNames = audioDeviceNames = audioDevices.Skip(BASS_INTERNAL_DEVICE_COUNT) + .Where(d => d.IsEnabled) + .Select(d => (d.Name, d.Driver)) + .ToImmutableList(); scheduler.Add(() => { @@ -498,9 +501,9 @@ private void syncAudioDevices() { eventScheduler.Add(delegate { - foreach (string d in newDevices) + foreach (string d in newDevices.Select(d => d.Name)) OnNewDevice?.Invoke(d); - foreach (string d in lostDevices) + foreach (string d in lostDevices.Select(d => d.Name)) OnLostDevice?.Invoke(d); }); }