DirectSound defines four cooperative levels for sound devices: normal, priority, exclusive, and write-primary. Applications set a sound device's cooperative level by using the IDirectSound::SetCooperativeLevel method. Applications can create global or sticky sound buffers in all cooperative levels except write-primary.
The normal cooperative level is the lowest level. At the normal level, the IDirectSoundBuffer::SetFormat and IDirectSound::Compact methods cannot be called. In addition, the application cannot obtain write access to primary buffers. All applications using this cooperative level use a primary buffer format of 22 kHz, stereo sound, and 8-bit samples to make task switching as smooth as possible.
When using a DirectSound object with the priority cooperative level, the application has first priority to hardware resources, such as hardware mixing, and can call IDirectSoundBuffer::SetFormat and IDirectSound::Compact.
When using a DirectSound object with the exclusive cooperative level, the application has all the privileges of the priority level. In addition, however, when the application has the input focus, its buffers are the only ones that are audible. After the input focus is gained, DirectSound restores the application's preferred wave format, which was defined in the most recent call to IDirectSoundBuffer::SetFormat. (DirectSound restores the wave format regardless of the priority level.)
The highest cooperative level is write-primary. When using a DirectSound object with this cooperative level, your application has direct access to the primary sound buffer. In this mode, the application must lock the buffer by using the IDirectSoundBuffer::Lock method and write directly to the primary buffer. While this occurs, secondary buffers cannot be played.
When the application is set to the write-primary cooperative level and gains the input focus, all secondary buffers for other applications are stopped and marked as lost. (These buffers must be restored by using the IDirectSoundBuffer::Restore method before they can be played again.) When this application, in turn, loses the input focus, its primary buffer is marked as lost. It also can be restored after the application regains the input focus.
The write-primary level is not required to create a primary buffer. However, to obtain access to the audio samples in the primary buffer, the application must be set to the write-primary level. If the application is not set to this level, then all calls to IDirectSoundBuffer::Lock and IDirectSoundBuffer::Play fail, although some methods, such as IDirectSoundBuffer::GetFormat, IDirectSoundBuffer::SetFormat, and IDirectSoundBuffer::GetVolume, can still be called successfully.