Compartir a través de


Querying Audio I/O Devices

A version of this page is also available for

Windows Embedded CE 6.0 R3

4/8/2010

The following table shows the functions that retrieve the number of audio devices on a Windows Embedded CE–based device.

Function Description

waveInGetNumDevs

Retrieves the number of waveform audio input devices that are present in a system.

waveOutGetNumDevs

Retrieves the number of waveform audio output devices that are present in a system.

After you determine how many audio devices are present in a system, you can query the capabilities of each device. The following table shows the functions and structures that retrieve this information.

Function Description Returned structure

waveInGetDevCaps

Retrieves the capabilities of a specified waveform audio input device.

WAVEINCAPS

waveOutGetDevCaps

Retrieves the capabilities of a specified waveform audio output device.

WAVEOUTCAPS

The waveInGetDevCaps and waveOutGetDevCaps functions fill the dwFormats member of the WAVEINCAPS and WAVEOUTCAPS structures with flags that describe the standard supported sound formats for a specified audio I/O device. Waveform audio I/O devices also support nonstandard capabilities. You also can use the waveInOpen or the waveOutOpen function to determine if a waveform audio I/O device supports a specified format.

To determine if a waveform audio I/O device supports a standard or a nonstandard format

  1. The common order for calling Waveform Audio functions to play audio is:

  2. Specify the format that you want to query in the WAVEFORMATEX structure.

  3. Pass this structure into waveInOpen or waveOutOpen by using the pwfx parameter.

  4. Call waveInOpen or waveOutOpen with the WAVE_FORMAT_QUERY flag set.

    This call does not open the device. Instead, the function returns a message that declares whether or not the audio device supports the specified format.

    Note

    Although the WAVEFORMATEX structure supersedes the PCMWAVEFORMAT and WAVEFORMAT structures, Windows Embedded CE maintains both of these structures for backward compatibility.

The following code example shows how to use the waveOutOpen function with the WAVE_FORMAT_QUERY flag to determine if a waveform audio device supports a specified format.

MMRESULT IsFormatSupported (LPWAVEFORMATEX pwfx, UINT uDeviceID) 
{ 
    return waveOutOpen (NULL,               // ptr can be NULL for query
                        uDeviceID,          // The device identifier 
                        pwfx,               // Defines the requested 
                                            // format.
                        NULL,               // No callback 
                        NULL,               // No instance data 
                        WAVE_FORMAT_QUERY); // Query only, do not open.
}

The preceding example determines if the specified waveform audio output device supports a specified waveform audio format. It returns the MMSYSERROR_NOERROR return value if the device supports the format, the WAVERROR_BADFORMAT return value if the device does not support the format, and one of the other MMSYSERROR return values for other errors.

This technique for determining nonstandard format support also applies to waveform audio input devices. The only difference is that the function will use waveInOpen instead of waveOutOpen to query for format support.

To determine if any waveform audio I/O devices on a system support a particular waveform audio data format, use the technique that is illustrated in the previous example. However, you must specify the WAVE_MAPPER constant in the uDeviceID parameter.

See Also

Concepts

Querying and Opening Waveform Audio I/O Devices