private void AudioEndpointVolume_OnVolumeNotification(AudioVolumeNotificationData data) { _volume = data.MasterVolume.DeNormalizeVolume(); _volumeResetEvent.Set(); OnVolumeChanged(_volume); if (data.Muted != _isMuted) { _isMuted = data.Muted; _muteChangedResetEvent.Set(); OnMuteChanged(_isMuted); } }
public int OnNotify(IntPtr notifyData) { //Since AUDIO_VOLUME_NOTIFICATION_DATA is dynamic in length based on the //number of audio channels available we cannot just call PtrToStructure //to get all data, thats why it is split up into two steps, first the static //data is marshalled into the data structure, then with some IntPtr math the //remaining floats are read from memory. // var data = (AudioVolumeNotificationDataStruct) Marshal.PtrToStructure(notifyData, typeof(AudioVolumeNotificationDataStruct)); //Determine offset in structure of the first float var offset = Marshal.OffsetOf(typeof(AudioVolumeNotificationDataStruct), "ChannelVolume"); //Determine offset in memory of the first float var firstFloatPtr = (IntPtr)((long)notifyData + (long)offset); //Something weird happened, better to ignore it and move on if (data.nChannels > 100) { return(0); } var voldata = new float[data.nChannels]; //Read all floats from memory. for (int i = 0; i < data.nChannels; i++) { voldata[i] = (float)Marshal.PtrToStructure(firstFloatPtr, typeof(float)); } //Create combined structure and Fire Event in parent class. var notificationData = new AudioVolumeNotificationData(data.guidEventContext, data.bMuted, data.fMasterVolume, voldata); var p = _handler.Target as AudioEndpointVolume; if (_handler.IsAlive && p != null) { p.FireNotification(notificationData); } return(0); }
internal void FireNotification(AudioVolumeNotificationData notificationData) { OnVolumeNotification?.Invoke(notificationData); }
private void AudioEndpointVolume_OnVolumeNotification(AudioVolumeNotificationData data) { RaiseVolumeChanged(); }
internal void FireNotification(AudioVolumeNotificationData notificationData) { AudioEndpointVolumeNotificationDelegate del = OnVolumeNotification; if (del != null) { del(notificationData); } }
private void AudioEndpointVolume_OnVolumeNotification(AudioVolumeNotificationData data) { RaiseVolumeChanged(Volume); //Fire the muted changed here too OnPropertyChanged("IsMuted"); }
public int OnNotify(IntPtr notifyData) { //Since AUDIO_VOLUME_NOTIFICATION_DATA is dynamic in length based on the //number of audio channels available we cannot just call PtrToStructure //to get all data, thats why it is split up into two steps, first the static //data is marshalled into the data structure, then with some IntPtr math the //remaining floats are read from memory. // var data = (AudioVolumeNotificationDataStruct) Marshal.PtrToStructure(notifyData, typeof(AudioVolumeNotificationDataStruct)); //Determine offset in structure of the first float var offset = Marshal.OffsetOf(typeof(AudioVolumeNotificationDataStruct), "ChannelVolume"); //Determine offset in memory of the first float var firstFloatPtr = (IntPtr)((long)notifyData + (long)offset); //Something weird happened, better to ignore it and move on if (data.nChannels > 100) return 0; var voldata = new float[data.nChannels]; //Read all floats from memory. for (int i = 0; i < data.nChannels; i++) { voldata[i] = (float)Marshal.PtrToStructure(firstFloatPtr, typeof(float)); } //Create combined structure and Fire Event in parent class. var notificationData = new AudioVolumeNotificationData(data.guidEventContext, data.bMuted, data.fMasterVolume, voldata); var p = _handler.Target as AudioEndpointVolume; if (_handler.IsAlive && p != null) p.FireNotification(notificationData); return 0; }