/// <summary> /// Registers the event client for callbacks /// </summary> private void RegisterEventClient() { UnregisterEventClient(); _sessionEvents = new AudioSessionEvents(); Marshal.ThrowExceptionForHR(_audioSessionControl.RegisterAudioSessionNotification(_sessionEvents)); }
public void Dispose() { if (_AudioSessionEvents != null) { try { Marshal.ThrowExceptionForHR(_AudioSessionControl2.UnregisterAudioSessionNotification(_AudioSessionEvents)); _AudioSessionEvents = null; } catch { } } }
/// <summary> /// Unregisters the event client from receiving callbacks /// </summary> private void UnregisterEventClient() { if (_sessionEvents == null) { return; } Marshal.ThrowExceptionForHR(_audioSessionControl.UnregisterAudioSessionNotification(_sessionEvents)); _sessionEvents = null; }
internal AudioSessionControl2(IAudioSessionControl2 realAudioSessionControl2) { _AudioSessionControl2 = realAudioSessionControl2; IAudioMeterInformation _meters = _AudioSessionControl2 as IAudioMeterInformation; ISimpleAudioVolume _volume = _AudioSessionControl2 as ISimpleAudioVolume; if (_meters != null) _AudioMeterInformation = new CoreAudio.AudioMeterInformation(_meters); if (_volume != null) _SimpleAudioVolume = new SimpleAudioVolume(_volume); _AudioSessionEvents = new AudioSessionEvents(this); Marshal.ThrowExceptionForHR(_AudioSessionControl2.RegisterAudioSessionNotification(_AudioSessionEvents)); }
internal AudioSessionControl(IAudioSessionControl realAudioSessionControl) { IAudioMeterInformation _meters = realAudioSessionControl as IAudioMeterInformation; ISimpleAudioVolume _volume = realAudioSessionControl as ISimpleAudioVolume; if (_meters != null) { _AudioMeterInformation = new CoreAudio.AudioMeterInformation(_meters); } if (_volume != null) { _SimpleAudioVolume = new SimpleAudioVolume(_volume); } _AudioSessionControl = realAudioSessionControl; _AudioSessionEvents = new AudioSessionEvents(this); Marshal.ThrowExceptionForHR(_AudioSessionControl.RegisterAudioSessionNotification(_AudioSessionEvents)); }
public AudioSessionControl2(IAudioSessionControl2 realAudioSessionControl2) { _AudioSessionControl2 = realAudioSessionControl2; if (_AudioSessionControl2 is IAudioMeterInformation _meters) { _AudioMeterInformation = new AudioMeterInformation(_meters); } if (_AudioSessionControl2 is ISimpleAudioVolume _volume1) { _SimpleAudioVolume = new SimpleAudioVolume(_volume1); } //IAudioVolumeLevel _volume2 = _AudioSessionControl2 as IAudioVolumeLevel; //if (_volume2 != null) _AudioVolumeLevel = new AudioVolumeLevel(_volume2); _AudioSessionEvents = new AudioSessionEvents(this); Marshal.ThrowExceptionForHR(_AudioSessionControl2.RegisterAudioSessionNotification(_AudioSessionEvents)); }