Beispiel #1
0
        /// <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);
        }
Beispiel #2
0
 public static extern MmResult acmFormatEnum(IntPtr hAcmDriver, ref AcmFormatDetails formatDetails, AcmFormatEnumCallback callback, IntPtr instance, AcmFormatEnumFlags flags);
Beispiel #3
0
 internal AcmFormat(AcmFormatDetails formatDetails)
 {
     this.formatDetails = formatDetails;
     waveFormat         = WaveFormat.MarshalFromPtr(formatDetails.waveFormatPointer);
 }
Beispiel #4
0
 private bool AcmFormatEnumCallback(IntPtr hAcmDriverId, ref AcmFormatDetails formatDetails, IntPtr dwInstance, AcmDriverDetailsSupportFlags flags)
 {
     tempFormatsList.Add(new AcmFormat(formatDetails));
     return(true);
 }
Beispiel #5
0
 internal AcmFormat(AcmFormatDetails formatDetails)
 {
     this.formatDetails = formatDetails;
     waveFormat = WaveFormat.MarshalFromPtr(formatDetails.waveFormatPointer);
 }
Beispiel #6
0
 private bool AcmFormatEnumCallback(IntPtr hAcmDriverId, ref AcmFormatDetails formatDetails, IntPtr dwInstance, AcmDriverDetailsSupportFlags flags)
 {
     tempFormatsList.Add(new AcmFormat(formatDetails));
     return true;
 }
Beispiel #7
0
 /// <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;
 }