private void ReloadAudioMeterInformation(IMMDevice device) { ComThread.BeginInvoke(() => { LoadAudioMeterInformation(device); }); }
private void Dispose(bool disposing) { if (_isDisposed) { return; } _timerSubscription?.Dispose(); _meterInformation.Dispose(); _simpleAudioVolume.Dispose(); _deviceMutedSubscription.Dispose(); _muteChanged.Dispose(); _stateChanged.Dispose(); _disconnected.Dispose(); _volumeChanged.Dispose(); _peakValueChanged.Dispose(); //Run this on the com thread to ensure it's disposed correctly ComThread.BeginInvoke(() => { AudioSessionControl.UnregisterAudioSessionNotification(this); }).ContinueWith(x => { _audioSessionControl.Dispose(); }); GC.SuppressFinalize(this); _isDisposed = true; }
public void Dispose() { _properties = null; ComThread.BeginInvoke(() => { _propertyStoreInteface = null; }); }
private async Task CreateSession(IAudioSessionControl sessionControl) { var managedSession = await ComThread.BeginInvoke(() => CacheSessionWrapper(sessionControl)).ConfigureAwait(false); if (managedSession != null) { OnSessionCreated(managedSession); } }
private void HandlePropertyChanged(DevicePropertyChangedEventArgs propertyChangedEvent) { ComThread.BeginInvoke(() => { LoadProperties(_device); }) .ContinueWith(x => { OnPropertyChanged(propertyChangedEvent.PropertyName); }); }
private void ReloadAudioEndpointVolume(IMMDevice device) { ComThread.BeginInvoke(() => { LoadAudioEndpointVolume(device); if (AudioEndpointVolume != null) { AudioEndpointVolume.OnVolumeNotification += AudioEndpointVolume_OnVolumeNotification; } }); }
/// <summary> /// Dispose /// </summary> public void Dispose() { if (_callBack != null) { ComThread.BeginInvoke(() => { _audioEndPointVolume.UnregisterControlChangeNotify(_callBack); _callBack = null; _audioEndPointVolume = null; }); } GC.SuppressFinalize(this); }
private void OnPropertyChanged(PropertyKey propertyKey) { ComThread.BeginInvoke(LoadProperties).ContinueWith(x => { //Ignore the properties we don't care about if (!PropertykeyToPropertyMap.ContainsKey(propertyKey)) { return; } foreach (var propName in PropertykeyToPropertyMap[propertyKey]) { OnPropertyChanged(propName); } }); }
private void OnStateChanged(EDeviceState deviceState) { _state = deviceState; ReloadAudioEndpointVolume(); ReloadAudioMeterInformation(); ReloadAudioSessionController(); OnStateChanged(deviceState.AsDeviceState()); //only load properties if it's active if ((deviceState & EDeviceState.Active) != 0) { //Attempt to reload properties if the device has become active. //A fail-safe incase the device doesn't fire property changed events //when it becomes "active" ComThread.BeginInvoke(LoadProperties); } }
protected override void Dispose(bool disposing) { if (_innerEnumerator != null) { ComThread.BeginInvoke(() => { _innerEnumerator.UnregisterEndpointNotificationCallback(_notificationClient); _notificationClient = null; _innerEnumerator = null; }); } _deviceCache = null; if (_lock != null) { _lock.Dispose(); } GC.SuppressFinalize(this); }
protected override void Dispose(bool disposing) { if (!_isDisposed) { _properties?.Dispose(); _peakValueTimerSubscription?.Dispose(); ComThread.BeginInvoke(() => { ClearAudioEndpointVolume(); ClearAudioMeterInformation(); ClearAudioSession(); _device = null; }); _isDisposed = true; } base.Dispose(disposing); }
protected override void Dispose(bool disposing) { ComThread.BeginInvoke(() => { _systemEvents?.Dispose(); _systemEvents = null; }) .ContinueWith(x => { foreach (var device in _deviceCache) { device.Dispose(); } _deviceCache?.Clear(); _lock?.Dispose(); _innerEnumerator?.Dispose(); base.Dispose(disposing); GC.SuppressFinalize(this); }); }