Example #1
0
        private void Dispose(bool disposing)
        {
            if (_isDisposed)
            {
                return;
            }

            _timerSubscription?.Dispose();
            _meterInformation.Dispose();
            _simpleAudioVolume.Dispose();
            _deviceMutedSubscription.Dispose();
            _muteChanged.Dispose();
            _stateChanged.Dispose();
            _disconnected.Dispose();
            _volumeChanged.Dispose();
            _peakValueChanged.Dispose();


            //Run this on the com thread to ensure it's disposed correctly
            ComThread.BeginInvoke(() =>
            {
                AudioSessionControl.UnregisterAudioSessionNotification(this);
            }).ContinueWith(x =>
            {
                _audioSessionControl.Dispose();
            });

            GC.SuppressFinalize(this);
            _isDisposed = true;
        }
        public void Dispose()
        {
            _events.StateChanged        -= OnStateChanged;
            _events.SimpleVolumeChanged -= OnVolumeChanged;

            _session?.UnregisterAudioSessionNotification(_events);
            _session?.Dispose();
            _session = null;

            _session2?.Dispose();
            _session2 = null;

            // Disposing of SimpleAudioVolume causes it to freeze.
            _simpleAudio = null;
        }
Example #3
0
        public void RemoveHandler(AudioSessionControl session)
        {
            string currentId = session.SessionInstanceIdentifier + session.ProcessID;

            if (IDs.Exists(id => id == currentId))
            {
                try
                {
                    session.UnregisterAudioSessionNotification(Handler);
                    IDs.Remove(currentId);
                }
                catch (COMException)
                {
                    //The UnregisterAudioSessionNotification failed trying to remove subscriptor due to invalid handler
                    //AKA not subscribed to this session
                    //Why we end up here?? the sessionId should not be on the list
                    //The AudioManager is being disposed. DO NOTHING!!
                }
            }
        }
 public void UnregisterAudioSessionNotification(IAudioSessionEvents notifications)
 {
     _updateThread.RunSynchronizedAction(
         () => _sessionControl.UnregisterAudioSessionNotification(notifications));
 }