コード例 #1
0
        /// <summary>
        ///     Creates a new Audio endpoint volume
        /// </summary>
        /// <param name="realEndpointVolume">IAudioEndpointVolume COM interface</param>
        internal AudioEndpointVolume(IAudioEndpointVolume realEndpointVolume)
        {
            ComThread.Assert();
            uint hardwareSupp;

            _audioEndPointVolume = realEndpointVolume;
            _channels = new AudioEndpointVolumeChannels(_audioEndPointVolume);
            _stepInformation = new AudioEndpointVolumeStepInformation(_audioEndPointVolume);
            Marshal.ThrowExceptionForHR(_audioEndPointVolume.QueryHardwareSupport(out hardwareSupp));
            _hardwareSupport = (EndpointHardwareSupport)hardwareSupp;
            _volumeRange = new AudioEndpointVolumeVolumeRange(_audioEndPointVolume);

            _callBack = new AudioEndpointVolumeCallback(this);
            Marshal.ThrowExceptionForHR(_audioEndPointVolume.RegisterControlChangeNotify(_callBack));
        }
コード例 #2
0
        /// <summary>
        ///     Creates a new Audio endpoint volume
        /// </summary>
        /// <param name="realEndpointVolume">IAudioEndpointVolume COM interface</param>
        internal AudioEndpointVolume(IAudioEndpointVolume realEndpointVolume)
        {
            ComThread.Assert();
            uint hardwareSupp;

            _audioEndPointVolume = realEndpointVolume;
            _channels            = new AudioEndpointVolumeChannels(_audioEndPointVolume);
            _stepInformation     = new AudioEndpointVolumeStepInformation(_audioEndPointVolume);
            Marshal.ThrowExceptionForHR(_audioEndPointVolume.QueryHardwareSupport(out hardwareSupp));
            _hardwareSupport = (EndpointHardwareSupport)hardwareSupp;
            _volumeRange     = new AudioEndpointVolumeVolumeRange(_audioEndPointVolume);

            _callBack = new AudioEndpointVolumeCallback(this);
            Marshal.ThrowExceptionForHR(_audioEndPointVolume.RegisterControlChangeNotify(_callBack));
        }
コード例 #3
0
        /// <summary>
        ///     Dispose
        /// </summary>
        public void Dispose()
        {
            if (_callBack != null)
            {
                ComThread.BeginInvoke(() =>
                {
                    _audioEndPointVolume.UnregisterControlChangeNotify(_callBack);
                    _callBack = null;
                    _audioEndPointVolume = null;
                });
            }

            GC.SuppressFinalize(this);
        }