Quake II RTX doxygen  1.0 dev
fixed.c File Reference
#include "shared/shared.h"
#include "common/cvar.h"
#include "common/common.h"
#include "fixed.h"
#include <AL/alc.h>

Go to the source code of this file.

Functions

void QAL_Shutdown (void)
 
qboolean QAL_Init (void)
 

Variables

static cvar_t * al_device
 
static ALCdevice * device
 
static ALCcontext * context
 

Function Documentation

◆ QAL_Init()

qboolean QAL_Init ( void  )

Definition at line 46 of file fixed.c.

47 {
48  al_device = Cvar_Get("al_device", "", 0);
49 
50  device = alcOpenDevice(al_device->string[0] ? al_device->string : NULL);
51  if (!device) {
52  Com_SetLastError(va("alcOpenDevice(%s) failed", al_device->string));
53  goto fail;
54  }
55 
56  context = alcCreateContext(device, NULL);
57  if (!context) {
58  Com_SetLastError("alcCreateContext failed");
59  goto fail;
60  }
61 
62  if (!alcMakeContextCurrent(context)) {
63  Com_SetLastError("alcMakeContextCurrent failed");
64  goto fail;
65  }
66 
67  al_device->flags |= CVAR_SOUND;
68 
69  return qtrue;
70 
71 fail:
72  QAL_Shutdown();
73  return qfalse;
74 }

◆ QAL_Shutdown()

void QAL_Shutdown ( void  )

Definition at line 30 of file fixed.c.

31 {
32  if (context) {
33  alcMakeContextCurrent(NULL);
34  alcDestroyContext(context);
35  context = NULL;
36  }
37  if (device) {
38  alcCloseDevice(device);
39  device = NULL;
40  }
41 
42  if (al_device)
43  al_device->flags &= ~CVAR_SOUND;
44 }

Referenced by QAL_Init().

Variable Documentation

◆ al_device

cvar_t* al_device
static

Definition at line 25 of file fixed.c.

Referenced by QAL_Init(), and QAL_Shutdown().

◆ context

ALCcontext* context
static

Definition at line 28 of file fixed.c.

Referenced by QAL_Init(), and QAL_Shutdown().

◆ device

ALCdevice* device
static

Definition at line 27 of file fixed.c.

Referenced by QAL_Init(), and QAL_Shutdown().

Cvar_Get
cvar_t * Cvar_Get(const char *var_name, const char *var_value, int flags)
Definition: cvar.c:257
device
static ALCdevice * device
Definition: fixed.c:27
al_device
static cvar_t * al_device
Definition: fixed.c:25
va
char * va(const char *format,...)
Definition: shared.c:429
QAL_Shutdown
void QAL_Shutdown(void)
Definition: fixed.c:30
context
static ALCcontext * context
Definition: fixed.c:28
Com_SetLastError
void Com_SetLastError(const char *msg)
Definition: common.c:382