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 will fill in a DSCAPS structure:
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 may be trade-offs between various resources; for example, allocating a single hardware streaming 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 may work on some sound devices but not on others. Furthermore, advanced devices are under development that will behave differently than 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 95 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 may have been allocated to another application.