private void Mute(bool mute) { if (muteDevice == null) { return; } try { syncContext.Send(x => { if (muteDevice.IsMuted == mute) { return; } bool result = muteDevice.Mute(mute); MutedChanged?.Invoke(this, EventArgs.Empty); }, null); } catch (Exception ex) { Debug.WriteLine($"Exception muting/unmuting: {ex}"); // Ummute failed: schedule retry. if (!mute) { timer.Change(UnmuteTimeMs, Timeout.Infinite); } } }
private void GetMicrophoneState() { var oldState = _isMuted; _isMuted = _muteControl.Value; if (oldState != _isMuted) { MutedChanged?.Invoke(this, _isMuted); } }
private bool Mute(bool mute) { if (muteDevice == null) { return(false); } bool result = muteDevice.Mute(mute); MutedChanged?.Invoke(this, EventArgs.Empty); return(result); }
public void ChangeToOpposite() { try { _muteControl.Value = !_muteControl.Value; var oldState = _isMuted; _isMuted = _muteControl.Value; if (oldState != _isMuted) { MutedChanged?.Invoke(this, _isMuted.Value); } } catch { //no actions required } }
private void Refresh() { try { _muteControl = GetMuteControl(); GetMicrophoneState(); } catch (Exception ex) { if (_lastError != ex.Message) { _lastError = ex.Message; ErrorChanged?.Invoke(this, _lastError); } var oldState = _isMuted; _isMuted = null; if (oldState != _isMuted) { MutedChanged?.Invoke(this, null); } } }