Using a Callback Function to Process Audio Driver Messages
You can also write your own callback function to process messages sent by the
device driver. To use a callback function, specify the CALLBACK_FUNCTION flag
in the dwFlags
parameter and the address of the callback in the dwCallback
parameter of the device-opening function.
Messages sent to a callback function are similar to messages sent to a window,
except that they have two doubleword parameters instead of one
unsigned-integer and one doubleword parameter.
Callback functions for the multimedia audio services are often called from
another thread running asynchronously from the application's thread. It is
therefore important to use critical sections to protect data shared between the
callback routine and the rest of the application. For more information about critical
sections, see Synchronization.
In 16-bit Windows, there is a limited set of APIs that an audio callback
function may call. In 32-bit Windows, that strict limitation has been removed.
However, it is strongly recommended that a 32-bit audio callback function restrain
its calls to a similar set of functions. Here is the recommended list:
If your audio callback function does stray from this list, it should be
careful not to call APIs that take a long time to complete. In particular, calling
wave and midi APIs may result in a deadlock.
If an audio callback shares data with other code, a Critical Section or
similar mutual exclusion mechanism should be used to protect the integrity of the
Use one of the following techniques to pass instance data from an application
to a callback function residing in a dynamic link library:
- Pass the instance data using the dwInstance parameter of the function that opens the device driver.
- Pass the instance data using the dwUser member of the WAVEHDR and MIDIHDR structures that identify an audio data block being sent to a device driver.
If you need more than 32 bits of instance data, pass a pointer to a structure
containing the additional information.
- Software for developers
Software for Android Developers
- More information resources
Unix Manual Pages
- Databases for Amazon shops developers
Amazon Categories Database
Browse Nodes Database