public override void UninitializeAudio() { if (null != _audioEndpointVolume) { _audioEndpointVolume.UnregisterControlChangeNotify(classCallBack); } if (null != _audioClient) { _audioClient.Stop(); } if (null != _audioMeter) { //For wait audio meter thread stop. then release memory Thread.Sleep(100); Marshal.ReleaseComObject(_audioMeter); _audioMeter = null; } if (null != _audioClient) { Marshal.ReleaseComObject(_audioClient); _audioClient = null; } if (null != _audioEndpointVolume) { Marshal.ReleaseComObject(_audioEndpointVolume); _audioEndpointVolume = null; } if (null != waveFormat) { waveFormat = null; } base.UninitializeAudio(); }
public void Dispose() { if (_CallBack != null) { Marshal.ThrowExceptionForHR(_AudioEndPointVolume.UnregisterControlChangeNotify(_CallBack)); _CallBack = null; } }
protected override void Dispose(bool disposing) { if (callBack != null) { audioEndPointVolume.UnregisterControlChangeNotify(callBack); callBack = null; } }
/// <summary> /// Dispose /// </summary> public void Dispose() { if (callBack != null) { Marshal.ThrowExceptionForHR(audioEndPointVolume.UnregisterControlChangeNotify(callBack)); callBack = null; } GC.SuppressFinalize(this); }
public void Dispose() { if (_callBack == null) { return; } Marshal.ThrowExceptionForHR(_audioEndpointVolume.UnregisterControlChangeNotify(_callBack)); _callBack = null; }
/// <summary> /// Dispose /// </summary> public void Dispose() { if (_callBack != null) { ComThread.BeginInvoke(() => { _audioEndPointVolume.UnregisterControlChangeNotify(_callBack); _callBack = null; _audioEndPointVolume = null; }); } GC.SuppressFinalize(this); }
// The bulk of the clean-up code is implemented in Dispose(bool) protected virtual void Dispose(bool disposing) { if (disposing) { // free managed resources here if (callBack != null) { Marshal.ThrowExceptionForHR(_AudioEndPointVolume.UnregisterControlChangeNotify(callBack)); callBack.Dispose(); callBack = null; } } // free native resources here if there are any. }
public void Dispose() { if (_CallBack != null) { try { Marshal.ThrowExceptionForHR(_AudioEndPointVolume.UnregisterControlChangeNotify(_CallBack)); } catch (Exception) { // Catch if no device is found } _CallBack = null; } }