private MMDevice GetDefaultAudioEndpoint(DataFlow dataFlow, Role deviceRole)
 {
     if (AudioMMDevices == null)
     {
         return(null);
     }
     if (!AudioMMDevices.HasDefaultAudioEndpoint(dataFlow, deviceRole))
     {
         return(null);
     }
     return(AudioMMDevices.GetDefaultAudioEndpointSafeException(DataFlow.Render, Role.Multimedia, !_disposed));
 }
        public void OnDefaultDeviceChanged(DataFlow dataFlow, Role deviceRole, string defaultDeviceId)
        {
            if (AudioMMDevices == null)
            {
                return;
            }
            if (!AudioMMDevices.HasDefaultAudioEndpoint(dataFlow, deviceRole))
            {
                return;
            }

            if (DefaultAudioEndPointDeviceID != null && _defaultEndpointVolumeController != null)
            {
                _defaultEndpointVolumeController.AudioEndpointVolume.OnVolumeNotification -=
                    AudioEndpointVolume_OnVolumeNotification;
            }

            SetDefaultAudioEndpoint(dataFlow, deviceRole);
        }