public void Dispose() { r_Session.VolumeChanged -= Session_VolumeChanged; r_Session.Dispose(); r_Session = null; }
public void Dispose() { MainWindowProcess?.Dispose(); _processesCache?.DisposeAll(); AudioSession?.Dispose(); _windowCreationEventHook?.Dispose(); _titleChangeEventHook?.Dispose(); _windowDestructionEventHook?.Dispose(); }
void AudioManager_NewSession(object sender, AudioSessionCreatedEventArgs e) { if (e.Session.IsSystemSoundsSession) { return; } var rHostProcessID = Process.GetCurrentProcess().Id; int?rProcessID = e.Session.ProcessID; var rIsBrowserProcess = false; while (rProcessID.HasValue) { using (var rManagementObject = new ManagementObject($"Win32_Process.Handle='{rProcessID.Value}'")) try { rManagementObject.Get(); rProcessID = Convert.ToInt32(rManagementObject["ParentProcessId"]); if (rProcessID == rHostProcessID) { rIsBrowserProcess = true; break; } } catch (ManagementException rException) when(rException.ErrorCode == ManagementStatus.NotFound) { rProcessID = null; } } if (!rIsBrowserProcess) { return; } e.Release = false; AudioSession?.Dispose(); AudioSession = new BrowserAudioSession(e.Session); AudioManager.Instance.NewSession -= AudioManager_NewSession; AudioManager.Instance.StopSessionNotification(); }