Microsoft Windows CE 3.0  

IDirectSound::SetCooperativeLevel

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.

The IDirectSound::SetCooperativeLevelmethod sets the cooperative level of the application for this sound device.

HRESULT SetCooperativeLevel(
HWND
hwnd
,
DWORD
dwLevel
);

Parameters

hwnd
Window handle to the application. See Remarks.
dwLevel
Requested priority level. Specify one of the following values:
DSSCL_EXCLUSIVE Sets the application to the exclusive level. When it has the input focus, the application will be the only one audible (sounds from applications with the DSBCAPS_GLOBALFOCUS flag set will be muted). With this level, it also has all the privileges of the DSSCL_PRIORITY level. DirectSound will restore the hardware format, as specified by the most recent call to the IDirectSoundBuffer::SetFormatmethod, once the application gains the input focus. (Note that DirectSound will always restore the wave format no matter what priority level is set.)
DSSCL_NORMAL Sets the application to a fully cooperative status. This level has the smoothest multitasking and resource-sharing behavior, but because it does not allow the primary buffer format to change, output is restricted to the default 44kHz, 16-bit, stereo format.
DSSCL_PRIORITY Sets the application to the priority level. Applications with this cooperative level can call the IDirectSoundBuffer::SetFormatand IDirectSound::Compactmethods.
DSSCL_WRITEPRIMARY This is the highest priority level. The application has write access to the primary sound buffers. No secondary sound buffers can be played. This level cannot be set if the DirectSound driver is being emulated for the device; that is, if the IDirectSound::GetCapsmethod returns the DSCAPS_EMULDRIVER flag in the DSCAPSstructure.

Return Values

If the method succeeds, the return value is DS_OK.

If the method fails, the return value may be one of the following error values:

Remarks

The application must set the cooperative level by calling this method before its buffers can be played. The recommended cooperative level is DSSCL_PRIORITY; use other priority levels when necessary. For additional information, see "DirectSound" in the Graphics and Multimedia guide.

The hwndparameter should be the top-level application window handle. If you are also using DirectDraw, it must be the same handle passed to the IDirectDraw4::SetCooperativeLevelmethod.

If your application cannot easily supply a window handle, you can obtain one by using the following code:

HWND hWnd = GetForegroundWindow(); if (hWnd ==
NULL) { hWnd = GetDesktopWindow(); }

On Windows CE, only the DSSCL_NORMALpriority level is supported. All playing secondary buffers from all processes will be mixed and played.

Requirements

Runs On Versions Defined in Include Link to
Windows CE OS 2.12 or later. Version 2.12 requires DXPAK 1.0 or later. dsound.h   dsound.lib
Note   This API is part of the complete Windows CE OS package as provided by Microsoft. The functionality of a particular platform is determined by the original equipment manufacturer (OEM) and some devices may not support this API.

See Also

IDirectSound::Compact, IDirectSoundBuffer::GetFormat, IDirectSoundBuffer::GetVolume, IDirectSoundBuffer::Lock, IDirectSoundBuffer::Play, IDirectSoundBuffer::Restore, IDirectSoundBuffer::SetFormat