Capture Buffer Notification

When capturing audio, you might want your application to be notified when the read cursor reaches a certain point in the buffer, or when the buffer is stopped. By using the Notify.SetNotificationPositions method, you can set any number of points within the buffer where events are to be signaled. You cannot do this while the buffer is capturing.

To set up notifications, do the following.

  1. Create an AutoResetEventLeave Site for each notification position.
  2. Obtain the Notify object by passing the CaptureBuffer object to the Notify constructor.
  3. Create an array of BufferPositionNotify structures, one for each notification position. Set the Offset member to the byte offset where you want to be notified. Set the EventNotifyHandle member to the AutoResetEventLeave Site.HandleLeave Site of one of the events you created in step 1.
  4. Call Notify.SetNotificationPositions, passing in the array of BufferPositionNotify structures.

You can now start the buffer in a separate thread and use WaitHandleLeave Site.WaitAnyLeave Site to wait for notifications.