Allocating Audio Data Blocks (Windows Embedded CE 6.0)
1/6/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 |
---|---|
Prepares a waveform audio input data block. |
|
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.