Platform SDK: DirectX |
The information in this topic pertains only to applications written in C and C++. See DirectSound Visual Basic Tutorials.
You receive capture notifications as events in the message loop, just as with playback notifications. Here is a sample loop:
BOOL Done = FALSE; while (!Done) { DWORD dwEvt = MsgWaitForMultipleObjects( NUMCAPTUREEVENTS, // How many possible events rghEvent, // Location of handles FALSE, // Wait for all? INFINITE, // How long to wait QS_ALLINPUT); // Any message is an event dwEvt -= WAIT_OBJECT_0; // If the event was set by the buffer, there's input // to process. if (dwEvt < NUMCAPTUREEVENTS) { StreamToFile(); } // If it's the last event, it's a message else if (dwEvt == NUMCAPTUREEVENTS) { while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) { if (msg.message == WM_QUIT) { Done = TRUE; } else { TranslateMessage(&msg); DispatchMessage(&msg); } } } // end message processing } // while (!Done)
As already noted, if you are receiving notifications from both a capture buffer and a secondary (output) buffer, you need to distinguish between the two types of events by the index value in dwEvt. For example, events 0 and 1 might be playback notifications, and events 2 and 3 might be capture notifications.