示例#1
0
        public void CanAccessPropertyStore()
        {
            using (var enumerator = new MMDeviceEnumerator())
            using (var collection = enumerator.EnumAudioEndpoints(DataFlow.All, DeviceState.All))
            {
                Utils.DumpCollection(collection);

                enumerator.Dispose();
                collection.Dispose();
            }
        }
        /// <summary>
        /// Disposes und unregisters the <see cref="MMNotificationClient"/>.
        /// </summary>
        /// <remarks>In order to unregister the <see cref="MMNotificationClient"/>, this method calls the <see cref="MMDeviceEnumerator.UnregisterEndpointNotificationCallback"/> method.</remarks>
        public void Dispose()
        {
            if (!_disposed)
            {
                _disposed = true;

                if (_deviceEnumerator != null && !_deviceEnumerator.IsDisposed)
                {
                    _deviceEnumerator.Dispose();
                }
                GC.SuppressFinalize(this);
            }
        }
示例#3
0
        public void CanEnumerateCaptureDevices()
        {
            using (var enumerator = new MMDeviceEnumerator())
            using (var collection = enumerator.EnumAudioEndpoints(DataFlow.Capture, DeviceState.All))
            {
                foreach (var item in collection)
                {
                    Debug.WriteLine(item.ToString());
                    item.Dispose();
                }

                enumerator.Dispose();
                collection.Dispose();
            }
        }
示例#4
0
        /// <summary>
        /// Disposes und unregisters the <see cref="MMNotificationClient"/>.
        /// </summary>
        /// <remarks>In order to unregister the <see cref="MMNotificationClient"/>, this method calls the <see cref="MMDeviceEnumerator.UnregisterEndpointNotificationCallback"/> method.</remarks>
        public void Dispose()
        {
            if (!_disposed)
            {
                _disposed = true;

                try
                {
                    CoreAudioAPIException.Try(_deviceEnumerator.UnregisterEndpointNotificationCallbackNative(this),
                                              InterfaceName, "UnregisterEndpointNotificationCallback");
                }
                finally
                {
                    _deviceEnumerator.Dispose();
                }
                GC.SuppressFinalize(this);
            }
        }