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 / Marshal.SizeOf(typeof(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 / Marshal.SizeOf(typeof(T))); return(data); } }
public unsafe static AudioChannelLayoutTag[] GetTagsForNumberOfChannels(int count) { const int type_size = sizeof(uint); int size; if (AudioFormatPropertyNative.AudioFormatGetPropertyInfo(AudioFormatProperty.TagsForNumberOfChannels, type_size, ref count, out size) != 0) { return(null); } var data = new AudioChannelLayoutTag[size / type_size]; fixed(AudioChannelLayoutTag *ptr = data) { var res = AudioFormatPropertyNative.AudioFormatGetProperty(AudioFormatProperty.TagsForNumberOfChannels, type_size, ref count, ref size, (int *)ptr); if (res != 0) { return(null); } return(data); } }
public unsafe static AudioChannelLayoutTag[] GetAvailableEncodeChannelLayoutTags(AudioStreamBasicDescription format) { var type_size = sizeof(AudioStreamBasicDescription); uint size; if (AudioFormatPropertyNative.AudioFormatGetPropertyInfo(AudioFormatProperty.AvailableEncodeChannelLayoutTags, type_size, ref format, out size) != 0) { return(null); } var data = new AudioChannelLayoutTag[size / sizeof(AudioChannelLayoutTag)]; fixed(AudioChannelLayoutTag *ptr = data) { var res = AudioFormatPropertyNative.AudioFormatGetProperty(AudioFormatProperty.AvailableEncodeChannelLayoutTags, type_size, ref format, ref size, (int *)ptr); if (res != 0) { return(null); } return(data); } }
public static AudioFormatError GetFormatInfo(ref AudioStreamBasicDescription format) { var size = Marshal.SizeOf(format); return(AudioFormatPropertyNative.AudioFormatGetProperty(AudioFormatProperty.FormatInfo, 0, IntPtr.Zero, ref size, ref format)); }