/// <summary> /// Creates a new Wave input stream /// </summary> /// <param name="deviceNumber">The device to open - 0 is default</param> /// <param name="desiredFormat">The PCM format to record in</param> /// <param name="callbackWindow">If this parameter is non-null, the Wave In Messages /// will be sent to the message loop of the supplied control. This is considered a /// safer way to use the waveIn functionality</param> public WaveInStream(int deviceNumber, WaveFormat desiredFormat, System.Windows.Forms.Control callbackWindow) { this.waveFormat = desiredFormat; callback = new WaveInterop.WaveCallback(Callback); if (callbackWindow == null) { MmException.Try(WaveInterop.waveInOpen(out waveInHandle, deviceNumber, desiredFormat, callback, 0, WaveInterop.CallbackFunction), "waveInOpen"); } else { waveInWindow = new WaveWindowNative(callback); MmException.Try(WaveInterop.waveInOpenWindow(out waveInHandle, deviceNumber, desiredFormat, callbackWindow.Handle, 0, WaveInterop.CallbackWindow), "waveInOpen"); waveInWindow.AssignHandle(callbackWindow.Handle); } // Default to three buffers of 100ms each int bufferSize = desiredFormat.AverageBytesPerSecond / 10; numBuffers = 3; buffers = new WaveInBuffer[numBuffers]; for (int n = 0; n < numBuffers; n++) { buffers[n] = new WaveInBuffer(waveInHandle, bufferSize); } }
// Token: 0x060009E7 RID: 2535 RVA: 0x0001C880 File Offset: 0x0001AA80 internal MmResult WaveInOpen(out IntPtr waveInHandle, int deviceNumber, WaveFormat waveFormat, WaveInterop.WaveCallback callback) { MmResult result; if (this.Strategy == WaveCallbackStrategy.FunctionCallback) { result = WaveInterop.waveInOpen(out waveInHandle, (IntPtr)deviceNumber, waveFormat, callback, IntPtr.Zero, WaveInterop.WaveInOutOpenFlags.CallbackFunction); } else { result = WaveInterop.waveInOpenWindow(out waveInHandle, (IntPtr)deviceNumber, waveFormat, this.Handle, IntPtr.Zero, WaveInterop.WaveInOutOpenFlags.CallbackWindow); } return(result); }