示例#1
0
 public WaveOutPlayer(int device, WaveFormat format, int bufferSize, int bufferCount, BufferFillEventHandler fillProc)
 {
     try
     {
         m_zero     = format.wBitsPerSample == 8 ? (byte)128 : (byte)0;
         m_FillProc = fillProc;
         WaveOutHelper.Try(WaveNative.waveOutOpen(out m_WaveOut, device, format, m_BufferProc, 0, WaveNative.CALLBACK_FUNCTION));
         AllocateBuffers(bufferSize, bufferCount);
         m_Thread = new Thread(new ThreadStart(ThreadProc));
         m_Thread.Start();
     }
     catch (Exception ex)
     {
         LogManage.WriteLog(this.GetType(), ex);
     }
 }
示例#2
0
        public WaveOutBuffer(IntPtr waveOutHandle, int size)
        {
            try
            {
                m_WaveOut = waveOutHandle;

                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;
                WaveOutHelper.Try(WaveNative.waveOutPrepareHeader(m_WaveOut, ref m_Header, Marshal.SizeOf(m_Header)));
            }
            catch (Exception ex)
            {
                LogManage.WriteLog(this.GetType(), ex);
            }
        }