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();
            }
        }
Example #3
0
        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;
        }
Example #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);
            }
        }
Example #6
0
        public static unsafe extern AudioFormatError AudioFormatGetProperty(AudioFormatProperty inPropertyID, int inSpecifierSize, AudioFormat* inSpecifier, ref int ioPropertyDataSize,
			out uint outPropertyData);
Example #7
0
        public static extern AudioFormatError AudioFormatGetProperty(AudioFormatProperty inPropertyID, int inSpecifierSize, IntPtr inSpecifier, ref int ioPropertyDataSize,
			ref AudioStreamBasicDescription outPropertyData);
Example #8
0
        public static unsafe extern AudioFormatError AudioFormatGetProperty(AudioFormatProperty propertyID, int inSpecifierSize, IntPtr inSpecifier,
			ref int ioDataSize, float* outPropertyData);
Example #9
0
        public static unsafe extern AudioFormatError AudioFormatGetProperty(AudioFormatProperty propertyID, int inSpecifierSize, ref AudioStreamBasicDescription inSpecifier,
			ref uint ioDataSize, int* outPropertyData);
Example #10
0
        public static unsafe extern AudioFormatError AudioFormatGetProperty(AudioFormatProperty propertyID, int inSpecifierSize, ref AudioFormatInfo inSpecifier,
			ref uint ioDataSize, AudioFormat* outPropertyData);
Example #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;
        }
Example #12
0
		public unsafe extern static AudioFormatError AudioFormatGetProperty (AudioFormatProperty propertyID, int inSpecifierSize, ref AudioFormatType inSpecifier,
			ref uint ioDataSize, IntPtr outPropertyData);
Example #13
0
		public unsafe extern static AudioFormatError AudioFormatGetProperty (AudioFormatProperty propertyID, int inSpecifierSize, ref int inSpecifier,
			ref int ioDataSize, int* outPropertyData);
Example #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);
Example #16
0
        public static extern AudioFormatError AudioFormatGetPropertyInfo(AudioFormatProperty propertyID, int inSpecifierSize, IntPtr inSpecifier,
			out int outPropertyDataSize);
Example #17
0
		public extern static AudioFormatError AudioFormatGetPropertyInfo (AudioFormatProperty propertyID, int inSpecifierSize, ref AudioFormatInfo inSpecifier,
			out uint outPropertyDataSize);