Example #1
0
 /// <summary>Callback function for handling recording process information.</summary>
 /// <param name="hdrvr">Audio input device handler.</param>
 /// <param name="uMsg">WIM_CLOSE, WIM_DONE, WIM_OPEN</param>
 /// <param name="dwUser">Additional data for clients use.</param>
 /// <param name="wavhdr">Wave Header.</param>
 /// <param name="dwParam2">Additional parameter.</param>
 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 (Exception ex)
         {
             throw ex;
         }
     }
 }
Example #2
0
        /// <summary>
        /// Free the internal buffers.
        /// </summary>
        private void _FreeBuffers()
        {
            _currentBuffer = null;
            if (_buffers != null)
            {
                WaveInBuffer first = _buffers;
                _buffers = null;

                WaveInBuffer current = first;
                do
                {
                    WaveInBuffer Next = current.NextBuffer;
                    current.Dispose();
                    current = Next;
                } while (current != first);
            }
        }
Example #3
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)
     {
         _buffers = new WaveInBuffer(_pWaveIn, bufferSize);
         WaveInBuffer Prev = _buffers;
         try
         {
             for (int i = 1; i < bufferCount; i++)
             {
                 WaveInBuffer Buf = new WaveInBuffer(_pWaveIn, bufferSize);
                 Prev.NextBuffer = Buf;
                 Prev            = Buf;
             }
         }
         finally
         {
             Prev.NextBuffer = _buffers;
         }
     }
 }
 /// <summary>
 /// Select next internal buffer.
 /// </summary>
 private void _SelectNextBuffer()
 {
     _currentBuffer = _currentBuffer == null ? _buffers : _currentBuffer.NextBuffer;
 }
        /// <summary>
        /// Free the internal buffers.
        /// </summary>
        private void _FreeBuffers()
        {
            _currentBuffer = null;
            if (_buffers != null)
            {
                WaveInBuffer first = _buffers;
                _buffers = null;

                WaveInBuffer current = first;
                do
                {
                    WaveInBuffer Next = current.NextBuffer;
                    current.Dispose();
                    current = Next;
                } while (current != first);
            }
        }
 /// <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)
     {
         _buffers = new WaveInBuffer(_pWaveIn, bufferSize);
         WaveInBuffer Prev = _buffers;
         try
         {
             for (int i = 1; i < bufferCount; i++)
             {
                 WaveInBuffer Buf = new WaveInBuffer(_pWaveIn, bufferSize);
                 Prev.NextBuffer = Buf;
                 Prev = Buf;
             }
         }
         finally
         {
             Prev.NextBuffer = _buffers;
         }
     }
 }