Beispiel #1
0
        private void updateAvailableAudioDevices()
        {
            var currentDeviceList  = getAllDevices().Where(d => d.IsEnabled).ToList();
            var currentDeviceNames = getDeviceNames(currentDeviceList).ToList();

            var newDevices  = currentDeviceNames.Except(audioDeviceNames).ToList();
            var lostDevices = audioDeviceNames.Except(currentDeviceNames).ToList();

            if (newDevices.Count > 0 || lostDevices.Count > 0)
            {
                eventScheduler.Add(delegate
                {
                    foreach (var d in newDevices)
                    {
                        OnNewDevice?.Invoke(d);
                    }
                    foreach (var d in lostDevices)
                    {
                        OnLostDevice?.Invoke(d);
                    }
                });
            }

            audioDevices     = currentDeviceList;
            audioDeviceNames = currentDeviceNames;
        }
        private void syncCameraDevices()
        {
            var updatedCameraDevices = EnumerateAllDevices().ToImmutableList();

            if (devices.SequenceEqual(updatedCameraDevices, cameraInfoComparer))
            {
                return;
            }

            devices = updatedCameraDevices;

            onDevicesChanged();

            var oldDeviceNames = deviceNames;
            var newDeviceNames = deviceNames = devices.Select(d => d.Name).ToImmutableList();

            var addedDevices = newDeviceNames.Except(oldDeviceNames).ToList();
            var lostDevices  = oldDeviceNames.Except(newDeviceNames).ToList();

            if (addedDevices.Count > 0 || lostDevices.Count > 0)
            {
                scheduler.Add(delegate
                {
                    foreach (var d in addedDevices)
                    {
                        OnNewDevice?.Invoke(d);
                    }

                    foreach (var d in lostDevices)
                    {
                        OnLostDevice?.Invoke(d);
                    }
                });
            }
        }
Beispiel #3
0
        private void updateAvailableAudioDevices()
        {
            audioDevices = EnumerateAllDevices().ToList();

            // Bass should always be providing "No sound" device
            Trace.Assert(audioDevices.Count > 0, "Bass did not provide any audio devices.");

            var oldDeviceNames = audioDeviceNames;
            var newDeviceNames = audioDeviceNames = audioDevices.Skip(1).Where(d => d.IsEnabled).Select(d => d.Name).ToList();

            var newDevices  = newDeviceNames.Except(oldDeviceNames).ToList();
            var lostDevices = oldDeviceNames.Except(newDeviceNames).ToList();

            if (newDevices.Count > 0 || lostDevices.Count > 0)
            {
                eventScheduler.Add(delegate
                {
                    foreach (var d in newDevices)
                    {
                        OnNewDevice?.Invoke(d);
                    }
                    foreach (var d in lostDevices)
                    {
                        OnLostDevice?.Invoke(d);
                    }
                });
            }
        }
Beispiel #4
0
        private void syncCameraDevices()
        {
            var updatedCameraDevices = EnumerateAllDevices().ToImmutableList();

            if (cameraDevices.SequenceEqual(updatedCameraDevices, updateComparer))
            {
                return;
            }

            cameraDevices = updatedCameraDevices;

            var oldDeviceNames = cameraDeviceNames;
            var newDeviceNames = cameraDeviceNames = cameraDevices.Select(d => d.Name).ToImmutableList();

            var newDevices  = newDeviceNames.Except(oldDeviceNames).ToList();
            var lostDevices = oldDeviceNames.Except(newDeviceNames).ToList();

            if (newDevices.Count > 0 || lostDevices.Count > 0)
            {
                eventScheduler.Add(delegate
                {
                    foreach (var d in newDevices)
                    {
                        OnNewDevice?.Invoke(d);
                    }
                    foreach (var d in lostDevices)
                    {
                        OnLostDevice?.Invoke(d);
                    }
                });
            }
        }
        private void syncAudioDevices()
        {
            // audioDevices are updated if:
            // - A new device is added
            // - An existing device is Enabled/Disabled or set as Default
            var updatedAudioDevices = EnumerateAllDevices().ToImmutableList();

            if (audioDevices.SequenceEqual(updatedAudioDevices, updateComparer))
            {
                return;
            }

            audioDevices = updatedAudioDevices;

            // Bass should always be providing "No sound" and "Default" device.
            Trace.Assert(audioDevices.Count >= 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();

            onDevicesChanged();

            var newDevices  = newDeviceNames.Except(oldDeviceNames).ToList();
            var lostDevices = oldDeviceNames.Except(newDeviceNames).ToList();

            if (newDevices.Count > 0 || lostDevices.Count > 0)
            {
                eventScheduler.Add(delegate
                {
                    foreach (string d in newDevices)
                    {
                        OnNewDevice?.Invoke(d);
                    }
                    foreach (string d in lostDevices)
                    {
                        OnLostDevice?.Invoke(d);
                    }
                });
            }
        }