public void Dispose() { foreach (var session in _sessions.Values) { session.SessionEnded -= OnSessionEnded; session.VolumeChanged -= OnSessionVolumeChanged; session.Dispose(); } _sessions.Clear(); _callback.NotifyRecived -= OnEndpointVolumeChanged; _sessionManager.SessionCreated -= OnSessionCreated; _endpointVolume?.UnregisterControlChangeNotify(_callback); _endpointVolume?.Dispose(); _endpointVolume = null; _callback = null; _sessionManager?.Dispose(); _sessionManager = null; _device?.Dispose(); _device = null; }
protected override void Dispose(bool disposing) { endpointVolume.Dispose(); device.Dispose(); base.Dispose(disposing); }
public void Stop() { if (!IsRunning) { return; } _logger.Info("Stopping audio engine"); _deviceEnumerator.DefaultDeviceChanged -= DefaultDeviceChanged; _endpointVolumeCallback.NotifyRecived -= VolumeNotifyReceived; _endpointVolume?.UnregisterControlChangeNotify(_endpointVolumeCallback); _endpointVolume?.Dispose(); _logger.Info($"Disposing modules ({_modules?.Count ?? 0})"); if (_modules?.Count > 0) { foreach (var audioModule in _modules) { _logger.Info($"Disposing module {audioModule.Id} ({audioModule.GetType()})"); audioModule.Dispose(); } _modules.Clear(); } _logger.Info("Audio engine stopped"); IsRunning = false; }
public override void Disable() { _notificationClient.DefaultDeviceChanged -= NotificationClient_DefaultDeviceChanged; _enumerator.UnregisterEndpointNotificationCallback(_notifyClient); _audioEndpointVolume.Dispose(); FreePlaybackDevice(); _enumerator.Dispose(); }
//BLARG 01.14.2020: Added the rest of the disposables since we'll be calling this method a lot more public void Dispose() { //_capture?.Stop(); //Don't need this, Dispose() takes care of it _capture?.Dispose(); _soundInSource?.Dispose(); _source?.Dispose(); _stream?.Dispose(); _audioEndpointVolume?.Dispose(); }
private void FreePlaybackDevice() { string disposingPlaybackDeviceFriendlyName = _playbackDevice?.FriendlyName ?? "Unknown"; _audioEndpointVolume?.Dispose(); _playbackDevice?.Dispose(); _playbackDevice = null; _logger.Information(string.Format("Playback device {0} unregistered as source device to fill Playback volume data model", disposingPlaybackDeviceFriendlyName)); }
static void DisposeVolume() { if (Volume == null) { return; } Volume.OnVolumeNotification -= VolumeUpdated; Volume.Dispose(); Volume = null; }
private void UnloadMMD() { M.D(1900, "UnloadMMD"); AMI.Dispose(); AEVC.NotifyRecived -= AEV_NotifyRecived; AEV.UnregisterControlChangeNotify(AEVC); AEV.Dispose(); L.MMD.Dispose(); L.MMD = null; L.MSD = null; M.D(1909); }
private void SetupDefaultEndpoint() { if (_endpointVolume != null) { _endpointVolume.UnregisterControlChangeNotify(_endpointVolumeCallback); _endpointVolume.Dispose(); } try { var defaultDevice = _deviceEnumerator.GetDefaultAudioEndpoint(DataFlow.Render, Role.Console); _endpointVolume = AudioEndpointVolume.FromDevice(defaultDevice); _endpointVolume.RegisterControlChangeNotify(_endpointVolumeCallback); } catch (Exception ex) { _logger.Error(ex); } }
public void Dispose() { // Client up our MM objects in reverse order if (iAudioEndpointVolumeMixerCallback != null && iAudioEndpointVolume != null) { iAudioEndpointVolume.UnregisterControlChangeNotify(iAudioEndpointVolumeMixerCallback); } if (iAudioEndpointVolumeMixerCallback != null) { iAudioEndpointVolumeMixerCallback.NotifyRecived -= iVolumeChangedHandler; iAudioEndpointVolumeMixerCallback = null; } if (iAudioEndpointVolume != null) { iAudioEndpointVolume.Dispose(); iAudioEndpointVolume = null; } if (_mMdevice != null) { _mMdevice.Dispose(); _mMdevice = null; } if (iMultiMediaNotificationClient != null) { iMultiMediaNotificationClient.DefaultDeviceChanged -= iDefaultDeviceChangedHandler; iMultiMediaNotificationClient.Dispose(); iMultiMediaNotificationClient = null; } if (_mMdeviceEnumerator != null) { _mMdeviceEnumerator.Dispose(); _mMdeviceEnumerator = null; } Stop(); Close(); }