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.
A version of this page is also available for
4/8/2010

This function prepares a buffer for waveform input. 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.

Syntax

MMRESULT waveInPrepareHeader(
  HWAVEIN 
hwi, 
  LPWAVEHDR 
pwh, 
  UINT 
cbwh 
); 

Parameters

hwi

Handle to the waveform-audio input device.

pwh

Pointer to a WAVEHDRstructure that identifies the buffer to be prepared. The buffer's base address must be aligned with the respect to the sample size.

cbwh

Size, in bytes, of the WAVEHDRstructure.

Return Value

One of the values described in the following table is returned.

Value Description

MMSYSERR_NOERROR

Success.

MMSYSERR_INVALHANDLE

Specified device handle is invalid.

MMSYSERR_INVALPARAM

The buffer's base address is not aligned with the sample size.

MMSYSERR_NODRIVER

No device driver is present.

MMSYSERR_NOMEM

Unable to allocate or lock memory.

Remarks

The lpData, dwBufferLength, and dwFlagsmembers of the WAVEHDRstructure must be set before calling this function ( dwFlagsmust be zero).

Once prepared, the application may not change the lpDatafield. The dwFlags, dwBufferLength, and dwLoopsmembers of the WAVEHDRstructure can change between calls to this function and the waveOutWritefunction, but it should never be increased above the amount originally specified in the call to waveInPrepareHeader. For example, when playing from a file an application will typically pass the same amount of data to the driver on each call to waveOutWrite until it hits the end-of-file. At that point, it will pass the remaining file data in a partial buffer (with a smaller value in dwBufferLength).

The only flags in the dwFlagsmember that you can change during this interval are WHDR_BEGINLOOP and WHDR_ENDLOOP. You can only change these flags as a matched pair; therefore, if you add or remove one of these flags, you must add or remove the other. If you change the size specified by dwBufferLengthbefore the call to waveOutWrite, the new value must be less than the prepared value.

Preparing a header that has already been prepared has no effect, and the function returns zero.

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.

Requirements

Header mmsystem.h
Library coredll.lib
Windows Embedded CE Windows CE 2.0 and later
Windows Mobile Windows Mobile Version 5.0 and later

See Also