Compartilhar via


Creating the Capture Device Object

[The feature associated with this page, DirectSound, is a legacy feature. It has been superseded by WASAPI and Audio Graphs. Media Casting have been optimized for Windows 10 and Windows 11. Microsoft strongly recommends that new code use Media Casting instead of DirectSound, when possible. Microsoft suggests that existing code that uses the legacy APIs be rewritten to use the new APIs if possible.]

You can create the capture device object by calling either the DirectSoundCaptureCreate8 or the DirectSoundFullDuplexCreate8 function. Both these functions retrieve a pointer to the IDirectSoundCapture8 interface.

The lpcGUID parameter to DirectSoundCaptureCreate, or the pcGuidRenderDevice parameter to DirectSoundFullDuplexCreate8, can be a GUID obtained by enumeration, or it can be one of the following predefined GUIDs:

GUID Description
DSDEVID_DefaultCapture The default system capture device. You can also specify this device by passing a NULL pointer instead of a device GUID.
DSDEVID_DefaultVoiceCapture The default voice communications capture device. Typically, this is a secondary device such as a USB headset with microphone.

If no device driver is present, the call fails.

You can also use the CoCreateInstance function to create the object. The procedure is similar to that for the device object; see Creating the Device Object. If you use CoCreateInstance, the object is created for the default capture device selected by the user in Control Panel.

If you want playback and capture device objects to coexist, then you should create and initialize the playback device object before creating and initializing the capture device object, or use DirectSoundFullDuplexCreate8.

Some audio devices aren't configured for full duplex audio by default. If your application has problems with creating and initializing both a playback device object and a capture device object, you should advise the user to check the audio device properties to ensure that full duplex is enabled.