Пример #1
0
 public static extern MmResult acmStreamOpen2(
     out IntPtr hAcmStream,
     IntPtr hAcmDriver,
     IntPtr sourceFormatPointer,
     IntPtr destFormatPointer,
     [In] WaveFilter waveFilter,
     IntPtr callback,
     IntPtr instance,
     AcmStreamOpenFlags openFlags);
Пример #2
0
 public static extern MmResult acmStreamOpen(
     out IntPtr hAcmStream,
     IntPtr hAcmDriver,
     [In, MarshalAs(UnmanagedType.CustomMarshaler, MarshalType = "NAudio.Wave.WaveFormatCustomMarshaler")]
     WaveFormat sourceFormat,
     [In, MarshalAs(UnmanagedType.CustomMarshaler, MarshalType = "NAudio.Wave.WaveFormatCustomMarshaler")]
     WaveFormat destFormat,
     [In] WaveFilter waveFilter,
     IntPtr callback,
     IntPtr instance,
     AcmStreamOpenFlags openFlags);
Пример #3
0
        /// <summary>
        /// Creates a new ACM stream to convert one format to another, using a
        /// specified driver identifier and wave filter
        /// </summary>
        /// <param name="driverId">the driver identifier</param>
        /// <param name="sourceFormat">the source format</param>
        /// <param name="waveFilter">the wave filter</param>
        public AcmStream(IntPtr driverId, WaveFormat sourceFormat, WaveFilter waveFilter)
        {
            int sourceBufferSize = Math.Max(16384, sourceFormat.AverageBytesPerSecond);

            this.sourceFormat = sourceFormat;
            sourceBufferSize -= (sourceBufferSize % sourceFormat.BlockAlign);
            MmException.Try(AcmInterop.acmDriverOpen(out driverHandle, driverId, 0), "acmDriverOpen");

            IntPtr sourceFormatPointer = WaveFormat.MarshalToPtr(sourceFormat);

            try
            {
                MmException.Try(AcmInterop.acmStreamOpen2(out streamHandle, driverHandle,
                                                          sourceFormatPointer, sourceFormatPointer, waveFilter, IntPtr.Zero, IntPtr.Zero, AcmStreamOpenFlags.NonRealTime), "acmStreamOpen");
            }
            finally
            {
                Marshal.FreeHGlobal(sourceFormatPointer);
            }
            streamHeader = new AcmStreamHeader(streamHandle, sourceBufferSize, SourceToDest(sourceBufferSize));
        }