Handle preferred audio device correctly when it is unavailable

This commit allows loading, storing, and displaying a preferred audio
device from config even when it is unavailable.
This commit is contained in:
Thomas Müller 2017-02-11 16:33:54 +01:00
parent d79c8b9695
commit d3380631e8

View File

@ -35,6 +35,11 @@ namespace osu.Game.Overlays.Options.Sections.Audio
var deviceItems = new List<KeyValuePair<string, string>>();
deviceItems.Add(new KeyValuePair<string, string>("Default", string.Empty));
deviceItems.AddRange(audio.AudioDeviceNames.Select(d => new KeyValuePair<string, string>(d, d)));
var preferredDeviceName = audio.AudioDevice.Value;
if (!deviceItems.Any(kv => kv.Value == preferredDeviceName))
deviceItems.Add(new KeyValuePair<string, string>(preferredDeviceName, preferredDeviceName));
dropdown.Items = deviceItems;
}