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
            IntPtr Offset = Marshal.OffsetOf(typeof (AudioVolumeNotificationDataStruct), "ChannelVolume");
            //Determine offset in memory of the first float
            var FirstFloatPtr = (IntPtr) ((long) NotifyData + (long) Offset);

            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);
            _Parent.FireNotification(NotificationData);
            return 0; //S_OK
        }
        public void VolumeChanged(AudioVolumeNotificationData data)
        {
            if (data == null)
            {
                throw new ArgumentNullException(nameof(data));
            }

            // Update the Volume and notify the change.
            Volume = Math.Round(data.MasterVolume * 100f);
            OnPropertyChanged("Volume");
            // Update Muted and notify the change.
            Muted = data.Muted;
            OnPropertyChanged("Muted");
        }
示例#3
0
 void AudioEndpointVolume_OnVolumeNotification(AudioVolumeNotificationData data)
 {
     try
     {
         this.Invoke(new Action(delegate()
         {
             UpdateVolume();
             UpdateMuted();
         }));
     }
     catch
     {
     }
 }
示例#4
0
 void AudioEndpointVolume_OnVolumeNotification(AudioVolumeNotificationData data)
 {
     if (this.InvokeRequired)//если изменения не из нашего приложения
     {
         object[] Params = new object[1];
         Params[0] = data;// создаём массив параметров и передаём их с помощью Invoke()!!! в главный дескриптор окна формы
         this.Invoke(new AudioEndpointVolumeNotificationDelegate(AudioEndpointVolume_OnVolumeNotification), Params);
     }
     else
     {                                                          //иначе либо это из нашего прирожения либо через Invoke() переданые изменения
         trackBarVolume.Value = (int)(data.MasterVolume * 100); // мы приваеваем нашим контролам любые изменения громкости
         labelVolume.Text     = $"{trackBarVolume.Value}";
     }
 }
示例#5
0
 private void VolNotify(AudioVolumeNotificationData data)
 {
     if (InvokeRequired)
     {
         Invoke(new AudioEndpointVolumeNotificationDelegate(VolNotify), data);
     }
     else
     {
         if (!Moving)
         {
             Value = data.MasterVolume;
         }
         Mute = data.Muted;
     }
 }
示例#6
0
 void AudioEndpointVolume_OnVolumeNotification(AudioVolumeNotificationData data)
 {
     if (data.EventContext == Guid.Empty)
     {
         return;
     }
     if (this.InvokeRequired)
     {
         this.Invoke((MethodInvoker) delegate() { AudioEndpointVolume_OnVolumeNotification(data); });
     }
     else
     {
         mediaSliderVolume.Value = (int)(data.MasterVolume * 100);
         outputBindingSource.ResetBindings(false);
     }
 }
示例#7
0
        public void HandleMasterVolumeChanged(AudioVolumeNotificationData data)
        {
            AudioSession masterSession = getMasterAudioSessionObject(device);

            AudioSessions[masterSession.id].volume = device.AudioEndpointVolume.MasterVolumeLevelScalar;
            AudioSessions[masterSession.id].mute   = device.AudioEndpointVolume.Mute;

            if (Main.LOG_EVENTS)
            {
                Console.WriteLine("\nMaster Volume Changed: " + masterSession.ToString());
            }

            if (OnAudioSessionEdited != null)
            {
                OnAudioSessionEdited(masterSession);
            }
        }
            /// <summary>
            /// volume状態変更時にCallされる
            /// </summary>
            /// <param name="data"></param>
            public void OnVolumeNotify(AudioVolumeNotificationData data)
            {
                //if (monitor.listener == null) return;

                // 更新されたボリューム値をListenerに通知
                //monitor.listener.OnVolumeChanged(data.MasterVolume, data.Muted);

                /*
                 * if (_OnAudioVolumeChanged == null || _OnAudioVolumeChanged.GetInvocationList().Length == 0)
                 * {
                 *  return;
                 * }
                 * _OnAudioVolumeChanged(data.MasterVolume, data.Muted);
                 */

                _OnAudioVolumeChanged?.Invoke(data.MasterVolume, data.Muted);
            }
示例#9
0
        // ------------------------------------------------------------------------------------------
        // ------------------------------          Audio Events          ------------------------------
        // ------------------------------------------------------------------------------------------
        private void AudioEndpointVolume_OnVolumeNotification(AudioVolumeNotificationData data)
        {
            if (this.InvokeRequired)
            {
                object[] Params = new object[1];
                Params[0] = data;
                this.Invoke(new AudioEndpointVolumeNotificationDelegate(AudioEndpointVolume_OnVolumeNotification), Params);
            }
            else
            {
#if DEBUG
                statLblVol.Text = (float)(data.MasterVolume * 100) + "%";
#else
                statLblVol.Text = (int)(data.MasterVolume * 100) + "%";
#endif
            }
        }
