|This is retired content. This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This content may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.|
An application must be able to determine when a device driver is finished with the data block, so that the application can unprepare and free the memory that is associated with the data block and header structure. The following list describes several ways to determine when a device driver is finished with a data block:
To use a callback function for driver messages
Messages that are sent to a callback function are similar to messages that are sent to a window, except that messages sent to a callback function have two DWORDparameters instead of one UINTand one DWORDparameter.
The following list describes the techniques for passing instance data from an application to a callback function:
Note If you need more than 32 bits of instance data, pass a pointer to a structure that contains the additional data.
To use an event callback
This action creates a nonsignaled event.
This call should be inside a loop that checks whether the WHDR_DONE flag is set in the dwFlagsmember of the WAVEHDRstructure.
Because event callbacks do not receive specific close, done, or open notifications, an application might have to check the status of the process that is waiting for notification after the event occurs. It is possible for a number of tasks to be completed by the time that WaitForSingleObjectreturns.
To use a window callback function
To use a callback thread
Note Messages that are sent to the window callback or the thread callback are specific to the audio I/O device type that is used.
In addition to using a callback function, you can poll the dwFlagsmember of a WAVEHDRstructure to determine when an audio I/O device is finished with a data block. You should sometimes poll dwFlagsrather than wait for another mechanism to receive messages from the drivers. For example, after calling the waveOutResetfunction or waveInResetfunction to release pending data blocks, you immediately can poll dwFlagsfor the WHDR_DONE flag to be sure that the data blocks have been released.
After you determine that the function has released the data block, call the waveInUnprepareHeaderfunction or the waveOutUnprepareHeaderfunction to unprepare the header file. After you have unprepared the header file, you can deallocate the memory normally.
Last updated on Tuesday, May 18, 2004