Microsoft DirectX 9.0

Device Capabilities

DirectSound enables your application to examine the hardware capabilities of the sound device. Many applications do not need to do this, because DirectSound automatically takes advantage of any available hardware acceleration. However, high-performance applications can use the information to scale their sound requirements to the available hardware. For example, an application might choose to play more sounds if hardware mixing is available than if it is not.

After calling the DirectSoundCreate8 function to create a device object, your application can retrieve the capabilities of the sound device by calling the IDirectSound8::GetCaps method.

The following example retrieves the capabilities of the device represented by the IDirectSound8 interface pointer lpDirectSound:

DSCAPS dscaps; 
 
dscaps.dwSize = sizeof(DSCAPS); 
HRESULT hr = lpDirectSound->GetCaps(&dscaps); 
if (FAILED(hr))
{
  ErrorHandler(hr);  // Add error-handling here.
}

The DSCAPS structure receives information about the performance and resources of the sound device, including the maximum resources of each type and the resources that are currently available. Note that the dwSize member of this structure must be initialized before the method is called.

If your application scales to hardware capabilities, you should call the IDirectSound8::GetCaps method between every buffer allocation to determine if there are enough resources to create the next buffer.