Esempio n. 1
0
 /// <summary>
 /// Dispose
 /// </summary>
 public void Dispose()
 {
     if (audioClientInterface != null)
     {
         if (audioClockClient != null)
         {
             audioClockClient.Dispose();
             audioClockClient = null;
         }
         if (audioRenderClient != null)
         {
             audioRenderClient.Dispose();
             audioRenderClient = null;
         }
         if (audioCaptureClient != null)
         {
             audioCaptureClient.Dispose();
             audioCaptureClient = null;
         }
         if (audioStreamVolume != null)
         {
             audioStreamVolume.Dispose();
             audioStreamVolume = null;
         }
         if (audioSessionControl != null)
         {
             audioSessionControl.Dispose();
             audioSessionControl = null;
         }
         Marshal.ReleaseComObject(audioClientInterface);
         audioClientInterface = null;
         GC.SuppressFinalize(this);
     }
 }
Esempio n. 2
0
        /// <summary>
        /// Constructor for session panel creation.
        /// </summary>
        /// <param name="device">Selected device.</param>
        /// <param name="session">Current session of device.</param>
        public VolumePanel(MMDevice device, AudioSessionControl session)
        {
            this.devicePanel = false;
            this.device = device;
            this.session = session;
            InitializeComponent();

            cmbDevice.Visible = false;
            Process process = Process.GetProcessById((int)session.GetProcessID);
            if (session.IsSystemSoundsSession)
            {
                lblName.Text = "System Sounds";
                pbProcessIcon.Visible = false;
                btnSoundProperties.Visible = true;
                var iconAddress = session.IconPath.Split(',');
                var icon = IconExtractor.Extract(iconAddress[0], int.Parse(iconAddress[1]), true);
                if (icon != null)
                    btnSoundProperties.Image = icon.ToBitmap();
                tooltip.SetToolTip(btnSoundProperties, lblName.Text);
            }
            else
            {
                pbProcessIcon.Image = Icon.ExtractAssociatedIcon(process.MainModule.FileName).ToBitmap();
                lblName.Text = process.MainWindowTitle != "" ? process.MainWindowTitle : process.ProcessName;
                pbProcessIcon.Visible = true;
                btnSoundProperties.Visible = false;
                tooltip.SetToolTip(pbProcessIcon, lblName.Text);
            }
            tooltip.SetToolTip(lblName, lblName.Text);

            session.RegisterEventClient(this);
            UpdateVolume();
            UpdateMuted();
        }
Esempio n. 3
0
 void AddVolumePanel(AudioSessionControl session)
 {
     var panel = new VolumePanel(DeviceVolumePanel.Device, session);
     AppVolumePanels.Add(panel);
     flowLayoutPanelApps.Controls.Add(panel);
 }
Esempio n. 4
0
        private void AudioSessionManager_OnSessionCreated(object sender, IAudioSessionControl newSession)
        {
            var audioSessionControl = new AudioSessionControl(newSession);

            if (_audioSessionControl == null && audioSessionControl.GetProcessID == Process.GetCurrentProcess().Id)
            {
                _audioSessionControl = audioSessionControl;
                _audioSessionControl.RegisterEventClient(this);

                if (_audioSessionControl.SimpleAudioVolume.Mute)
                {
                    _isMuted = true;
                }

                UpdateVolume();
                UpdateIsMuted();
            }
        }