public void OnNotify(ref AudioVolumeNotificationDataStruct data)
        //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.
            //
            //AudioVolumeNotificationDataStruct 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
            //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] = data.fMasterVolume;
            //}

            //Create combined structure and Fire Event in parent class.
            AudioVolumeNotificationData NotificationData = new AudioVolumeNotificationData(data.guidEventContext, data.bMuted, data.fMasterVolume);

            _Parent.FireNotification(NotificationData);
        }
Пример #2
0
        // Token: 0x06000048 RID: 72 RVA: 0x00004274 File Offset: 0x00002474
        public void OnNotify(IntPtr notifyData)
        {
            AudioVolumeNotificationDataStruct audioVolumeNotificationDataStruct = (AudioVolumeNotificationDataStruct)Marshal.PtrToStructure(notifyData, typeof(AudioVolumeNotificationDataStruct));
            IntPtr value = Marshal.OffsetOf(typeof(AudioVolumeNotificationDataStruct), "ChannelVolume");
            IntPtr ptr   = (IntPtr)((long)notifyData + (long)value);

            float[] array = new float[audioVolumeNotificationDataStruct.nChannels];
            int     num   = 0;

            while ((long)num < (long)((ulong)audioVolumeNotificationDataStruct.nChannels))
            {
                array[num] = (float)Marshal.PtrToStructure(ptr, typeof(float));
                num++;
            }
            AudioVolumeNotificationData notificationData = new AudioVolumeNotificationData(audioVolumeNotificationDataStruct.guidEventContext, audioVolumeNotificationDataStruct.bMuted, audioVolumeNotificationDataStruct.fMasterVolume, array);

            this.parent.FireNotification(notificationData);
        }
Пример #3
0
        public void OnNotify(IntPtr notifyData)
        {
            AudioVolumeNotificationDataStruct audioVolumeNotificationDataStruct = MarshalHelpers.PtrToStructure <AudioVolumeNotificationDataStruct>(notifyData);
            IntPtr value   = MarshalHelpers.OffsetOf <AudioVolumeNotificationDataStruct>("ChannelVolume");
            IntPtr pointer = (IntPtr)((long)notifyData + (long)value);

            float[] array = new float[audioVolumeNotificationDataStruct.nChannels];
            int     num   = 0;

            while ((long)num < (long)((ulong)audioVolumeNotificationDataStruct.nChannels))
            {
                array[num] = MarshalHelpers.PtrToStructure <float>(pointer);
                num++;
            }
            AudioVolumeNotificationData notificationData = new AudioVolumeNotificationData(audioVolumeNotificationDataStruct.guidEventContext, audioVolumeNotificationDataStruct.bMuted, audioVolumeNotificationDataStruct.fMasterVolume, array, audioVolumeNotificationDataStruct.guidEventContext);

            this.parent.FireNotification(notificationData);
        }
Пример #4
0
        /// <summary>
        /// Marshals a native AUDIO_VOLUME_NOTIFICATION_DATA structure to a <see cref="AudioVolumeNotificationData"/> object.
        /// </summary>
        /// <param name="ptr">A pointer to an AUDIO_VOLUME_NOTIFICATION_DATA structure.</param>
        /// <returns>The marshaled <see cref="AudioVolumeNotificationData"/> object.</returns>
        internal static AudioVolumeNotificationData MarshalFromPtr(IntPtr ptr)
        {
            AudioVolumeNotificationDataStruct data = (AudioVolumeNotificationDataStruct)Marshal.PtrToStructure(ptr, typeof(AudioVolumeNotificationDataStruct));
            IntPtr channelVolumesPtr = new IntPtr(ptr.ToInt64() + Marshal.OffsetOf <AudioVolumeNotificationDataStruct>("ChannelVolume0").ToInt64());

            // Read dynamic channel volumes array
            float[] channelVolume = new float[data.Channels];
            Marshal.Copy(channelVolumesPtr, channelVolume, 0, data.Channels);

            // Construct the complete AudioVolumeNotificationData object
            AudioVolumeNotificationData notificationData = new AudioVolumeNotificationData()
            {
                EventContext  = data.EventContext,
                Muted         = data.Muted,
                MasterVolume  = data.MasterVolume,
                Channels      = data.Channels,
                ChannelVolume = channelVolume,
            };

            return(notificationData);
        }