Quake II RTX doxygen  1.0 dev
dynamic.h File Reference
#include <AL/al.h>

Go to the source code of this file.

Macros

#define AL_NO_PROTOTYPES
 
#define AL_SOFT_loop_points   1
 
#define AL_LOOP_POINTS_SOFT   0x2015
 
#define QAL_IMP
 
#define QAL(type, func)   extern type q##func
 

Functions

QAL_IMP qboolean QAL_Init (void)
 
void QAL_Shutdown (void)
 

Macro Definition Documentation

◆ AL_LOOP_POINTS_SOFT

#define AL_LOOP_POINTS_SOFT   0x2015

Definition at line 24 of file dynamic.h.

◆ AL_NO_PROTOTYPES

#define AL_NO_PROTOTYPES

Definition at line 19 of file dynamic.h.

◆ AL_SOFT_loop_points

#define AL_SOFT_loop_points   1

Definition at line 23 of file dynamic.h.

◆ QAL

#define QAL (   type,
  func 
)    extern type q##func

Definition at line 102 of file dynamic.h.

◆ QAL_IMP

#define QAL_IMP

Definition at line 27 of file dynamic.h.

Function Documentation

◆ QAL_Init()

QAL_IMP qboolean QAL_Init ( void  )

Definition at line 92 of file dynamic.c.

93 {
94  al_driver = Cvar_Get("al_driver", LIBAL, 0);
95  al_device = Cvar_Get("al_device", "", 0);
96 
97  // don't allow absolute or relative paths
99 
100  Sys_LoadLibrary(al_driver->string, NULL, &handle);
101  if (!handle) {
102  return qfalse;
103  }
104 
105 #define QAL(type, func) if ((q##func = Sys_GetProcAddress(handle, #func)) == NULL) goto fail;
106  QALC_IMP
107  QAL_IMP
108 #undef QAL
109 
110  device = qalcOpenDevice(al_device->string[0] ? al_device->string : NULL);
111  if (!device) {
112  Com_SetLastError(va("alcOpenDevice(%s) failed", al_device->string));
113  goto fail;
114  }
115 
116  context = qalcCreateContext(device, NULL);
117  if (!context) {
118  Com_SetLastError("alcCreateContext failed");
119  goto fail;
120  }
121 
122  if (!qalcMakeContextCurrent(context)) {
123  Com_SetLastError("alcMakeContextCurrent failed");
124  goto fail;
125  }
126 
127  al_driver->flags |= CVAR_SOUND;
128  al_device->flags |= CVAR_SOUND;
129 
130  return qtrue;
131 
132 fail:
133  QAL_Shutdown();
134  return qfalse;
135 }

◆ QAL_Shutdown()

void QAL_Shutdown ( void  )

Definition at line 64 of file dynamic.c.

65 {
66  if (context) {
67  qalcMakeContextCurrent(NULL);
68  qalcDestroyContext(context);
69  context = NULL;
70  }
71  if (device) {
72  qalcCloseDevice(device);
73  device = NULL;
74  }
75 
76 #define QAL(type, func) q##func = NULL
77  QALC_IMP
78  QAL_IMP
79 #undef QAL
80 
81  if (handle) {
83  handle = NULL;
84  }
85 
86  if (al_driver)
87  al_driver->flags &= ~CVAR_SOUND;
88  if (al_device)
89  al_device->flags &= ~CVAR_SOUND;
90 }
handle
static void * handle
Definition: dynamic.c:52
al_device
static cvar_t * al_device
Definition: dynamic.c:50
QAL_IMP
#define QAL_IMP
Definition: dynamic.h:27
QAL_Shutdown
QAL_IMP void QAL_Shutdown(void)
Definition: dynamic.c:64
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: dynamic.c:53
QALC_IMP
#define QALC_IMP
Definition: dynamic.c:27
al_driver
static cvar_t * al_driver
Definition: dynamic.c:49
va
char * va(const char *format,...)
Definition: shared.c:429
Sys_LoadLibrary
void * Sys_LoadLibrary(const char *path, const char *sym, void **handle)
Definition: system.c:794
FS_SanitizeFilenameVariable
void FS_SanitizeFilenameVariable(cvar_t *var)
Definition: files.c:294
context
static ALCcontext * context
Definition: dynamic.c:54
Com_SetLastError
void Com_SetLastError(const char *msg)
Definition: common.c:382
Sys_FreeLibrary
void Sys_FreeLibrary(void *handle)
Definition: system.c:787