internal SoundIODevice(IntPtr device) { IntPtr ptr; int size; handle = device; Id = MarshalHelper.ReadStringAnsiField <SoundIoDevice>(handle, "Id"); Name = MarshalHelper.ReadStringAnsiField <SoundIoDevice>(handle, "Name"); Aim = (SoundIoDeviceAim)MarshalHelper.ReadInt32Field <SoundIoDevice>(handle, "Aim"); LayoutCount = MarshalHelper.ReadInt32Field <SoundIoDevice>(handle, "LayoutCount"); CurrentLayout = new SoundIOChannelLayout(handle + MarshalHelper.OffsetOf <SoundIoDevice>("CurrentLayout")); layouts = new SoundIOChannelLayout[LayoutCount]; ptr = MarshalHelper.ReadIntPtrField <SoundIoDevice>(handle, "Layouts"); size = Marshal.SizeOf(typeof(SoundIoChannelLayout)); for (int n = 0; n < LayoutCount; n++) { layouts[n] = new SoundIOChannelLayout(ptr); ptr += size; } FormatCount = MarshalHelper.ReadInt32Field <SoundIoDevice>(handle, "FormatCount"); CurrentFormat = (SoundIoFormat)MarshalHelper.ReadInt32Field <SoundIoDevice>(handle, "CurrentFormat"); formats = new SoundIoFormat[FormatCount]; ptr = MarshalHelper.ReadIntPtrField <SoundIoDevice>(handle, "Formats"); size = sizeof(int); for (int n = 0; n < FormatCount; n++) { formats[n] = (SoundIoFormat)Marshal.ReadInt32(ptr); ptr += size; } SamleRateCount = MarshalHelper.ReadInt32Field <SoundIoDevice>(handle, "SamleRateCount"); CurrentSampleRate = MarshalHelper.ReadInt32Field <SoundIoDevice>(handle, "SampleRateCurrent"); sampleRates = new SoundIoSampleRateRange[SamleRateCount]; ptr = MarshalHelper.ReadIntPtrField <SoundIoDevice>(handle, "SampleRates"); size = Marshal.SizeOf(typeof(SoundIoSampleRateRange)); for (int n = 0; n < SamleRateCount; n++) { sampleRates[n] = (SoundIoSampleRateRange)Marshal.PtrToStructure(ptr, typeof(SoundIoSampleRateRange)); ptr += size; } IsRaw = MarshalHelper.ReadByteField <SoundIoDevice>(handle, "IsRaw") != 0; ProbeError = (SoundIoError)MarshalHelper.ReadInt32Field <SoundIoDevice>(handle, "ProbeError"); }
/// <summary> /// Whether specified <see cref="SoundIOChannelLayout"/> is supported by the device. /// </summary> /// <param name="layout">Channel layout to validate support for.</param> /// <returns>Value indicating whether channel layout is supported.</returns> public bool SupportsLayout(SoundIOChannelLayout layout) { return(NativeMethods.SoundIoDeviceSupportsLayout(handle, layout.Handle)); }