Managing Rendering Contexts

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 OpenAL, "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").

Configuration Management

Not yet specified.

Creating a Context

A context is created using alcCreateContext. At this time, the device parameter should be a NULL pointer. The attribute list is implementation specific.

ALCcontext* alcCreateContext ( ALCdevice* device , int * attrList );

Selecting a Context

To make a Context current, alcMakeContextCurrent is used. At this time, the device parameter should be a NULL pointer. The context parameter can be NULL or a valid context pointer.

boolean alcMakeContextCurrent ( ALCdevice* device, ALCcontext* context);

Query for Current Context

The application can query for, and obtain an handle to, the current context. If there is no current context, NULL is returned.

ALCcontext alcGetCurrentContext(void);

Destroying a Context

void alcDestroyContext(ALCdevicedevice, ALCcontextcontext);

Recommendation: do not destroy a current context.