|Microsoft DirectX 9.0|
If your application is simply going to capture sounds through the user's preferred capture device, there is no need to enumerate the available devices. When you create the device object by calling the DirectSoundCaptureCreate8 or DirectSoundFullDuplexCreate8 function, you can specify a default device. For more information, see Creating the Capture Device Object.
Enumeration is necessary in the following situations:
Enumeration serves three purposes:
To enumerate devices, you must first set up a callback function that will be called once for each device on the system. You can do anything you want within this function, and you can give it any name, but you must declare it in the same form as the DSEnumCallback prototype. The callback function must return TRUE if enumeration is to continue, or FALSE otherwisefor instance, after finding a device with the capabilities you need.
For a sample callback function, see Enumerating Sound Devices.
The enumeration is set in motion by using the DirectSoundCaptureEnumerate function, as follows:
DWORD pv; // Can be any 32-bit type. HRESULT hr = DirectSoundCaptureEnumerate( (LPDSENUMCALLBACK)DSEnumProc, (VOID*)&pv);
The second parameter can be any 32-bit value that you want to have access to within the callback.
Note The first device enumerated is always called the Primary Sound Capture Driver, and the lpGUID parameter of the callback is NULL. This device represents the preferred capture device set by the user in Control Panel. It is enumerated separately to make it easy for the application to add "Primary Sound Capture Driver" to a list when presenting the user with a choice of devices. The primary capture device is also enumerated with its proper name and GUID.