Пример #1
0
 public void Close()
 {
     WaveInRecorder.ThrowOnError(WaveNative.waveInUnprepareHeader(m_WaveIn, ref m_Header, Marshal.SizeOf(m_Header)));
     m_HeaderHandle.Free();
     m_Header.lpData = IntPtr.Zero;
     m_HeaderDataHandle.Free();
 }
Пример #2
0
        public WaveInBuffer(IntPtr waveInHandle, int size)
        {
            m_WaveIn = waveInHandle;

            m_HeaderHandle          = GCHandle.Alloc(m_Header, GCHandleType.Pinned);
            m_Header.dwUser         = (IntPtr)GCHandle.Alloc(this);
            m_HeaderData            = new byte[size];
            m_HeaderDataHandle      = GCHandle.Alloc(m_HeaderData, GCHandleType.Pinned);
            m_Header.lpData         = m_HeaderDataHandle.AddrOfPinnedObject();
            m_Header.dwBufferLength = size;
            WaveInRecorder.ThrowOnError(WaveNative.waveInPrepareHeader(m_WaveIn, ref m_Header, Marshal.SizeOf(m_Header)));
        }
Пример #3
0
        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();
        }
Пример #4
0
        public void Close()
        {
            m_Finished = true;
            WaveInRecorder.ThrowOnError(WaveNative.waveInReset(m_WaveIn));

            m_Thread.Join();
            m_Thread   = null;
            m_DoneProc = null;

            buffer1.WaitFor();
            buffer2.WaitFor();

            buffer1.Close();
            buffer2.Close();

            WaveInRecorder.ThrowOnError(WaveNative.waveInClose(m_WaveIn));
            m_WaveIn = IntPtr.Zero;
        }
Пример #5
0
 public void Record()
 {
     m_RecordEvent.Reset();
     WaveInRecorder.ThrowOnError(WaveNative.waveInAddBuffer(m_WaveIn, ref m_Header, Marshal.SizeOf(m_Header)));
 }