Allocating Audio Data Blocks

A version of this page is also available for

Windows Embedded CE 6.0 R3

4/8/2010

After you have determined the capabilities of your Windows Embedded CEā€“based device, you can allocate memory for your audio data blocks. Use the WAVEHDR structure to allocate the memory that the waveInAddBuffer and waveOutWrite functions need to play sound. The following table shows the functions that prepare headers.

Function Description

waveInPrepareHeader

Prepares a waveform audio input data block.

waveOutPrepareHeader

Prepares a waveform audio output data block.

Before passing an audio data block to a device driver with waveInAddBuffer or waveOutWrite, call the waveInPrepareHeader or the waveOutPrepareHeader function on the data block. This function allows both the audio driver and the operating system (OS) to do time consuming processing of the header and/or buffer once at initialization. The application can use the buffer repeatedly without additional processing by the driver or the OS.

For each header, the application should allocate its associated data buffer and set the lpData & dwBufferLength values in the header before calling waveInPrepareHeader.

An application should not attempt to prepare the same header on two different wave devices at the same time. If you want to record from one wave device and play back the same data to another wave device, but don't want to copy data between buffers, you can allocate two wave headers, point them both to the same data buffer, and then call waveInPrepareHeader on one and waveOutPrepareHeader on the other as appropriate.

Once initialized, pass the data block to waveInAddBuffer or waveOutWrite.

See Also

Concepts

Using the Waveform Audio Interface