// Restore configuration settings into the active device list public void RestoreAudioDevices(Dictionary <String, UIWin.AudioDevice> sysdevs) { // Go through the devices found in the configuration. We only // restore settings for devices listed there; devices that are // present in the system but not listed in the configuration // are left with default settings. Every device is disabled // by default except for the device designated in the Windows // audio control panel as the "default" device, which is always // enabled. So the result is that we enable all of the devices // explicitly marked as enabled in the configuration, plus the // Windows default device. foreach (var v in devices) { // If this device exists in the system devices table, set up // the system device with the saved settings. If it doesn't // exist in the system devices table, ignore it. We leave // the entry in the configuration list so that it will still // take effect in future sessions if the device is installed // again later. if (sysdevs.ContainsKey(v.Key)) { // get the config record and system device entry CfgAudioDevice cfgdev = v.Value; UIWin.AudioDevice sysdev = sysdevs[v.Key]; // Copy the config settings to the system device entry. Note // that isActive is always set to true, since a device only // appears in the config list at all if it's active. sysdev.isActive = true; sysdev.relLevel = cfgdev.relVol / 100.0f; // adjust % value to normalized scale sysdev.useLocal = cfgdev.useLocal; } } }
public AudioOutputs(UIWin.AudioDevice[] devices, UIWin.AudioDevice defaultDevice) { this.devices = devices; this.defaultDevice = defaultDevice; InitializeComponent(); }