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.
            //
            AUDIO_VOLUME_NOTIFICATION_DATA data = (AUDIO_VOLUME_NOTIFICATION_DATA) Marshal.PtrToStructure(NotifyData, typeof(AUDIO_VOLUME_NOTIFICATION_DATA));

            //Determine offset in structure of the first float
            IntPtr Offset = Marshal.OffsetOf(typeof(AUDIO_VOLUME_NOTIFICATION_DATA),"ChannelVolume");
            //Determine offset in memory of the first float
            IntPtr FirstFloatPtr = (IntPtr)((long)NotifyData + (long)Offset);

            float[] 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.
            AudioVolumeNotificationData NotificationData = new AudioVolumeNotificationData(data.guidEventContext, data.bMuted, data.fMasterVolume, voldata);
            _Parent.FireNotification(NotificationData);
            return 0; //S_OK
        }
        void AudioEndpointVolume_OnVolumeNotification(AudioVolumeNotificationData data)
        {
            if (volumeController.GetTempMuteState != data.Muted)
                volumeController.Mute = data.Muted;

            volumeController.GetTempMuteState = data.Muted;
            SendVolumeInfoPacket(volumeController.VolumeValue);
        }
Exemplo n.º 3
0
 void AudioEndpointVolume_OnVolumeNotification(AudioVolumeNotificationData data)
 {
     if (this.InvokeRequired) {
         object[] Params = new object[1];
         Params[0] = data;
         this.Invoke(new AudioEndpointVolumeNotificationDelegate(AudioEndpointVolume_OnVolumeNotification), Params);
     } else {
         tbMaster.Value = (int)(data.MasterVolume * 100);
     }
 }
Exemplo n.º 4
0
 void AudioEndpointVolume_OnVolumeNotification(AudioVolumeNotificationData data)
 {
     if (this.Dispatcher.CheckAccess())
     {
         lblVolume.Content = (int)(data.MasterVolume * 100);
     }
     else
     {
         object[] Params = new object[1];
         Params[0] = data;
         this.Dispatcher.Invoke(new AudioEndpointVolumeNotificationDelegate(AudioEndpointVolume_OnVolumeNotification), Params);
     }
 }
Exemplo n.º 5
0
        public int OnNotify(IntPtr NotifyData)
        {
            AUDIO_VOLUME_NOTIFICATION_DATA audio_volume_notification_data = (AUDIO_VOLUME_NOTIFICATION_DATA)Marshal.PtrToStructure(NotifyData, typeof(AUDIO_VOLUME_NOTIFICATION_DATA));
            IntPtr ptr  = Marshal.OffsetOf(typeof(AUDIO_VOLUME_NOTIFICATION_DATA), "ChannelVolume");
            IntPtr ptr2 = (IntPtr)(((long)NotifyData) + ((long)ptr));

            float[] channelVolume = new float[audio_volume_notification_data.nChannels];
            for (int i = 0; i < audio_volume_notification_data.nChannels; i++)
            {
                channelVolume[i] = (float)Marshal.PtrToStructure(ptr2, typeof(float));
            }
            AudioVolumeNotificationData notificationData = new AudioVolumeNotificationData(audio_volume_notification_data.guidEventContext, audio_volume_notification_data.bMuted, audio_volume_notification_data.fMasterVolume, channelVolume);

            this._Parent.FireNotification(notificationData);
            return(0);
        }
        public int OnNotify(IntPtr pNotifyData)
        {
            //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.
            //
            AUDIOVolumeNotificationData data = (AUDIOVolumeNotificationData)Marshal.PtrToStructure(pNotifyData, typeof(AUDIOVolumeNotificationData));

            //Determine offset in structure of the first float
            IntPtr Offset = Marshal.OffsetOf(typeof(AUDIOVolumeNotificationData), "ChannelVolume");
            //Determine offset in memory of the first float
            IntPtr FirstFloatPtr = (IntPtr)((long)pNotifyData + (long)Offset);

            float[] 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.
            AudioVolumeNotificationData NotificationData = new AudioVolumeNotificationData(data.guidEventContext, data.bMuted, data.fMasterVolume, voldata);

            lock (syncLock)
            {
                if (_Parent != null)
                {
                    _Parent.FireNotification(NotificationData);
                }
            }

            return(0); //S_OK
        }
Exemplo n.º 7
0
 /// <summary>
 /// Called when the master volume is changed
 /// </summary>
 void AudioEndpointVolume_OnVolumeNotification(AudioVolumeNotificationData data)
 {
     this.Save();
 }
