Microsoft Windows CE 3.0  

Cooperative Levels

Important:
This is retired content. This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This content may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.

Because Windows is a multitasking environment, more than one application may be working with a device driver at any one time. Through the use of cooperative levels, DirectX makes sure that each application does not gain access to the device in the wrong way or at the wrong time. Each DirectSound application has a cooperative level that determines the extent to which it is allowed to access the device.

After creating a DirectSound object, you must set the cooperative level for the device with the IDirectSound::SetCooperativeLevelmethod before you can play sounds.

In Windows 9x, and Windows 2000, DirectSound defines four cooperative levels for sound devices: normal, priority, exclusive, and write-primary. These are represented by the values DSSCL_NORMAL, DSSCL_PRIORITY, DSSCL_EXCLUSIVE, and DSSCL_WRITEPRIMARY. Windows CE does not need that level of control, and so the only cooperative level available on Windows CE is DSSCL_NORMAL.

The following C example sets the cooperative level for the DirectSound device initialized at Creating the DirectSound Object. The hwndparameter is the handle to the application window.

HRESULT hr =
lpDirectSound->lpVtbl->SetCooperativeLevel( lpDirectSound,
hwnd, DSSCL_NORMAL);

Normal Cooperative Level

At the normal cooperative level, the application cannot set the format of the primary sound buffer, write to the primary buffer, or compact the on-board memory of the device. All applications at this cooperative level use a primary buffer format of 44 kHz, stereo sound, and 16-bit samples, so that the device can switch between applications as smoothly as possible. Secondary buffers can be in whatever format required.

For more information, see Access to the Primary Buffer.



 Last updated on Tuesday, May 18, 2004

© 2004 Microsoft Corporation. All rights reserved.