CRI ADX  Last Updated: 2025-05-07 13:34 p
WASAPI exclusive mode

Sample directory

/cri/pc/samples/criatomex/wasapi_exclusive

Data used in the sample

/cri/common/smpdata/criatomex/
  • SampleProject.acf
  • AtomCueSheet.acb
  • AtomCueSheet.awb

Sample description

How to use
If you want to use the WASAPI exclusive mode, you need to initialize the library with the following procedure.
-# Instruct the library to use the WASAPI exclusive mode with the criAtom_SetAudioClientShareMode_WASAPI function.
-# Specify the sound output format as WAVEFORMATEXTENSIBLE type in the criAtom_SetAudioClientFormat_WASAPI function.
-# Initialize the library with the criAtomEx_Initialize_WASAPI function.
An example of specific processing code is shown below.
:
/* Indicate to initialize WASAPI in exclusive mode */
criAtom_SetAudioClientShareMode_WASAPI(AUDCLNT_SHAREMODE_EXCLUSIVE);
/* Specify the WASAPI output format */
/* Caution: This sample uses 48 kHz 24-bit PCM output, */
/* but there is no guarantee that the specified format can actually be used. */
memset(&output_format, 0, sizeof(output_format));
ex_ptr = (WAVEFORMATEX *)&output_format;
ex_ptr->wFormatTag = WAVE_FORMAT_EXTENSIBLE;
ex_ptr->nChannels = 2;
ex_ptr->nSamplesPerSec = 48000;
ex_ptr->wBitsPerSample = 32;
ex_ptr->nBlockAlign = ex_ptr->wBitsPerSample / 8 * ex_ptr->nChannels;
ex_ptr->nAvgBytesPerSec = ex_ptr->nSamplesPerSec * ex_ptr->nBlockAlign;
ex_ptr->cbSize = 22;
output_format.Samples.wValidBitsPerSample = 24;
output_format.SubFormat = KSDATAFORMAT_SUBTYPE_PCM;
criAtom_SetAudioClientFormat_WASAPI((const WAVEFORMATEX *)ex_ptr);
/* Initialize the library for WASAPI output */
/* Initialize the library for WASAPI output */
:
void criAtom_SetAudioClientFormat_WASAPI(const WAVEFORMATEX *format)
Output format specification.
void criAtom_SetAudioClientShareMode_WASAPI(AUDCLNT_SHAREMODE mode)
Sharing mode specification.
void criAtomEx_Initialize_WASAPI(const CriAtomExConfig_WASAPI *config, void *work, CriSint32 work_size)
Library initialization.
[Remarks]
When the library is initialized using the criAtomEx_Initialize_WASAPI function, you must use the criAtomEx_Finalize_WASAPI function to clean up the library when you are finished.
Cautions
Whether or not the specified format can be used to correctly output sound strongly depends on the hardware used.
(In some cases, sound may not be output properly even if there is no error returned from WASAPI.)
Use WASAPI exclusive mode only for games which are hardware-limited (such as PC-based arcade games).
Only one application may use WASAPI exclusive mode per OS.
If multiple applications are launched that attempt to use WASAPI exclusive mode, the library initialization will fail.
When using WASAPI exclusive mode, sound output will be disabled for all other applications.
Any sound playback from outside the Atom library, even within the same application, will also be muted.
The Atom library supports the following three types of quantization bit PCM data formats.
- 16bit
- 32bit/24valid
- IEEE float
If a PCM data format other than those listed above is specified, or If the criAtom_GetAudioClientIsFormatSupported_WASAPI function returns CRI_FALSE even when an above format is specified, sound output cannot be performed.