unsafe static T[] GetAvailable <T> (AudioFormatProperty prop, AudioFormatType format)
        {
            uint size;

            if (AudioFormatPropertyNative.AudioFormatGetPropertyInfo(prop, sizeof(AudioFormatType), ref format, out size) != 0)
            {
                return(null);
            }

            var data         = new T[size / Marshal.SizeOf(typeof(T))];
            var array_handle = GCHandle.Alloc(data, GCHandleType.Pinned);

            try {
                var ptr = array_handle.AddrOfPinnedObject();
                var res = AudioFormatPropertyNative.AudioFormatGetProperty(prop, sizeof(AudioFormatType), ref format, ref size, ptr);
                if (res != 0)
                {
                    return(null);
                }

                Array.Resize(ref data, (int)size / Marshal.SizeOf(typeof(T)));
                return(data);
            } finally {
                array_handle.Free();
            }
        }
        unsafe static T[]? GetAvailable <T> (AudioFormatProperty prop, AudioFormatType format)
        {
            uint size;

            if (AudioFormatPropertyNative.AudioFormatGetPropertyInfo(prop, sizeof(AudioFormatType), ref format, out size) != 0)
            {
                return(null);
            }

            var data         = new T[size / Marshal.SizeOf(typeof(T))];
            var array_handle = GCHandle.Alloc(data, GCHandleType.Pinned);              // This requires a pinned GCHandle, since it's not possible to use unsafe code to get the address of a generic object.

            try {
                var ptr = array_handle.AddrOfPinnedObject();
                var res = AudioFormatPropertyNative.AudioFormatGetProperty(prop, sizeof(AudioFormatType), ref format, ref size, ptr);
                if (res != 0)
                {
                    return(null);
                }

                Array.Resize(ref data, (int)size / Marshal.SizeOf(typeof(T)));
                return(data);
            } finally {
                array_handle.Free();
            }
        }
        unsafe static AudioFormatType[] GetFormats(AudioFormatProperty prop)
        {
            int size;

            if (AudioFormatPropertyNative.AudioFormatGetPropertyInfo(prop, 0, IntPtr.Zero, out size) != 0)
            {
                return(null);
            }

            var elementSize = sizeof(AudioFormatType);
            var data        = new AudioFormatType[size / elementSize];

            fixed(AudioFormatType *ptr = data)
            {
                var res = AudioFormatPropertyNative.AudioFormatGetProperty(prop, 0, IntPtr.Zero, ref size, (IntPtr)ptr);

                if (res != 0)
                {
                    return(null);
                }

                Array.Resize(ref data, elementSize);
                return(data);
            }
        }
        static AudioChannelLayout GetChannelLayout(AudioFormatProperty property, int value)
        {
            int size;
            AudioFormatPropertyNative.AudioFormatGetPropertyInfo (property, sizeof (AudioFormatProperty), ref value, out size);

            AudioChannelLayout layout;
            IntPtr ptr = Marshal.AllocHGlobal (size);
            if (AudioFormatPropertyNative.AudioFormatGetProperty (property, sizeof (AudioFormatProperty), ref value, ref size, ptr) == 0)
                layout = new AudioChannelLayout (ptr);
            else
                layout = null;

            Marshal.FreeHGlobal (ptr);
            return layout;
        }
Exemple #5
0
        unsafe static T[] GetAvailable <T> (AudioFormatProperty prop, AudioFormatType format) where T : struct
        {
            uint size;

            if (AudioFormatPropertyNative.AudioFormatGetPropertyInfo(prop, sizeof(AudioFormatType), ref format, out size) != 0)
            {
                return(null);
            }

            var data = new T[size / sizeof(T)];

            fixed(T *ptr = data)
            {
                var res = AudioFormatPropertyNative.AudioFormatGetProperty(prop, sizeof(AudioFormatType), ref format, ref size, (IntPtr)ptr);

                if (res != 0)
                {
                    return(null);
                }

                Array.Resize(ref data, (int)size / sizeof(T));
                return(data);
            }
        }
Exemple #6
0
        public static unsafe extern AudioFormatError AudioFormatGetProperty(AudioFormatProperty inPropertyID, int inSpecifierSize, AudioFormat* inSpecifier, ref int ioPropertyDataSize,
			out uint outPropertyData);
Exemple #7
0
        public static extern AudioFormatError AudioFormatGetProperty(AudioFormatProperty inPropertyID, int inSpecifierSize, IntPtr inSpecifier, ref int ioPropertyDataSize,
			ref AudioStreamBasicDescription outPropertyData);
Exemple #8
0
        public static unsafe extern AudioFormatError AudioFormatGetProperty(AudioFormatProperty propertyID, int inSpecifierSize, IntPtr inSpecifier,
			ref int ioDataSize, float* outPropertyData);
Exemple #9
0
        public static unsafe extern AudioFormatError AudioFormatGetProperty(AudioFormatProperty propertyID, int inSpecifierSize, ref AudioStreamBasicDescription inSpecifier,
			ref uint ioDataSize, int* outPropertyData);
Exemple #10
0
        public static unsafe extern AudioFormatError AudioFormatGetProperty(AudioFormatProperty propertyID, int inSpecifierSize, ref AudioFormatInfo inSpecifier,
			ref uint ioDataSize, AudioFormat* outPropertyData);
Exemple #11
0
        static AudioChannelLayout GetChannelLayout(AudioFormatProperty property, int value)
        {
            int size;
            AudioFormatPropertyNative.AudioFormatGetPropertyInfo (property, sizeof (AudioFormatProperty), ref value, out size);

            AudioChannelLayout layout;
            IntPtr ptr = Marshal.AllocHGlobal (size);
            if (AudioFormatPropertyNative.AudioFormatGetProperty (property, sizeof (AudioFormatProperty), ref value, ref size, ptr) == 0)
                layout = new AudioChannelLayout (ptr);
            else
                layout = null;

            Marshal.FreeHGlobal (ptr);
            return layout;
        }
		public unsafe extern static AudioFormatError AudioFormatGetProperty (AudioFormatProperty propertyID, int inSpecifierSize, ref AudioFormatType inSpecifier,
			ref uint ioDataSize, IntPtr outPropertyData);
		public unsafe extern static AudioFormatError AudioFormatGetProperty (AudioFormatProperty propertyID, int inSpecifierSize, ref int inSpecifier,
			ref int ioDataSize, int* outPropertyData);
Exemple #14
0
        public static extern AudioFormatError AudioFormatGetPropertyInfo(AudioFormatProperty propertyID, int inSpecifierSize, ref AudioStreamBasicDescription inSpecifier,
			out uint outPropertyDataSize);
 public unsafe extern static AudioFormatError AudioFormatGetProperty(AudioFormatProperty inPropertyID, int inSpecifierSize, AudioClassDescription *inSpecifier, ref int ioPropertyDataSize,
                                                                     out uint outPropertyData);
Exemple #16
0
        public static extern AudioFormatError AudioFormatGetPropertyInfo(AudioFormatProperty propertyID, int inSpecifierSize, IntPtr inSpecifier,
			out int outPropertyDataSize);
		public extern static AudioFormatError AudioFormatGetPropertyInfo (AudioFormatProperty propertyID, int inSpecifierSize, ref AudioFormatInfo inSpecifier,
			out uint outPropertyDataSize);