Example #1
0
        public void Dispose()
        {
            int hr = _deviceEnumerator.UnregisterEndpointNotificationCallback(this);

            if (hr != HResult.OK)
            {
                throw Marshal.GetExceptionForHR(hr);
            }
        }
 /* added -> */
 public void Dispose()
 {
     if (_notificationClient != null)
     {
         int hr = _realEnumerator.UnregisterEndpointNotificationCallback(_notificationClient);
         Marshal.ThrowExceptionForHR(hr);
         _notificationClient = null;
     }
     if (_realEnumerator != null)
     {
         Marshal.ReleaseComObject(_realEnumerator);
     }
 }
Example #3
0
        /// <summary>
        /// Unregisters a call back for Device Events
        /// </summary>
        /// <param name="client">Object implementing IMMNotificationClient type casted as IMMNotificationClient interface </param>
        /// <returns></returns>
        public int UnregisterEndpointNotificationCallback([In][MarshalAs(UnmanagedType.Interface)] IMMNotificationClient client)
        {
            if (!_notificationClients.Contains(client))
            {
                return(0);
            }

            var hresult = _mmDeviceEnumerator.UnregisterEndpointNotificationCallback(client);

            Marshal.ThrowExceptionForHR(hresult);

            _notificationClients.Remove(client);
            return(hresult);
        }
Example #4
0
 internal static void AudioDevicesClientClose()
 {
     if (pm_AudioDevicesCallback != null)
     {
         try
         {
             IMMDeviceEnumerator deviceEnumerator = (IMMDeviceEnumerator)(new MMDeviceEnumerator());
             deviceEnumerator.UnregisterEndpointNotificationCallback(pm_AudioDevicesCallback);
             pm_AudioDevicesCallback  = null;
             pm_AudioDevicesEventArgs = null;
             if (deviceEnumerator != null)
             {
                 Marshal.ReleaseComObject(deviceEnumerator); deviceEnumerator = null;
             }
         }
         catch { /* ignore */ }
     }
 }
        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);
        }
 /// <summary>
 /// Unregisters a call back for Device Events
 /// </summary>
 /// <param name="client">Object implementing IMMNotificationClient type casted as IMMNotificationClient interface </param>
 /// <returns></returns>
 public int UnregisterEndpointNotificationCallback(
     [In][MarshalAs(UnmanagedType.Interface)] IMMNotificationClient client)
 {
     return(realEnumerator.UnregisterEndpointNotificationCallback(client));
 }
Example #7
0
 /// <summary>
 /// Deletes the registration of a notification interface that the client registered in a previous call
 /// to the <see cref="IMMDeviceEnumerator.RegisterEndpointNotificationCallback"/> method.
 /// </summary>
 /// <param name="client">A <see cref="IMMNotificationClient"/> interface that was previously registered for notification callbacks.</param>
 /// <returns>An HRESULT code indicating whether the operation passed of failed.</returns>
 public void UnregisterEndpointNotificationCallback(IMMNotificationClient client)
 {
     Marshal.ThrowExceptionForHR(_realEnumerator.UnregisterEndpointNotificationCallback(client));
 }
 private void Dispose(bool disposing)
 {
     _deviceEnumerator.UnregisterEndpointNotificationCallback(this);
     Marshal.ReleaseComObject(_deviceEnumerator);
 }
 public void UnregisterEndpointNotificationCallback(IMMNotificationClient client)
 {
     _realEnumerator.UnregisterEndpointNotificationCallback(client);
 }
Example #10
0
 public void UnregisterEndpointNotificationCallback(IMMNotificationClient client)
 {
     _inner.UnregisterEndpointNotificationCallback(client);
 }