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.
- Create an AutoResetEvent for each notification position.
- Obtain the Notify object by passing the CaptureBuffer object to the Notify constructor.
- 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 AutoResetEvent.Handle of one of the events you created in step 1.
- Call Notify.SetNotificationPositions, passing in the array of BufferPositionNotify structures.
You can now start the buffer in a separate thread and use WaitHandle.WaitAny to wait for notifications.