internal static AcmFormatInfo FromFormatTagDetails(ACMFORMATTAGDETAILS details, IntPtr hDriver, int driverId) { if (driverId == 0) { AcmNativeMethods.acmDriverID(hDriver, out driverId, 0); } AcmFormatInfo info = new AcmFormatInfo(); info.DriverId = driverId; //info.Format = new WaveFormat2( info.FormatName = details.szFormatTag; info.FormatTag = (FormatTag)details.dwFormatTag; for (int i = 0; i < details.cStandardFormats; i++) { ACMFORMATDETAILS fd = new ACMFORMATDETAILS(); fd.cbStruct = Marshal.SizeOf(fd); fd.cbwfx = details.cbFormatSize; WaveFormat2 fmt = new WaveFormat2(new byte[fd.cbwfx]); fmt.FormatTag = (FormatTag)details.dwFormatTag; fmt.Size = (short)(fd.cbwfx == 16 ? 0 : fd.cbwfx - 18); fmt.Extra = new byte[fmt.Size]; fd.pwfx = Marshal.AllocHGlobal(fd.cbwfx); Marshal.Copy(fmt.GetBytes(), 0, fd.pwfx, fd.cbwfx); fd.dwFormatIndex = i; fd.dwFormatTag = (int)info.FormatTag; /*MMResult mmr = */ int mmr = AcmNativeMethods.acmFormatDetails(hDriver, ref fd, AcmFormatDetailsFlags.INDEX); byte[] fmtData = new byte[fd.cbwfx]; Marshal.Copy(fd.pwfx, fmtData, 0, fd.cbwfx); info.Format = new WaveFormat2(fmtData); Marshal.FreeHGlobal(fd.pwfx); } return(info); }
extern static public int acmFormatDetails(IntPtr had, ref ACMFORMATDETAILS pafd, AcmFormatDetailsFlags fdwDetails);
extern static public int acmFormatEnum(IntPtr had, ref ACMFORMATDETAILS pafd, ACMFORMATENUMCB fnCallback, int dwInstance, int fdwEnum);