示例#10
0
        private void AudioEndpointVolume_OnVolumeNotification(AudioVolumeNotificationData data)
        {
            if (!Pref.isVolumeOn)
            {
                return;
            }
            if (isMuted == data.Muted && nowVolume == (int)(data.MasterVolume * 100))
            {
                return;
            }
            nowVolume = data.MasterVolume * 100;
            isMuted   = data.Muted;

            Dispatcher.Invoke(new Action(() => {
                windowVolume.RefreshVolume(nowVolume, data.Muted);
            }));
        }
示例#11
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));
        }
        private void OnDeviceSpeakerVolumeCallBack(AudioVolumeNotificationData cData)
        {
            var callbackvalue = Math.Round(cData.MasterVolume * AppCoreAudioConstants.VALUE_MAX).ToString();

            if (_audioDeviceCollection.First().AudioSlider.SliderValue.Equals(callbackvalue))
            {
                return;
            }
            _audioDeviceCollection.First().AudioSlider.SliderValue = callbackvalue;
            _audioDeviceCollection.First().ButtonContent.MenuImage = GetMutedImage(cData.Muted);
            //Set sessions
            foreach (var sscontrol in _audioSessionCollection)
            {
                var vv = CompareStringValues(_audioDeviceCollection.First().AudioSlider.SliderValue, sscontrol.AudioSlider.SliderValue);
                if (vv < 0)
                {
                    sscontrol.AudioSlider.SliderValue = callbackvalue;
                }
            }
        }
示例#13
0
        private void AudioVolumeNotificationCallback(AudioVolumeNotificationData audioVolumeNotificationData)
        {
            if (_lastMasterVolumeLevel != audioVolumeNotificationData.MasterVolume)
            {
                _lastMasterVolumeLevel = audioVolumeNotificationData.MasterVolume;
                _masterVolumeLevelChangedEvent?.Invoke(this, new MasterVolumeLevelChangedEventArgs()
                {
                    VolumeLevel = audioVolumeNotificationData.MasterVolume
                });
            }

            if (_lastMasterMuteState != audioVolumeNotificationData.Muted)
            {
                _lastMasterMuteState = audioVolumeNotificationData.Muted;
                _masterMuteStateChangedEvent?.Invoke(this, new MasterMuteStateChangedEventArgs()
                {
                    MuteState = audioVolumeNotificationData.Muted
                });
            }
        }
示例#14
0
        private void AudioEndpointVolume_OnVolumeNotification(AudioVolumeNotificationData data)
        {
            int volume = Convert.ToInt32(Math.Floor(100 * data.MasterVolume));

            if (volumeInRange(volume))
            {
                volumeQueue.Enqueue(volume);
                if (progressBar1.InvokeRequired)
                {
                    setVolumeCallback cb = new setVolumeCallback(setPBarValue);
                    this.Invoke(cb);
                }
                else
                {
                    setPBarValue();
                }
            }
            else
            {
                throw new IndexOutOfRangeException("Bad volume. Data is " + volume);
            }
        }
示例#15
0
        void InputDeviceVolChange(AudioVolumeNotificationData data, string DeviceID)
        {
            float newVol = data.MasterVolume;

            //Console.WriteLine(newVol*100 + ", " + isMuted.ToString().ToLower());

            if (data.Muted)
            {
                newVol = 0;
            }

            if (Client.CurrentPage == Constants.Device_Pages.INPUTS)
            {
                if ((long)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalMilliseconds - lastChangeSessionLevelTime > 200)
                {
                    if (!(lastChangedVolD.did == DeviceID && (int)(newVol * 100) == lastChangedVolD.vol) || lastSentVolD.isMuted)
                    {
                        if (lastSentVolD.did == DeviceID && (int)(newVol * 100) == lastSentVolD.vol)
                        {
                            //Console.WriteLine("Not sending 2");
                        }
                        else
                        {
                            SendMessage("{\"" + Constants.Commands.CHANGE_INPUT_LEVEL + "\": [\"" + InputDevices.GetKeysByValue(DeviceID).First() + "\", " + newVol * 100 + "]}", false);
                            lastSentVolD = new DeviceVolumeInt(DeviceID, (int)(newVol * 100), data.Muted);
                        }
                    }
                    else
                    {
                        //Console.WriteLine("Not sending 1");
                    }
                }
            }
            else
            {
                //Console.WriteLine("Not sending: " + Client.CurrentPage);
            }
        }
