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();
 }
Example #2
0
 public void Dispose()
 {
     if (_CallBack != null)
     {
         Marshal.ThrowExceptionForHR(_AudioEndPointVolume.UnregisterControlChangeNotify(_CallBack));
         _CallBack = null;
     }
 }
Example #3
0
 protected override void Dispose(bool disposing)
 {
     if (callBack != null)
     {
         audioEndPointVolume.UnregisterControlChangeNotify(callBack);
         callBack = null;
     }
 }
Example #4
0
 /// <summary>
 /// Dispose
 /// </summary>
 public void Dispose()
 {
     if (callBack != null)
     {
         Marshal.ThrowExceptionForHR(audioEndPointVolume.UnregisterControlChangeNotify(callBack));
         callBack = null;
     }
     GC.SuppressFinalize(this);
 }
Example #5
0
        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.
 }
Example #8
0
 public void Dispose()
 {
     if (_CallBack != null)
     {
         try
         {
             Marshal.ThrowExceptionForHR(_AudioEndPointVolume.UnregisterControlChangeNotify(_CallBack));
         }
         catch (Exception)
         {
             // Catch if no device is found
         }
         _CallBack = null;
     }
 }