| OpenAL Specification and Reference | ||
|---|---|---|
| <<< Previous | AL Contexts and the ALC API | Next >>> |
All operations of the AL core API affect a current AL context. Within the scope of AL, the ALC is implied - it is not visible as a handle or function parameter. Only one AL Context per INprocess can be current at a time. Applications maintaining multiple AL Contexts, whether threaded or not, have to set the current context accordingly. Applications can have multiple threads that share one more or contexts. In other words, AL and ALC are threadsafe.
The default AL Context interoperates with a hardware device driver. The application manages hardware and driver resources by communicating through the ALC API, and configures and uses such Contexts by issuing AL API calls. A default AL Context processes AL calls and sound data to generate sound output. Such a Context is called a Rendering Context. There might be non-rendering contexts in the future.
The word "rendering" was chosen intentionally to emphasize the primary objective of the AL API - spatialized sound - and the underlying concept of AL as a sound synthesis pipeline that simulates sound propagation by specifying spatial arrangements of listeners, filters, and sources. If used in describing an application that uses both OpenGL and AL, "sound rendering context" and "graphics rendering context" should be used for clarity. Throughout this document, "rendering" is used to describe spatialized audio synthesis (avoiding ambiguous words like "processing", as well as proprietary and restrictive terms like "wavetracing").
The application can choose to specify certain attributes for a context. Attributes not specified explicitely are set to implementation dependend defaults.
Table 1. Context Attributes
| Name | Description |
|---|---|
| ALC_FREQUENCY | Frequency for mixing output buffer, in units of Hz. |
| ALC_REFRESH | Refresh intervalls, in units of Hz. |
| ALC_SYNC | Flag, indicating a synchronous context. |
A context is created using alcCreateContext. The device parameter has to be a valid device. The attribute list can be NULL, or a zero terminated list of integer pairs composed of valid ALC attribute tokens and requested values.
ALCcontext * alcCreateContext ( const ALCdevice * deviceHandle , int * attrList );
To make a Context current with respect to AL Operation (state changes by issueing commands), alcMakeContextCurrent is used. The context parameter can be NULL or a valid context pointer. The operation will apply to the device that the context was created for.
boolean alcMakeContextCurrent ( ALCcontext * context );
The current context is the only context accessible to state changes by AL commands (aside from state changes affecting shared objects). However, multiple contexts can be processed at the same time. To indicate that a context should be processed (i.e. that internal execution state like offset increments are supposed to be performed), the application has to use alcProcessContext.
void alcProcessContext( ALCcontext * context );
The application can suspend any context from processing (including the current one). To indicate that a context should be suspended from processing (i.e. that internal execution state like offset increments is not supposed to be changed), the application has to use alcSuspendContext.
void alcSuspendContext( ALCcontext * context );
void alcDestroyContext ( ALCcontext * context );
| <<< Previous | Home | Next >>> |
| AL Contexts and the ALC API | Up | ALC Queries |