internal static void WaveInProc(IntPtr hdrvr, int uMsg, int dwUser, ref WaveNative.WaveHdr wavhdr, int dwParam2) { if (uMsg == WaveNative.MM_WIM_DATA) { GCHandle h = (GCHandle)wavhdr.dwUser; WaveInBuffer buf = (WaveInBuffer)h.Target; buf.OnCompleted(); } }
private void WaitForAllBuffers() { WaveInBuffer Buf = m_Buffers; while (Buf.NextBuffer != m_Buffers) { Buf.WaitFor(); Buf = Buf.NextBuffer; } }
/// <summary>Wait for buffers</summary> private void WaitForAllBuffers() { WaveInBuffer buf = _cBuffers; while (buf._cNextBuffer != _cBuffers) { buf.WaitFor(); buf = buf._cNextBuffer; } }
internal static void WaveInProc(IntPtr hdrvr, int uMsg, int dwUser, ref WAVEHDR wavhdr, int dwParam2) { if (uMsg == MM_WIM_DATA) { try { GCHandle h = (GCHandle)wavhdr.dwUser; WaveInBuffer buf = (WaveInBuffer)h.Target; buf.OnCompleted(); } catch { } } }
private void FreeBuffers() { m_CurrentBuffer = null; if (m_Buffers != null) { WaveInBuffer First = m_Buffers; m_Buffers = null; WaveInBuffer Current = First; do { WaveInBuffer Next = Current.NextBuffer; Current.Dispose(); Current = Next; } while(Current != First); } }
private void ThreadProc() { while (!m_Finished) { m_CurrentBuffer = (m_CurrentBuffer == buffer1) ? buffer2 : buffer1; m_CurrentBuffer.WaitFor(); m_DoneProc(m_CurrentBuffer.Data, m_CurrentBuffer.Size); if (m_Finished) { break; } m_CurrentBuffer.Record(); } }
public WaveInRecorder(int device, WaveFormat format, int bufferSize, BufferDoneEventHandler doneProc) { m_DoneProc = doneProc; WaveInRecorder.ThrowOnError(WaveNative.waveInOpen(out m_WaveIn, device, format, m_BufferProc, 0, WaveNative.CALLBACK_FUNCTION)); buffer1 = new WaveInBuffer(m_WaveIn, bufferSize); buffer2 = new WaveInBuffer(m_WaveIn, bufferSize); buffer1.Record(); buffer2.Record(); m_CurrentBuffer = buffer1; WaveInRecorder.ThrowOnError(WaveNative.waveInStart(m_WaveIn)); m_Thread = new Thread(new ThreadStart(ThreadProc)); m_Thread.Start(); }
/// <summary>Free the internal buffers</summary> private void FreeBuffers() { _cCurrentBuffer = null; if (_cBuffers != null) { WaveInBuffer first = _cBuffers; _cBuffers = null; WaveInBuffer current = first; do { WaveInBuffer Next = current._cNextBuffer; current.Dispose(); current = Next; } while(current != first); } }
private void AllocateBuffers(int bufferSize, int bufferCount) { FreeBuffers(); if (bufferCount > 0) { m_Buffers = new WaveInBuffer(m_WaveIn, bufferSize); WaveInBuffer Prev = m_Buffers; try { for (int i = 1; i < bufferCount; i++) { WaveInBuffer Buf = new WaveInBuffer(m_WaveIn, bufferSize); Prev.NextBuffer = Buf; Prev = Buf; } } finally { Prev.NextBuffer = m_Buffers; } } }
/// <summary>Allocate internal buffers</summary> /// <param name="bufferSize">size of buffer</param> /// <param name="bufferCount">number of buffers to allocate</param> private void AllocateBuffers(uint bufferSize, uint bufferCount) { FreeBuffers(); if (bufferCount > 0) { _cBuffers = new WaveInBuffer(_pWaveIn, bufferSize); WaveInBuffer Prev = _cBuffers; try { for (int i = 1; i < bufferCount; i++) { WaveInBuffer Buf = new WaveInBuffer(_pWaveIn, bufferSize); Prev._cNextBuffer = Buf; Prev = Buf; } } finally { Prev._cNextBuffer = _cBuffers; } } }
private void SelectNextBuffer() { m_CurrentBuffer = m_CurrentBuffer == null ? m_Buffers : m_CurrentBuffer.NextBuffer; }
/// <summary>Select next internal buffer</summary> private void SelectNextBuffer() { _cCurrentBuffer = _cCurrentBuffer == null ? _cBuffers : _cCurrentBuffer._cNextBuffer; }