Managing Data Blocks by Polling

In addition to using a callback function, you can poll the dwFlags member of a WAVEHDR structure to determine when an audio device is finished with a data block. Sometimes it is better to poll dwFlags than to wait for another mechanism to receive messages from the drivers. For example, after you call the waveOutReset function to release pending data blocks, you can immediately poll to be sure that the data blocks have been released before calling waveOutUnprepareHeader and freeing the memory for the data block.

You can use the WHDR_DONE flag to test the dwFlags member. As soon as the WHDR_DONE flag is set in the dwFlags member of the WAVEHDR structure, the driver is finished with the data block.