// Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using osu.Framework.Allocation; using osu.Framework.Audio; using osu.Framework.Graphics; using System.Collections.Generic; using System.Linq; namespace osu.Game.Overlays.Options.Sections.Audio { public class AudioDevicesOptions : OptionsSubsection { protected override string Header => "Devices"; private AudioManager audio; private OptionDropDown dropdown; [BackgroundDependencyLoader] private void load(AudioManager audio) { this.audio = audio; } protected override void Dispose(bool isDisposing) { base.Dispose(isDisposing); audio.OnNewDevice -= onDeviceChanged; audio.OnLostDevice -= onDeviceChanged; } private void updateItems() { var deviceItems = new List>(); deviceItems.Add(new KeyValuePair("Default", string.Empty)); deviceItems.AddRange(audio.AudioDeviceNames.Select(d => new KeyValuePair(d, d))); dropdown.Items = deviceItems; } private void onDeviceChanged(string name) => updateItems(); protected override void LoadComplete() { base.LoadComplete(); Children = new Drawable[] { dropdown = new OptionDropDown() { Bindable = audio.AudioDevice }, }; updateItems(); audio.OnNewDevice += onDeviceChanged; audio.OnLostDevice += onDeviceChanged; } } }