Ejemplo n.º 1
0
        public WaveOutBuffer(IntPtr waveOutHandle, int size)
        {
            m_WaveOut = waveOutHandle;

            _mHeaderHandle          = GCHandle.Alloc(_mHeader, GCHandleType.Pinned);
            _mHeader.dwUser         = (IntPtr)GCHandle.Alloc(this);
            _mHeaderData            = new byte[size];
            _mHeaderDataHandle      = GCHandle.Alloc(_mHeaderData, GCHandleType.Pinned);
            _mHeader.lpData         = _mHeaderDataHandle.AddrOfPinnedObject();
            _mHeader.dwBufferLength = size;
            WaveOutHelper.Try(WaveNative.waveOutPrepareHeader(m_WaveOut, ref _mHeader, Marshal.SizeOf(_mHeader)));
        }
Ejemplo n.º 2
0
 public WaveOutPlayer(int device, WaveFormat format, int bufferSize, int bufferCount,
                      BufferFillEventHandler fillProc)
 {
     _mZero     = format.wBitsPerSample == 8 ? (byte)128 : (byte)0;
     _mFillProc = fillProc;
     WaveOutHelper.Try(WaveNative.waveOutOpen(out _mWaveOut, device, format, m_BufferProc, 0,
                                              WaveNative.CallbackFunction));
     AllocateBuffers(bufferSize, bufferCount);
     _mThread = new Thread(ThreadProc)
     {
         IsBackground = true
     };
     _mThread.Start();
 }