日期:2014-05-17 浏览次数:20998 次
private void RecordCapturedData() { byte[] CaptureData = null; int ReadPos; int CapturePos; int LockSize; mRecBuffer.GetCurrentPosition(out CapturePos, out ReadPos); LockSize = ReadPos - mNextCaptureOffset; if (LockSize < 0) LockSize += mBufferSize; LockSize -= (LockSize % mNotifySize); if (0 == LockSize) return; CaptureData = (byte[])mRecBuffer.Read(mNextCaptureOffset, typeof(byte), LockFlag.None, LockSize); mNextCaptureOffset += CaptureData.Length; mNextCaptureOffset %= mBufferSize; //check state if (state == State.Recording || state == State.PreRecording) { secondBuffer.Add(CaptureData); } }
public class Recorder { //由于长度限制,变量略 public void Initialize() { // Create capture buffer. CreateCaptureBuffer(); // Create notification system. InitNotifications(); mRecBuffer.Start(true); } public void Dispose() { // Close notification if (null != mNotificationEvent) mNotificationEvent.Set(); // Stop recording mRecBuffer.Stop(); } #endregion #region Initialize Recorder public Recorder() { InitCaptureDevice(); mWavFormat = CreateWaveFormat(); buffDes = new BufferDescription(); buffDes.GlobalFocus = true; buffDes.ControlVolume = true; buffDes.ControlPan = true; secDev = new Device(); bufferStates = new List<int>(); } private void RecordCapturedData() { byte[] CaptureData = null; int ReadPos; int CapturePos; int LockSize; mRecBuffer.GetCurrentPosition(out CapturePos, out ReadPos); LockSize = ReadPos - mNextCaptureOffset; if (LockSize < 0) LockSize += mBufferSize; LockSize -= (LockSize % mNotifySize); if (0 == LockSize) return; CaptureData = (byte[])mRecBuffer.Read(mNextCaptureOffset, typeof(byte), LockFlag.None, LockSize); mNextCaptureOffset += CaptureData.Length; mNextCaptureOffset %= mBufferSize; //check state if (state == State.Recording || state == State.PreRecording) { secondBuffer.Add(CaptureData); } } private void CreateCaptureBuffer() { CaptureBufferDescription bufferdescription = new CaptureBufferDescription(); if (null != mNotify) { mNotify.Dispose(); mNotify = null; } if (null != mRecBuffer)