Microsoft Windows CE 3.0  

Using Windows Messages to Manage Waveform Audio Playback

Important:
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.

You can send a variety of Windows CE messages to a window procedure function to manage waveform audio playback. The following table shows these messages.

Message Description
MM_WIM_CLOSE Sent when the waveOutCloseor the waveInClosefunction closes a device
MM_WIM_DATA Sent when the device driver finishes with a data block that is sent by the waveOutWriteor the waveInAddBufferfunction
MM_WIM_OPEN Sent when the waveOutOpenor the waveInOpenfunction opens a device

The MM_WIM_DATA message is the most useful message in the preceding table. When MM_WIM_DATA signals a completed data block, you can clean up and free that data block. Unless you need to allocate memory or initialize variables, you probably do not need to process the MM_WIM_OPEN message or the MM_WIM_CLOSE message.

Like other Windows-based messages, these Windows-based messages have a wParamparameter and an lParamparameter that are associated with them. The wParamparameter always specifies a handle to the open waveform audio output device. For the MM_WIM_DATA message, lParamspecifies a pointer to a WAVEHDRstructure. This structure identifies a completed data block. The MM_WIM_CLOSE and MM_WIM_OPEN messages do not use lParam.

The following code example shows how to process the MM_WIM_DATA message.

// WndProc-Main window procedure LRESULT FAR
PASCAL WndProc (HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{ switch (msg) { case MM_WIM_DATA: // A waveform audio data block
has been played and can now be // freed. waveOutUnprepareHeader
((HWAVEOUT)wParam, (LPWAVEHDR)lParam, sizeof (WAVEHDR)); // Free
hData memory waveOutClose ((HWAVEOUT)wParam); break; } return
DefWindowProc (hWnd, msg, wParam, lParam); }

The preceding example assumes that the application does not play multiple data blocks, so it can close the output device after playing a single data block.



 Last updated on Tuesday, May 18, 2004

© 2004 Microsoft Corporation. All rights reserved.