diff --git a/SoundSwitch/Framework/Configuration/Device/DeviceInfoCollection.cs b/SoundSwitch/Framework/Configuration/Device/DeviceInfoCollection.cs index f6d297c495..61ffb3d897 100644 --- a/SoundSwitch/Framework/Configuration/Device/DeviceInfoCollection.cs +++ b/SoundSwitch/Framework/Configuration/Device/DeviceInfoCollection.cs @@ -30,13 +30,21 @@ public DeviceInfoCollection(HashSet devices) /// public IEnumerable IntersectWith(IEnumerable devices) { - var result = devices.Join(_deviceById, device => device.ID, pair => pair.Key, (device, pair) => device); - if (result.GetEnumerator().Current != null) + var devicesResult = new Dictionary(); + foreach (var mmDevice in devices) { - return result; + if (devicesResult.ContainsKey(mmDevice.ID)) + continue; + + if (!_deviceById.ContainsKey(mmDevice.ID) && !_deviceByName.ContainsKey(mmDevice.FriendlyName)) + continue; + + devicesResult.Add(mmDevice.ID, mmDevice); + } - return devices.Join(_deviceByName, device => device.FriendlyName, pair => pair.Key, (device, pair) => device); + return devicesResult.Values; + } public IEnumerator GetEnumerator()