/// <summary> /// Gets all the supported formats for a given format tag /// </summary> /// <param name="formatTag">Format tag</param> /// <returns>Supported formats</returns> public IEnumerable <AcmFormat> GetFormats(AcmFormatTag formatTag) { if (driverHandle == IntPtr.Zero) { throw new InvalidOperationException("Driver must be opened first"); } tempFormatsList = new List <AcmFormat>(); var formatDetails = new AcmFormatDetails(); formatDetails.structSize = Marshal.SizeOf(formatDetails); // need to make sure we have enough space for a waveFormat. formatTag.FormatSize isn't reliable, // and some codecs MaxFormatSize isn't either formatDetails.waveFormatByteSize = 1024; formatDetails.waveFormatPointer = Marshal.AllocHGlobal(formatDetails.waveFormatByteSize); formatDetails.formatTag = (int)formatTag.FormatTag; // (int)WaveFormatEncoding.Unknown var result = AcmInterop.acmFormatEnum(driverHandle, ref formatDetails, AcmFormatEnumCallback, IntPtr.Zero, AcmFormatEnumFlags.None); Marshal.FreeHGlobal(formatDetails.waveFormatPointer); MmException.Try(result, "acmFormatEnum"); return(tempFormatsList); }
/// <summary> /// Gets all the supported formats for a given format tag /// </summary> /// <param name="formatTag">Format tag</param> /// <returns>Supported formats</returns> public IEnumerable<AcmFormat> GetFormats(AcmFormatTag formatTag) { if (driverHandle == IntPtr.Zero) { throw new InvalidOperationException("Driver must be opened first"); } tempFormatsList = new List<AcmFormat>(); var formatDetails = new AcmFormatDetails(); formatDetails.structSize = Marshal.SizeOf(formatDetails); // need to make sure we have enough space for a waveFormat. formatTag.FormatSize isn't reliable, // and some codecs MaxFormatSize isn't either formatDetails.waveFormatByteSize = 1024; formatDetails.waveFormatPointer = Marshal.AllocHGlobal(formatDetails.waveFormatByteSize); formatDetails.formatTag = (int)formatTag.FormatTag; // (int)WaveFormatEncoding.Unknown var result = AcmInterop.acmFormatEnum(driverHandle, ref formatDetails, AcmFormatEnumCallback, IntPtr.Zero, AcmFormatEnumFlags.None); Marshal.FreeHGlobal(formatDetails.waveFormatPointer); MmException.Try(result,"acmFormatEnum"); return tempFormatsList; }