示例#1
0
//		readonly Int32 _bufferSize; // allocated bytes - may not be the same as bytes read
//		/// <summary>
//		/// The buffer-size in bytes.
//		/// </summary>
//		public int BufferSize
//		{
//			get { return _bufferSize; }
//		}
        #endregion properties


        #region cTor
        /// <summary>
        /// Creates a new WaveOutBuffer.
        /// </summary>
        /// <param name="hWaveOut">WaveOut device to write to</param>
        /// <param name="bufferSize">buffer size in bytes</param>
        /// <param name="bufferFillStream">stream to provide more data</param>
        /// <param name="waveOutLock">lock to protect WaveOut API's from being called on 2+ threads</param>
        internal WaveOutBuffer(IntPtr hWaveOut, Int32 bufferSize, WaveFileReader bufferFillStream, object waveOutLock)
        {
//			_bufferSize = bufferSize;

            _buffer  = new byte[bufferSize];
            _hBuffer = GCHandle.Alloc(_buffer, GCHandleType.Pinned);

            _hWaveOut     = hWaveOut;
            _waveProvider = bufferFillStream;
            _waveOutLock  = waveOutLock;

            _header              = new WaveHeader();
            _hHeader             = GCHandle.Alloc(_header, GCHandleType.Pinned);
            _header.dataBuffer   = _hBuffer.AddrOfPinnedObject();
            _header.bufferLength = bufferSize;
            _header.loops        = 1;

            _hThis           = GCHandle.Alloc(this);
            _header.userData = (IntPtr)_hThis;

            lock (_waveOutLock)
            {
                MultimediaException.Try(WaveInterop.waveOutPrepareHeader(_hWaveOut,
                                                                         _header,
                                                                         Marshal.SizeOf(_header)),
                                        "waveOutPrepareHeader");
            }
        }
示例#2
0
 public static extern MultimediaResult waveOutUnprepareHeader(IntPtr hWaveOut,
                                                              WaveHeader lpWaveOutHdr,
                                                              int uSize);
示例#3
0
 public static extern MultimediaResult waveOutWrite(IntPtr hWaveOut,
                                                    WaveHeader lpWaveOutHdr,
                                                    int uSize);