Skip to content

Latest commit

 

History

History
35 lines (26 loc) · 2.28 KB

using-a-callback-function-to-process-driver-messages.md

File metadata and controls

35 lines (26 loc) · 2.28 KB
title description ms.assetid keywords ms.topic ms.date ms.custom
Using a Callback Function to Process Driver Messages
Using a Callback Function to Process Driver Messages
7fef400f-5040-4d33-9a2f-bb12aa9369e0
waveform audio,callback functions
audio data blocks,callback functions
waveform audio,processing driver messages
audio data blocks,processing driver messages
processing driver messages
waveInOpen function
waveOutOpen function
article
4/26/2023
UpdateFrequency5

Using a Callback Function to Process Driver Messages

[The feature associated with this page, Waveform Audio, is a legacy feature. It has been superseded by WASAPI and Audio Graphs. WASAPI and Audio Graphs have been optimized for Windows 10 and Windows 11. Microsoft strongly recommends that new code use WASAPI and Audio Graphs instead of Waveform Audio, when possible. Microsoft suggests that existing code that uses the legacy APIs be rewritten to use the new APIs if possible.]

You can 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 fdwOpen parameter and the address of the callback in the dwCallback parameter of the waveInOpen or waveOutOpen function.

Messages sent to a callback function are similar to messages sent to a window, except they have two DWORD parameters instead of a UINT and a DWORD parameter. For details on these messages, see Playing Waveform-Audio Files.

To pass instance data from an application to a callback function, use one of the following techniques:

  • 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 structure that identifies 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.