Querying the Hardware Capabilities
DirectSound allows your application to retrieve the hardware capabilities of the sound device being used by a DirectSound object. Most applications will not need to do this; DirectSound automatically takes advantage of hardware acceleration. However, high-performance applications can use this information to scale their sound requirements to the available hardware. For example, your application might play more sounds if hardware mixing is available.
To retrieve the hardware capabilities, use the IDirectSound::GetCaps method, which fills in a DSCAPS structure, as shown in the following example :
AppDetermineHardwareCaps(LPDIRECTSOUND lpDirectSound)
{
DSCAPS dscaps;
HRESULT hr;
dscaps.dwSize = sizeof(DSCAPS);
hr = lpDirectSound->lpVtbl->GetCaps(lpDirectSound,
&dscaps);
if(DS_OK == hr) {
// Succeeded, now parse DSCAPS structure.
// .
// .
// .
}
// .
// .
// .
}
The DSCAPS structure contains information about the performance and resources of the sound device, including the maximum resources of each type and the resources that are currently available. There can be tradeoffs between various resources; for example, allocating a single hardware streaming sound buffer might consume two static mixing channels. If your application scales to hardware capabilities, you should call the IDirectSound::GetCaps method between every buffer allocation to determine if there are enough resources for the next buffer creation.
Do not make assumptions about the behavior of the sound device; otherwise, your application might work on some sound devices but not on others. Furthermore, future devices might behave differently from existing devices.
When allocating hardware resources, your application should attempt to allocate them as software buffers instead. Complete access to all hardware resources is not always available. For example, because Windows is a multitasking operating system, the IDirectSound::GetCaps method might indicate a free resource, but by the time you attempt to allocate the resource, it might have been allocated to another application.