Esempio n. 1
0
        public AcmStream(IntPtr driverId, WaveFormat sourceFormat, WaveFilter waveFilter)
        {
            int num = Math.Max(16384, sourceFormat.AverageBytesPerSecond);

            this.sourceFormat = sourceFormat;
            num -= num % sourceFormat.BlockAlign;
            MmException.Try(AcmInterop.acmDriverOpen(out this.driverHandle, driverId, 0), "acmDriverOpen");
            MmException.Try(AcmInterop.acmStreamOpen(out this.streamHandle, this.driverHandle, sourceFormat, sourceFormat, waveFilter, IntPtr.Zero, IntPtr.Zero, AcmStreamOpenFlags.NonRealTime), "acmStreamOpen");
            this.streamHeader = new AcmStreamHeader(this.streamHandle, num, this.SourceToDest(num));
        }
Esempio n. 2
0
 public AcmStream(WaveFormat sourceFormat, WaveFormat destFormat)
 {
     try
     {
         this.streamHandle = IntPtr.Zero;
         this.sourceFormat = sourceFormat;
         int num = Math.Max(65536, sourceFormat.AverageBytesPerSecond);
         num -= num % sourceFormat.BlockAlign;
         MmException.Try(AcmInterop.acmStreamOpen(out this.streamHandle, IntPtr.Zero, sourceFormat, destFormat, null, IntPtr.Zero, IntPtr.Zero, AcmStreamOpenFlags.NonRealTime), "acmStreamOpen");
         int destBufferLength = this.SourceToDest(num);
         this.streamHeader = new AcmStreamHeader(this.streamHandle, num, destBufferLength);
         this.driverHandle = IntPtr.Zero;
     }
     catch
     {
         this.Dispose();
         throw;
     }
 }
Esempio n. 3
0
 protected virtual void Dispose(bool disposing)
 {
     if (disposing && this.streamHeader != null)
     {
         this.streamHeader.Dispose();
         this.streamHeader = null;
     }
     if (this.streamHandle != IntPtr.Zero)
     {
         MmResult mmResult = AcmInterop.acmStreamClose(this.streamHandle, 0);
         this.streamHandle = IntPtr.Zero;
         if (mmResult != MmResult.NoError)
         {
             throw new MmException(mmResult, "acmStreamClose");
         }
     }
     if (this.driverHandle != IntPtr.Zero)
     {
         AcmInterop.acmDriverClose(this.driverHandle, 0);
         this.driverHandle = IntPtr.Zero;
     }
 }