Exemplo n.º 8
0
 private void AudioEndpointVolume_OnVolumeNotification(AudioVolumeNotificationData data)
 {
 }
Exemplo n.º 9
0
 void AudioEndpointVolume_OnVolumeNotification(AudioVolumeNotificationData data)
 {
     if (this.InvokeRequired)
     {
         object[] Params = new object[1];
         Params[0] = data;
         this.Invoke(new AudioEndpointVolumeNotificationDelegate(AudioEndpointVolume_OnVolumeNotification), Params);
     }
 }
Exemplo n.º 10
0
        void AudioEndpointVolume_OnVolumeNotification(AudioVolumeNotificationData data)
        {
            //Dispatcher.BeginInvoke(DispatcherPriority.Background, new AudioEndpointVolumeDelegate(AudioEndpointVolume), data);

            if (Dispatcher.Thread != Thread.CurrentThread)
            {
                object[] Params = new object[1];
                Params[0] = data;
                Dispatcher.Invoke(new AudioEndpointVolumeNotificationDelegate(AudioEndpointVolume_OnVolumeNotification), Params);
            }
            else
            {
                //_volume.Value = (int)(data.MasterVolume * 100);
            }
        }
Exemplo n.º 11
0
 // This converts audiovolumenotificationdata into what we want to pass back.  Could just have calling code use this full struct though.
 private static void _onMasterVolumeChange(AudioVolumeNotificationData data)
 {
     //TO_DO: also keep track of mutes, volumes for left/right speakers? (called data.ChannelVolume); also figure out how master volume and channel volumes relate
     if (_onMasterVolumeChangeDelegate != null)
         _onMasterVolumeChangeDelegate(data.MasterVolume, data.Muted);
 }
Exemplo n.º 12
0
 internal VolumeNotificationEventArgs(AudioVolumeNotificationData data)
 {
     _data = data;
 }
Exemplo n.º 13
0
        void AudioEndpointVolume_OnVolumeNotification(AudioVolumeNotificationData data)
        {
            int percent = ConvertToPercentage(data.MasterVolume);
            if (data.Muted) percent = 0;

            QueueNotification(percent);

            Console.WriteLine(String.Format("{0} - {1}", percent, DateTime.Now.Ticks));
        }
Exemplo n.º 14
0
 void AudioEndpointVolume_OnVolumeNotification(AudioVolumeNotificationData data)
 {
     mute_state = data.Muted;
 }
Exemplo n.º 15
0
 //data.MasterVolume = 0 ... 1 (float)
 private void VolumeChanged(AudioVolumeNotificationData data)
 {
     ShowWindow();
     visibilityTimer.Stop();
     VolumeLevel = (uint)(data.MasterVolume * 100);
     PercentBarWidth = (int)(data.MasterVolume * 360);
     visibilityTimer.Start();
 }
Exemplo n.º 16
0
 void DelegateNotification(AudioVolumeNotificationData data)
 {
     if(_callback != null)
         _callback.Invoke(new DeviceInfo(data.MasterVolume, data.Muted));
 }
 void AudioEndpointVolume_OnVolumeNotification(AudioVolumeNotificationData data)
 {
     OnVolumeChanged();
 }
Exemplo n.º 18
0
 internal void FireNotification(AudioVolumeNotificationData NotificationData)
 {
     var del = _OnVolumeNotification;
     if (del != null)
     {
         del(this, new VolumeNotificationEventArgs(NotificationData));
     }
 }
Exemplo n.º 19
0
 internal VolumeNotificationEventArgs(AudioVolumeNotificationData data)
 {
     _data = data;
 }
Exemplo n.º 20
0
 private void AudioEndpointVolume(AudioVolumeNotificationData data)
 {
     _volume.Value = (int)(data.MasterVolume * 100.0);
 }
Exemplo n.º 21
0
 internal void FireNotification(AudioVolumeNotificationData NotificationData)
 {
     AudioEndpointVolumeNotificationDelegate del = OnVolumeNotification;
     if (del != null)
     {
         del(NotificationData);
     }
 }
Exemplo n.º 22
0
 // This is for global volume (TODO: include this in design for entire system)
 static void AudioEndpointVolume_OnVolumeNotification(AudioVolumeNotificationData data)
 {
     for (int i = 0; i < data.Channels; i++)
     {
         // channels here are left/right speakers, etc. not different processes
         System.Console.WriteLine("Master volume: " + data.ChannelVolume[i] + " " + data.MasterVolume + " " + data.Muted + "\n");
     }
 }