示例#16
0
        void AudioEndpointVolume_OnVolumeNotification(AudioVolumeNotificationData data)
        {
            var theShit = new MethodInvoker(() =>
            {
                var c   = zg1.GraphPane.CurveList[2];
                var ppl = (PointPairList)c.Points;

                ppl[0].Y = (_audDev.AudioEndpointVolume.MasterVolumeLevelScalar * 100);
                c.Color  = (_audDev.AudioEndpointVolume.Mute)
                                                                  ? Color.Red
                                                                  : Color.Green;

                zg1.Refresh();
            });

            if (InvokeRequired)
            {
                BeginInvoke(theShit);
            }
            else
            {
                theShit.Invoke();
            }
        }
示例#17
0
 void AudioEndpointVolume_OnVolumeNotification(AudioVolumeNotificationData data)
 {
     CreateTextIcon(((int)(data.MasterVolume * 100f)).ToString());
 }
示例#18
0
文件: Form1.cs 项目: raymelon/VolPI
 private void AudioEndpointVolume_OnVolumeNotification(AudioVolumeNotificationData data)
 {
     this.volumeString     = this.defaultPlaybackDevice.Volume.ToString();
     this.notifyIcon1.Icon = generateNotifyIcon();
 }
示例#19
0
 private void OnMasterVolumeChanged(AudioVolumeNotificationData data)
 {
     VolumeChanged?.BeginInvoke(this, new VolumeChangedArgs((int)(player.Volume * data.MasterVolume * 100), data.Muted), null, null);
 }
示例#20
0
 private void AudioEndpointVolume_OnVolumeNotification(AudioVolumeNotificationData data)
 {
     logger.Debug($"Volume is set to {data.MasterVolume * 100}%, audio device is {(data.Muted ? "muted" : "not muted")}.");
     VolumeChanged?.Invoke(data.MasterVolume, data.Muted);
 }
示例#21
0
 private void AudioEndpointVolume_OnVolumeNotification(AudioVolumeNotificationData data)
 {
     UpdateVolume(data.MasterVolume * 100);
 }
示例#22
0
 void AudioEndpointVolume_OnVolumeNotification(AudioVolumeNotificationData data)
 {
     // This shows data.MasterVolume, you can do whatever you want here
     mon1.AudioEndpointVolume.MasterVolumeLevel = defDevice.AudioEndpointVolume.MasterVolumeLevel;
     mon2.AudioEndpointVolume.MasterVolumeLevel = defDevice.AudioEndpointVolume.MasterVolumeLevel;
 }
示例#23
0
 void AudioEndpointVolume_OnVolumeNotification(AudioVolumeNotificationData data, string DeviceID)
 {
     AudioSessionVolumeChanged(-69001, data.MasterVolume, data.Muted);
 }
示例#24
0
 private static void AudioEndpointVolume_OnVolumeNotification(AudioVolumeNotificationData data)
 {
 }
示例#25
0
 protected virtual void OnVolumeChanged(AudioVolumeNotificationData volume)
 {
     VolumeChanged?.Invoke(this, volume);
 }
 internal void FireNotification(AudioVolumeNotificationData NotificationData)
 {
     AudioEndpointVolumeNotificationDelegate del = OnVolumeNotification;
     if (del != null)
     {
         del(NotificationData);
     }
 }
示例#27
0
 private void _mic_OnVolumeNotification(AudioVolumeNotificationData data)
 {
     IsMuted = data.Muted;
 }
示例#28
0
 private static void AudioEndpointVolume_OnVolumeNotification(AudioVolumeNotificationData data)
 {
     TrayIcon.Text = ToolTipFromVolume();
     TrayIcon.Icon = IconFromVolume();
 }
示例#29
0
 private static void ProcessNotificationData(AudioVolumeNotificationData data)
 {
     TunerHub.UpdateSoundLevel((short)Math.Round(data.MasterVolume * 100));
 }
示例#30
0
 void AudioEndpointVolume_OnVolumeNotification(AudioVolumeNotificationData data)
 {
     volum.Value = (int)(data.MasterVolume * 100);
 }
 void AudioEndpointVolume_OnVolumeNotification(AudioVolumeNotificationData data)
 {
     OnVolumeChanged();
 }
 void DelegateNotification(AudioVolumeNotificationData data)
 {
     if(_callback != null)
         _callback.Invoke(new DeviceInfo(data.MasterVolume, data.Muted));
 }