Example #1
0
 private void DoRecording()
 {
     WaveInBuffer[] array = this.buffers;
     for (int i = 0; i < array.Length; i++)
     {
         WaveInBuffer waveInBuffer = array[i];
         if (!waveInBuffer.InQueue)
         {
             waveInBuffer.Reuse();
         }
     }
     while (this.recording)
     {
         if (this.callbackEvent.WaitOne() && this.recording)
         {
             array = this.buffers;
             for (int i = 0; i < array.Length; i++)
             {
                 WaveInBuffer waveInBuffer2 = array[i];
                 if (waveInBuffer2.Done)
                 {
                     if (this.DataAvailable != null)
                     {
                         this.DataAvailable(this, new WaveInEventArgs(waveInBuffer2.Data, waveInBuffer2.BytesRecorded));
                     }
                     waveInBuffer2.Reuse();
                 }
             }
         }
     }
 }
Example #2
0
 private void EnqueueBuffers()
 {
     WaveInBuffer[] array = this.buffers;
     for (int i = 0; i < array.Length; i++)
     {
         WaveInBuffer waveInBuffer = array[i];
         if (!waveInBuffer.InQueue)
         {
             waveInBuffer.Reuse();
         }
     }
 }
Example #3
0
 private void Callback(IntPtr waveInHandle, WaveInterop.WaveMessage message, IntPtr userData, WaveHeader waveHeader, IntPtr reserved)
 {
     if (message == WaveInterop.WaveMessage.WaveInData && this.recording)
     {
         WaveInBuffer waveInBuffer = (WaveInBuffer)((GCHandle)waveHeader.userData).Target;
         if (waveInBuffer == null)
         {
             return;
         }
         this.lastReturnedBufferIndex = Array.IndexOf <WaveInBuffer>(this.buffers, waveInBuffer);
         this.RaiseDataAvailable(waveInBuffer);
         try
         {
             waveInBuffer.Reuse();
         }
         catch (Exception e)
         {
             this.recording = false;
             this.RaiseRecordingStopped(e);
         }
     }
 }