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); }
internal int AcmFormatTagEnumCB(IntPtr hadid, /*ref ACMFORMATTAGDETAILS*/ IntPtr pafd, int dwInstance, int fdwSupport) { try { ACMFORMATTAGDETAILS afd = (ACMFORMATTAGDETAILS)Marshal.PtrToStructure(pafd, typeof(ACMFORMATTAGDETAILS)); AcmFormatInfo info = AcmFormatInfo.FromFormatTagDetails(afd, (IntPtr)dwInstance, (int)hadid); _formats.Add(info); } catch (Exception ex) { if (System.Diagnostics.Debugger.IsAttached) { System.Diagnostics.Debugger.Break(); } System.Diagnostics.Debug.WriteLine("AcmFormatTagEnumCB error: " + ex.Message); } return(1); }