Inheritance: IDisposable
Example #1
0
 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();
     }
 }
Example #2
0
        private void WaitForAllBuffers()
        {
            WaveInBuffer Buf = m_Buffers;

            while (Buf.NextBuffer != m_Buffers)
            {
                Buf.WaitFor();
                Buf = Buf.NextBuffer;
            }
        }
Example #3
0
        /// <summary>Wait for buffers</summary>
        private void WaitForAllBuffers()
        {
            WaveInBuffer buf = _cBuffers;

            while (buf._cNextBuffer != _cBuffers)
            {
                buf.WaitFor();
                buf = buf._cNextBuffer;
            }
        }
Example #4
0
 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 { }
     }
 }
Example #5
0
        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);
            }
        }
Example #6
0
        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();
            }
        }
Example #7
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();
        }
Example #8
0
        /// <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);
            }
        }
Example #9
0
 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;
         }
     }
 }
Example #10
0
 /// <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;
         }
     }
 }
Example #11
0
 private void SelectNextBuffer()
 {
     m_CurrentBuffer = m_CurrentBuffer == null ? m_Buffers : m_CurrentBuffer.NextBuffer;
 }
Example #12
0
        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);
            }
        }
Example #13
0
 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;
         }
     }
 }
Example #14
0
 private void SelectNextBuffer()
 {
     m_CurrentBuffer = m_CurrentBuffer == null ? m_Buffers : m_CurrentBuffer.NextBuffer;
 }
Example #15
0
 /// <summary>Select next internal buffer</summary>
 private void SelectNextBuffer()
 {
     _cCurrentBuffer = _cCurrentBuffer == null ? _cBuffers : _cCurrentBuffer._cNextBuffer;
 }