예제 #1
0
        private void DumpRecordBuffers()
        {
            while (m_qBuffers.Count > 0)
            {
                Monitor.Enter(m_qBuffers);
                WaveHeader hdr = (WaveHeader)m_qBuffers.Dequeue();
                Monitor.Exit(m_qBuffers);


                try
                {
                    m_streamRecord.Write(hdr.BufferData, 0, hdr.BytesRecorded);
                    //          m_streamRecord.Write(hdr.GetData(), 0, hdr.BytesRecorded);
                }
                catch (Exception ex)
                {
                    Debug.Write("Exception in stream.Write: " + ex.ToString());
                }
                hdr.Dispose();
            }
        }
예제 #2
0
        private void BufferWriteThreadProc(object header)
        {
            WaveHeader hdr = header as WaveHeader;

            Interlocked.Increment(ref m_workers);

            Debug.WriteLine(string.Format("Queued Worker Thread on header {0} - Flags == {1} [{2} running]", hdr.Pointer.ToString(), hdr.Flags.ToString(), m_workers));

            int ret = NativeMethods.waveOutWrite(m_hWaveOut, hdr.Pointer, hdr.HeaderLength);

            while ((hdr.Flags & WHDR_FLAGS.DONE) == 0)
            {
                Thread.Sleep(1);
            }

            Interlocked.Decrement(ref m_workers);

            Debug.WriteLine(string.Format("Worker Thread on header {0} Completed [{1} remain]", hdr.Pointer.ToString(), m_workers));

            CheckWaveError(NativeMethods.waveOutUnprepareHeader(m_hWaveOut, hdr.Pointer, hdr.HeaderLength));
            hdr.Dispose();
        }