/// <summary> /// Called when we get a new buffer of recorded data /// </summary> private void Callback(IntPtr waveInHandle, WaveInterop.WaveMessage message, IntPtr userData, WaveHeader waveHeader, IntPtr reserved) { if (message == WaveInterop.WaveMessage.WaveInData) { GCHandle hBuffer = (GCHandle)waveHeader.userData; WaveInBuffer buffer = (WaveInBuffer)hBuffer.Target; Exception exception = null; if (DataAvailable != null) { DataAvailable(this, new WaveInEventArgs(buffer.Data, buffer.BytesRecorded)); } if (recording) { try { buffer.Reuse(); } catch (Exception e) { recording = false; exception = e; } } if (!recording) { RaiseRecordingStopped(exception); } } }
/// <summary> /// Called when we get a new buffer of recorded data /// </summary> private void Callback(IntPtr waveInHandle, WaveInterop.WaveMessage message, int userData, WaveHeader waveHeader, int reserved) { if (message == WaveInterop.WaveMessage.WaveInData) { GCHandle hBuffer = (GCHandle)waveHeader.userData; WaveInBuffer buffer = (WaveInBuffer)hBuffer.Target; length += buffer.BytesRecorded; if (DataAvailable != null) { DataAvailable(this, new WaveInEventArgs(buffer.Data, buffer.BytesRecorded)); } if (recording) { buffer.Reuse(); } else { if (RecordingStopped != null) { RecordingStopped(this, EventArgs.Empty); } } } }
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); } } }