Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Added missing snd_system

  • Loading branch information...
commit b4044e18db9366724c747a8c658061ae6ac73643 1 parent 5c0838f
Dusan Jocic authored
188 src/engine/snd_system/libmumblelink.cpp
... ... @@ -0,0 +1,188 @@
35 src/engine/snd_system/libmumblelink.h
... ... @@ -0,0 +1,35 @@
336 src/engine/snd_system/qal.cpp
... ... @@ -0,0 +1,336 @@
  1 +/*
  2 +===========================================================================
  3 +Copyright (C) 1999-2005 Id Software, Inc.
  4 +Copyright (C) 2005 Stuart Dalton (badcdev@gmail.com)
  5 +
  6 +This file is part of OpenWolf source code.
  7 +
  8 +OpenWolf source code is free software; you can redistribute it
  9 +and/or modify it under the terms of the GNU General Public License as
  10 +published by the Free Software Foundation; either version 2 of the License,
  11 +or (at your option) any later version.
  12 +
  13 +OpenWolf source code is distributed in the hope that it will be
  14 +useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
  15 +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16 +GNU General Public License for more details.
  17 +
  18 +You should have received a copy of the GNU General Public License
  19 +along with OpenWolf source code; if not, write to the Free Software
  20 +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  21 +===========================================================================
  22 +*/
  23 +
  24 +// Dynamically loads OpenAL
  25 +
  26 +#ifdef USE_OPENAL
  27 +
  28 +#include "qal.h"
  29 +
  30 +#ifdef USE_OPENAL_DLOPEN
  31 +
  32 +#include "../sys/sys_loadlib.h"
  33 +
  34 +LPALENABLE qalEnable;
  35 +LPALDISABLE qalDisable;
  36 +LPALISENABLED qalIsEnabled;
  37 +LPALGETSTRING qalGetString;
  38 +LPALGETBOOLEANV qalGetBooleanv;
  39 +LPALGETINTEGERV qalGetIntegerv;
  40 +LPALGETFLOATV qalGetFloatv;
  41 +LPALGETDOUBLEV qalGetDoublev;
  42 +LPALGETBOOLEAN qalGetBoolean;
  43 +LPALGETINTEGER qalGetInteger;
  44 +LPALGETFLOAT qalGetFloat;
  45 +LPALGETDOUBLE qalGetDouble;
  46 +LPALGETERROR qalGetError;
  47 +LPALISEXTENSIONPRESENT qalIsExtensionPresent;
  48 +LPALGETPROCADDRESS qalGetProcAddress;
  49 +LPALGETENUMVALUE qalGetEnumValue;
  50 +LPALLISTENERF qalListenerf;
  51 +LPALLISTENER3F qalListener3f;
  52 +LPALLISTENERFV qalListenerfv;
  53 +LPALLISTENERI qalListeneri;
  54 +LPALGETLISTENERF qalGetListenerf;
  55 +LPALGETLISTENER3F qalGetListener3f;
  56 +LPALGETLISTENERFV qalGetListenerfv;
  57 +LPALGETLISTENERI qalGetListeneri;
  58 +LPALGENSOURCES qalGenSources;
  59 +LPALDELETESOURCES qalDeleteSources;
  60 +LPALISSOURCE qalIsSource;
  61 +LPALSOURCEF qalSourcef;
  62 +LPALSOURCE3F qalSource3f;
  63 +LPALSOURCEFV qalSourcefv;
  64 +LPALSOURCEI qalSourcei;
  65 +LPALGETSOURCEF qalGetSourcef;
  66 +LPALGETSOURCE3F qalGetSource3f;
  67 +LPALGETSOURCEFV qalGetSourcefv;
  68 +LPALGETSOURCEI qalGetSourcei;
  69 +LPALSOURCEPLAYV qalSourcePlayv;
  70 +LPALSOURCESTOPV qalSourceStopv;
  71 +LPALSOURCEREWINDV qalSourceRewindv;
  72 +LPALSOURCEPAUSEV qalSourcePausev;
  73 +LPALSOURCEPLAY qalSourcePlay;
  74 +LPALSOURCESTOP qalSourceStop;
  75 +LPALSOURCEREWIND qalSourceRewind;
  76 +LPALSOURCEPAUSE qalSourcePause;
  77 +LPALSOURCEQUEUEBUFFERS qalSourceQueueBuffers;
  78 +LPALSOURCEUNQUEUEBUFFERS qalSourceUnqueueBuffers;
  79 +LPALGENBUFFERS qalGenBuffers;
  80 +LPALDELETEBUFFERS qalDeleteBuffers;
  81 +LPALISBUFFER qalIsBuffer;
  82 +LPALBUFFERDATA qalBufferData;
  83 +LPALGETBUFFERF qalGetBufferf;
  84 +LPALGETBUFFERI qalGetBufferi;
  85 +LPALDOPPLERFACTOR qalDopplerFactor;
  86 +LPALDOPPLERVELOCITY qalDopplerVelocity;
  87 +LPALDISTANCEMODEL qalDistanceModel;
  88 +
  89 +LPALCCREATECONTEXT qalcCreateContext;
  90 +LPALCMAKECONTEXTCURRENT qalcMakeContextCurrent;
  91 +LPALCPROCESSCONTEXT qalcProcessContext;
  92 +LPALCSUSPENDCONTEXT qalcSuspendContext;
  93 +LPALCDESTROYCONTEXT qalcDestroyContext;
  94 +LPALCGETCURRENTCONTEXT qalcGetCurrentContext;
  95 +LPALCGETCONTEXTSDEVICE qalcGetContextsDevice;
  96 +LPALCOPENDEVICE qalcOpenDevice;
  97 +LPALCCLOSEDEVICE qalcCloseDevice;
  98 +LPALCGETERROR qalcGetError;
  99 +LPALCISEXTENSIONPRESENT qalcIsExtensionPresent;
  100 +LPALCGETPROCADDRESS qalcGetProcAddress;
  101 +LPALCGETENUMVALUE qalcGetEnumValue;
  102 +LPALCGETSTRING qalcGetString;
  103 +LPALCGETINTEGERV qalcGetIntegerv;
  104 +LPALCCAPTUREOPENDEVICE qalcCaptureOpenDevice;
  105 +LPALCCAPTURECLOSEDEVICE qalcCaptureCloseDevice;
  106 +LPALCCAPTURESTART qalcCaptureStart;
  107 +LPALCCAPTURESTOP qalcCaptureStop;
  108 +LPALCCAPTURESAMPLES qalcCaptureSamples;
  109 +
  110 +static void *OpenALLib = NULL;
  111 +
  112 +static qboolean alinit_fail = qfalse;
  113 +
  114 +/*
  115 +=================
  116 +GPA
  117 +=================
  118 +*/
  119 +static void *GPA(char *str)
  120 +{
  121 + void *rv;
  122 +
  123 + rv = Sys_LoadFunction(OpenALLib, str);
  124 + if(!rv)
  125 + {
  126 + Com_Printf( " Can't load symbol %s\n", str);
  127 + alinit_fail = qtrue;
  128 + return NULL;
  129 + }
  130 + else
  131 + {
  132 + Com_DPrintf( " Loaded symbol %s (%p)\n", str, rv);
  133 + return rv;
  134 + }
  135 +}
  136 +
  137 +/*
  138 +=================
  139 +QAL_Init
  140 +=================
  141 +*/
  142 +qboolean QAL_Init(const char *libname)
  143 +{
  144 + if(OpenALLib)
  145 + return qtrue;
  146 +
  147 + if(!(OpenALLib = Sys_LoadDll(libname, qtrue)))
  148 + return qfalse;
  149 +
  150 + alinit_fail = qfalse;
  151 +
  152 + qalEnable = GPA("alEnable");
  153 + qalDisable = GPA("alDisable");
  154 + qalIsEnabled = GPA("alIsEnabled");
  155 + qalGetString = GPA("alGetString");
  156 + qalGetBooleanv = GPA("alGetBooleanv");
  157 + qalGetIntegerv = GPA("alGetIntegerv");
  158 + qalGetFloatv = GPA("alGetFloatv");
  159 + qalGetDoublev = GPA("alGetDoublev");
  160 + qalGetBoolean = GPA("alGetBoolean");
  161 + qalGetInteger = GPA("alGetInteger");
  162 + qalGetFloat = GPA("alGetFloat");
  163 + qalGetDouble = GPA("alGetDouble");
  164 + qalGetError = GPA("alGetError");
  165 + qalIsExtensionPresent = GPA("alIsExtensionPresent");
  166 + qalGetProcAddress = GPA("alGetProcAddress");
  167 + qalGetEnumValue = GPA("alGetEnumValue");
  168 + qalListenerf = GPA("alListenerf");
  169 + qalListener3f = GPA("alListener3f");
  170 + qalListenerfv = GPA("alListenerfv");
  171 + qalListeneri = GPA("alListeneri");
  172 + qalGetListenerf = GPA("alGetListenerf");
  173 + qalGetListener3f = GPA("alGetListener3f");
  174 + qalGetListenerfv = GPA("alGetListenerfv");
  175 + qalGetListeneri = GPA("alGetListeneri");
  176 + qalGenSources = GPA("alGenSources");
  177 + qalDeleteSources = GPA("alDeleteSources");
  178 + qalIsSource = GPA("alIsSource");
  179 + qalSourcef = GPA("alSourcef");
  180 + qalSource3f = GPA("alSource3f");
  181 + qalSourcefv = GPA("alSourcefv");
  182 + qalSourcei = GPA("alSourcei");
  183 + qalGetSourcef = GPA("alGetSourcef");
  184 + qalGetSource3f = GPA("alGetSource3f");
  185 + qalGetSourcefv = GPA("alGetSourcefv");
  186 + qalGetSourcei = GPA("alGetSourcei");
  187 + qalSourcePlayv = GPA("alSourcePlayv");
  188 + qalSourceStopv = GPA("alSourceStopv");
  189 + qalSourceRewindv = GPA("alSourceRewindv");
  190 + qalSourcePausev = GPA("alSourcePausev");
  191 + qalSourcePlay = GPA("alSourcePlay");
  192 + qalSourceStop = GPA("alSourceStop");
  193 + qalSourceRewind = GPA("alSourceRewind");
  194 + qalSourcePause = GPA("alSourcePause");
  195 + qalSourceQueueBuffers = GPA("alSourceQueueBuffers");
  196 + qalSourceUnqueueBuffers = GPA("alSourceUnqueueBuffers");
  197 + qalGenBuffers = GPA("alGenBuffers");
  198 + qalDeleteBuffers = GPA("alDeleteBuffers");
  199 + qalIsBuffer = GPA("alIsBuffer");
  200 + qalBufferData = GPA("alBufferData");
  201 + qalGetBufferf = GPA("alGetBufferf");
  202 + qalGetBufferi = GPA("alGetBufferi");
  203 + qalDopplerFactor = GPA("alDopplerFactor");
  204 + qalDopplerVelocity = GPA("alDopplerVelocity");
  205 + qalDistanceModel = GPA("alDistanceModel");
  206 +
  207 + qalcCreateContext = GPA("alcCreateContext");
  208 + qalcMakeContextCurrent = GPA("alcMakeContextCurrent");
  209 + qalcProcessContext = GPA("alcProcessContext");
  210 + qalcSuspendContext = GPA("alcSuspendContext");
  211 + qalcDestroyContext = GPA("alcDestroyContext");
  212 + qalcGetCurrentContext = GPA("alcGetCurrentContext");
  213 + qalcGetContextsDevice = GPA("alcGetContextsDevice");
  214 + qalcOpenDevice = GPA("alcOpenDevice");
  215 + qalcCloseDevice = GPA("alcCloseDevice");
  216 + qalcGetError = GPA("alcGetError");
  217 + qalcIsExtensionPresent = GPA("alcIsExtensionPresent");
  218 + qalcGetProcAddress = GPA("alcGetProcAddress");
  219 + qalcGetEnumValue = GPA("alcGetEnumValue");
  220 + qalcGetString = GPA("alcGetString");
  221 + qalcGetIntegerv = GPA("alcGetIntegerv");
  222 + qalcCaptureOpenDevice = GPA("alcCaptureOpenDevice");
  223 + qalcCaptureCloseDevice = GPA("alcCaptureCloseDevice");
  224 + qalcCaptureStart = GPA("alcCaptureStart");
  225 + qalcCaptureStop = GPA("alcCaptureStop");
  226 + qalcCaptureSamples = GPA("alcCaptureSamples");
  227 +
  228 + if(alinit_fail)
  229 + {
  230 + QAL_Shutdown();
  231 + Com_Printf( " One or more symbols not found\n");
  232 + return qfalse;
  233 + }
  234 +
  235 + return qtrue;
  236 +}
  237 +
  238 +/*
  239 +=================
  240 +QAL_Shutdown
  241 +=================
  242 +*/
  243 +void QAL_Shutdown( void )
  244 +{
  245 + if(OpenALLib)
  246 + {
  247 + Sys_UnloadLibrary(OpenALLib);
  248 + OpenALLib = NULL;
  249 + }
  250 +
  251 + qalEnable = NULL;
  252 + qalDisable = NULL;
  253 + qalIsEnabled = NULL;
  254 + qalGetString = NULL;
  255 + qalGetBooleanv = NULL;
  256 + qalGetIntegerv = NULL;
  257 + qalGetFloatv = NULL;
  258 + qalGetDoublev = NULL;
  259 + qalGetBoolean = NULL;
  260 + qalGetInteger = NULL;
  261 + qalGetFloat = NULL;
  262 + qalGetDouble = NULL;
  263 + qalGetError = NULL;
  264 + qalIsExtensionPresent = NULL;
  265 + qalGetProcAddress = NULL;
  266 + qalGetEnumValue = NULL;
  267 + qalListenerf = NULL;
  268 + qalListener3f = NULL;
  269 + qalListenerfv = NULL;
  270 + qalListeneri = NULL;
  271 + qalGetListenerf = NULL;
  272 + qalGetListener3f = NULL;
  273 + qalGetListenerfv = NULL;
  274 + qalGetListeneri = NULL;
  275 + qalGenSources = NULL;
  276 + qalDeleteSources = NULL;
  277 + qalIsSource = NULL;
  278 + qalSourcef = NULL;
  279 + qalSource3f = NULL;
  280 + qalSourcefv = NULL;
  281 + qalSourcei = NULL;
  282 + qalGetSourcef = NULL;
  283 + qalGetSource3f = NULL;
  284 + qalGetSourcefv = NULL;
  285 + qalGetSourcei = NULL;
  286 + qalSourcePlayv = NULL;
  287 + qalSourceStopv = NULL;
  288 + qalSourceRewindv = NULL;
  289 + qalSourcePausev = NULL;
  290 + qalSourcePlay = NULL;
  291 + qalSourceStop = NULL;
  292 + qalSourceRewind = NULL;
  293 + qalSourcePause = NULL;
  294 + qalSourceQueueBuffers = NULL;
  295 + qalSourceUnqueueBuffers = NULL;
  296 + qalGenBuffers = NULL;
  297 + qalDeleteBuffers = NULL;
  298 + qalIsBuffer = NULL;
  299 + qalBufferData = NULL;
  300 + qalGetBufferf = NULL;
  301 + qalGetBufferi = NULL;
  302 + qalDopplerFactor = NULL;
  303 + qalDopplerVelocity = NULL;
  304 + qalDistanceModel = NULL;
  305 +
  306 + qalcCreateContext = NULL;
  307 + qalcMakeContextCurrent = NULL;
  308 + qalcProcessContext = NULL;
  309 + qalcSuspendContext = NULL;
  310 + qalcDestroyContext = NULL;
  311 + qalcGetCurrentContext = NULL;
  312 + qalcGetContextsDevice = NULL;
  313 + qalcOpenDevice = NULL;
  314 + qalcCloseDevice = NULL;
  315 + qalcGetError = NULL;
  316 + qalcIsExtensionPresent = NULL;
  317 + qalcGetProcAddress = NULL;
  318 + qalcGetEnumValue = NULL;
  319 + qalcGetString = NULL;
  320 + qalcGetIntegerv = NULL;
  321 + qalcCaptureOpenDevice = NULL;
  322 + qalcCaptureCloseDevice = NULL;
  323 + qalcCaptureStart = NULL;
  324 + qalcCaptureStop = NULL;
  325 + qalcCaptureSamples = NULL;
  326 +}
  327 +#else
  328 +qboolean QAL_Init(const char *libname)
  329 +{
  330 + return qtrue;
  331 +}
  332 +void QAL_Shutdown( void )
  333 +{
  334 +}
  335 +#endif
  336 +#endif
252 src/engine/snd_system/qal.h
... ... @@ -0,0 +1,252 @@
  1 +/*
  2 +===========================================================================
  3 +Copyright (C) 1999-2005 Id Software, Inc.
  4 +Copyright (C) 2005 Stuart Dalton (badcdev@gmail.com)
  5 +
  6 +This file is part of OpenWolf source code.
  7 +
  8 +OpenWolf source code is free software; you can redistribute it
  9 +and/or modify it under the terms of the GNU General Public License as
  10 +published by the Free Software Foundation; either version 2 of the License,
  11 +or (at your option) any later version.
  12 +
  13 +OpenWolf source code is distributed in the hope that it will be
  14 +useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
  15 +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16 +GNU General Public License for more details.
  17 +
  18 +You should have received a copy of the GNU General Public License
  19 +along with OpenWolf source code; if not, write to the Free Software
  20 +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  21 +===========================================================================
  22 +*/
  23 +
  24 +
  25 +#ifndef __QAL_H__
  26 +#define __QAL_H__
  27 +
  28 +#include "../qcommon/q_shared.h"
  29 +#include "../qcommon/qcommon.h"
  30 +
  31 +#ifdef USE_OPENAL_DLOPEN
  32 +#define AL_NO_PROTOTYPES
  33 +#define ALC_NO_PROTOTYPES
  34 +#endif
  35 +
  36 +#ifdef USE_LOCAL_HEADERS
  37 +#include "../AL/al.h"
  38 +#include "../AL/alc.h"
  39 +#else
  40 +#ifdef _MSC_VER
  41 + // MSVC users must install the OpenAL SDK which doesn't use the AL/*.h scheme.
  42 + #include <al.h>
  43 + #include <alc.h>
  44 +#else
  45 + #include <AL/al.h>
  46 + #include <AL/alc.h>
  47 +#endif
  48 +#endif
  49 +
  50 +/* Hack to enable compiling both on OpenAL SDK and OpenAL-soft. */
  51 +#ifndef ALC_ENUMERATE_ALL_EXT
  52 +# define ALC_ENUMERATE_ALL_EXT 1
  53 +# define ALC_DEFAULT_ALL_DEVICES_SPECIFIER 0x1012
  54 +# define ALC_ALL_DEVICES_SPECIFIER 0x1013
  55 +#endif
  56 +
  57 +#ifdef USE_OPENAL_DLOPEN
  58 +extern LPALENABLE qalEnable;
  59 +extern LPALDISABLE qalDisable;
  60 +extern LPALISENABLED qalIsEnabled;
  61 +extern LPALGETSTRING qalGetString;
  62 +extern LPALGETBOOLEANV qalGetBooleanv;
  63 +extern LPALGETINTEGERV qalGetIntegerv;
  64 +extern LPALGETFLOATV qalGetFloatv;
  65 +extern LPALGETDOUBLEV qalGetDoublev;
  66 +extern LPALGETBOOLEAN qalGetBoolean;
  67 +extern LPALGETINTEGER qalGetInteger;
  68 +extern LPALGETFLOAT qalGetFloat;
  69 +extern LPALGETDOUBLE qalGetDouble;
  70 +extern LPALGETERROR qalGetError;
  71 +extern LPALISEXTENSIONPRESENT qalIsExtensionPresent;
  72 +extern LPALGETPROCADDRESS qalGetProcAddress;
  73 +extern LPALGETENUMVALUE qalGetEnumValue;
  74 +extern LPALLISTENERF qalListenerf;
  75 +extern LPALLISTENER3F qalListener3f;
  76 +extern LPALLISTENERFV qalListenerfv;
  77 +extern LPALLISTENERI qalListeneri;
  78 +extern LPALLISTENER3I qalListener3i;
  79 +extern LPALLISTENERIV qalListeneriv;
  80 +extern LPALGETLISTENERF qalGetListenerf;
  81 +extern LPALGETLISTENER3F qalGetListener3f;
  82 +extern LPALGETLISTENERFV qalGetListenerfv;
  83 +extern LPALGETLISTENERI qalGetListeneri;
  84 +extern LPALGETLISTENER3I qalGetListener3i;
  85 +extern LPALGETLISTENERIV qalGetListeneriv;
  86 +extern LPALGENSOURCES qalGenSources;
  87 +extern LPALDELETESOURCES qalDeleteSources;
  88 +extern LPALISSOURCE qalIsSource;
  89 +extern LPALSOURCEF qalSourcef;
  90 +extern LPALSOURCE3F qalSource3f;
  91 +extern LPALSOURCEFV qalSourcefv;
  92 +extern LPALSOURCEI qalSourcei;
  93 +extern LPALSOURCE3I qalSource3i;
  94 +extern LPALSOURCEIV qalSourceiv;
  95 +extern LPALGETSOURCEF qalGetSourcef;
  96 +extern LPALGETSOURCE3F qalGetSource3f;
  97 +extern LPALGETSOURCEFV qalGetSourcefv;
  98 +extern LPALGETSOURCEI qalGetSourcei;
  99 +extern LPALGETSOURCE3I qalGetSource3i;
  100 +extern LPALGETSOURCEIV qalGetSourceiv;
  101 +extern LPALSOURCEPLAYV qalSourcePlayv;
  102 +extern LPALSOURCESTOPV qalSourceStopv;
  103 +extern LPALSOURCEREWINDV qalSourceRewindv;
  104 +extern LPALSOURCEPAUSEV qalSourcePausev;
  105 +extern LPALSOURCEPLAY qalSourcePlay;
  106 +extern LPALSOURCESTOP qalSourceStop;
  107 +extern LPALSOURCEREWIND qalSourceRewind;
  108 +extern LPALSOURCEPAUSE qalSourcePause;
  109 +extern LPALSOURCEQUEUEBUFFERS qalSourceQueueBuffers;
  110 +extern LPALSOURCEUNQUEUEBUFFERS qalSourceUnqueueBuffers;
  111 +extern LPALGENBUFFERS qalGenBuffers;
  112 +extern LPALDELETEBUFFERS qalDeleteBuffers;
  113 +extern LPALISBUFFER qalIsBuffer;
  114 +extern LPALBUFFERDATA qalBufferData;
  115 +extern LPALBUFFERF qalBufferf;
  116 +extern LPALBUFFER3F qalBuffer3f;
  117 +extern LPALBUFFERFV qalBufferfv;
  118 +extern LPALBUFFERF qalBufferi;
  119 +extern LPALBUFFER3F qalBuffer3i;
  120 +extern LPALBUFFERFV qalBufferiv;
  121 +extern LPALGETBUFFERF qalGetBufferf;
  122 +extern LPALGETBUFFER3F qalGetBuffer3f;
  123 +extern LPALGETBUFFERFV qalGetBufferfv;
  124 +extern LPALGETBUFFERI qalGetBufferi;
  125 +extern LPALGETBUFFER3I qalGetBuffer3i;
  126 +extern LPALGETBUFFERIV qalGetBufferiv;
  127 +extern LPALDOPPLERFACTOR qalDopplerFactor;
  128 +extern LPALDOPPLERVELOCITY qalDopplerVelocity;
  129 +extern LPALSPEEDOFSOUND qalSpeedOfSound;
  130 +extern LPALDISTANCEMODEL qalDistanceModel;
  131 +
  132 +extern LPALCCREATECONTEXT qalcCreateContext;
  133 +extern LPALCMAKECONTEXTCURRENT qalcMakeContextCurrent;
  134 +extern LPALCPROCESSCONTEXT qalcProcessContext;
  135 +extern LPALCSUSPENDCONTEXT qalcSuspendContext;
  136 +extern LPALCDESTROYCONTEXT qalcDestroyContext;
  137 +extern LPALCGETCURRENTCONTEXT qalcGetCurrentContext;
  138 +extern LPALCGETCONTEXTSDEVICE qalcGetContextsDevice;
  139 +extern LPALCOPENDEVICE qalcOpenDevice;
  140 +extern LPALCCLOSEDEVICE qalcCloseDevice;
  141 +extern LPALCGETERROR qalcGetError;
  142 +extern LPALCISEXTENSIONPRESENT qalcIsExtensionPresent;
  143 +extern LPALCGETPROCADDRESS qalcGetProcAddress;
  144 +extern LPALCGETENUMVALUE qalcGetEnumValue;
  145 +extern LPALCGETSTRING qalcGetString;
  146 +extern LPALCGETINTEGERV qalcGetIntegerv;
  147 +extern LPALCCAPTUREOPENDEVICE qalcCaptureOpenDevice;
  148 +extern LPALCCAPTURECLOSEDEVICE qalcCaptureCloseDevice;
  149 +extern LPALCCAPTURESTART qalcCaptureStart;
  150 +extern LPALCCAPTURESTOP qalcCaptureStop;
  151 +extern LPALCCAPTURESAMPLES qalcCaptureSamples;
  152 +#else
  153 +#define qalEnable alEnable
  154 +#define qalDisable alDisable
  155 +#define qalIsEnabled alIsEnabled
  156 +#define qalGetString alGetString
  157 +#define qalGetBooleanv alGetBooleanv
  158 +#define qalGetIntegerv alGetIntegerv
  159 +#define qalGetFloatv alGetFloatv
  160 +#define qalGetDoublev alGetDoublev
  161 +#define qalGetBoolean alGetBoolean
  162 +#define qalGetInteger alGetInteger
  163 +#define qalGetFloat alGetFloat
  164 +#define qalGetDouble alGetDouble
  165 +#define qalGetError alGetError
  166 +#define qalIsExtensionPresent alIsExtensionPresent
  167 +#define qalGetProcAddress alGetProcAddress
  168 +#define qalGetEnumValue alGetEnumValue
  169 +#define qalListenerf alListenerf
  170 +#define qalListener3f alListener3f
  171 +#define qalListenerfv alListenerfv
  172 +#define qalListeneri alListeneri
  173 +#define qalListener3i alListener3i
  174 +#define qalListeneriv alListeneriv
  175 +#define qalGetListenerf alGetListenerf
  176 +#define qalGetListener3f alGetListener3f
  177 +#define qalGetListenerfv alGetListenerfv
  178 +#define qalGetListeneri alGetListeneri
  179 +#define qalGetListener3i alGetListener3i
  180 +#define qalGetListeneriv alGetListeneriv
  181 +#define qalGenSources alGenSources
  182 +#define qalDeleteSources alDeleteSources
  183 +#define qalIsSource alIsSource
  184 +#define qalSourcef alSourcef
  185 +#define qalSource3f alSource3f
  186 +#define qalSourcefv alSourcefv
  187 +#define qalSourcei alSourcei
  188 +#define qalSource3i alSource3i
  189 +#define qalSourceiv alSourceiv
  190 +#define qalGetSourcef alGetSourcef
  191 +#define qalGetSource3f alGetSource3f
  192 +#define qalGetSourcefv alGetSourcefv
  193 +#define qalGetSourcei alGetSourcei
  194 +#define qalGetSource3i alGetSource3i
  195 +#define qalGetSourceiv alGetSourceiv
  196 +#define qalSourcePlayv alSourcePlayv
  197 +#define qalSourceStopv alSourceStopv
  198 +#define qalSourceRewindv alSourceRewindv
  199 +#define qalSourcePausev alSourcePausev
  200 +#define qalSourcePlay alSourcePlay
  201 +#define qalSourceStop alSourceStop
  202 +#define qalSourceRewind alSourceRewind
  203 +#define qalSourcePause alSourcePause
  204 +#define qalSourceQueueBuffers alSourceQueueBuffers
  205 +#define qalSourceUnqueueBuffers alSourceUnqueueBuffers
  206 +#define qalGenBuffers alGenBuffers
  207 +#define qalDeleteBuffers alDeleteBuffers
  208 +#define qalIsBuffer alIsBuffer
  209 +#define qalBufferData alBufferData
  210 +#define qalBufferf alBufferf
  211 +#define qalBuffer3f alBuffer3f
  212 +#define qalBufferfv alBufferfv
  213 +#define qalBufferi alBufferi
  214 +#define qalBuffer3i alBuffer3i
  215 +#define qalBufferiv alBufferiv
  216 +#define qalGetBufferf alGetBufferf
  217 +#define qalGetBuffer3f alGetBuffer3f
  218 +#define qalGetBufferfv alGetBufferfv
  219 +#define qalGetBufferi alGetBufferi
  220 +#define qalGetBuffer3i alGetBuffer3i
  221 +#define qalGetBufferiv alGetBufferiv
  222 +#define qalDopplerFactor alDopplerFactor
  223 +#define qalDopplerVelocity alDopplerVelocity
  224 +#define qalSpeedOfSound alSpeedOfSound
  225 +#define qalDistanceModel alDistanceModel
  226 +
  227 +#define qalcCreateContext alcCreateContext
  228 +#define qalcMakeContextCurrent alcMakeContextCurrent
  229 +#define qalcProcessContext alcProcessContext
  230 +#define qalcSuspendContext alcSuspendContext
  231 +#define qalcDestroyContext alcDestroyContext
  232 +#define qalcGetCurrentContext alcGetCurrentContext
  233 +#define qalcGetContextsDevice alcGetContextsDevice
  234 +#define qalcOpenDevice alcOpenDevice
  235 +#define qalcCloseDevice alcCloseDevice
  236 +#define qalcGetError alcGetError
  237 +#define qalcIsExtensionPresent alcIsExtensionPresent
  238 +#define qalcGetProcAddress alcGetProcAddress
  239 +#define qalcGetEnumValue alcGetEnumValue
  240 +#define qalcGetString alcGetString
  241 +#define qalcGetIntegerv alcGetIntegerv
  242 +#define qalcCaptureOpenDevice alcCaptureOpenDevice
  243 +#define qalcCaptureCloseDevice alcCaptureCloseDevice
  244 +#define qalcCaptureStart alcCaptureStart
  245 +#define qalcCaptureStop alcCaptureStop
  246 +#define qalcCaptureSamples alcCaptureSamples
  247 +#endif
  248 +
  249 +qboolean QAL_Init(const char *libname);
  250 +void QAL_Shutdown( void );
  251 +
  252 +#endif // __QAL_H__
330 src/engine/snd_system/snd_adpcm.cpp
... ... @@ -0,0 +1,330 @@
  1 +/***********************************************************
  2 +Copyright 1992 by Stichting Mathematisch Centrum, Amsterdam, The
  3 +Netherlands.
  4 +
  5 + All Rights Reserved
  6 +
  7 +Permission to use, copy, modify, and distribute this software and its
  8 +documentation for any purpose and without fee is hereby granted,
  9 +provided that the above copyright notice appear in all copies and that
  10 +both that copyright notice and this permission notice appear in
  11 +supporting documentation, and that the names of Stichting Mathematisch
  12 +Centrum or CWI not be used in advertising or publicity pertaining to
  13 +distribution of the software without specific, written prior permission.
  14 +
  15 +STICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO
  16 +THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
  17 +FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE
  18 +FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  19 +WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  20 +ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
  21 +OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  22 +
  23 +******************************************************************/
  24 +
  25 +/*
  26 +** Intel/DVI ADPCM coder/decoder.
  27 +**
  28 +** The algorithm for this coder was taken from the IMA Compatability Project
  29 +** proceedings, Vol 2, Number 2; May 1992.
  30 +**
  31 +** Version 1.2, 18-Dec-92.
  32 +*/
  33 +
  34 +#include "snd_local.h"
  35 +
  36 +
  37 +/* Intel ADPCM step variation table */
  38 +static int indexTable[16] = {
  39 + -1, -1, -1, -1, 2, 4, 6, 8,
  40 + -1, -1, -1, -1, 2, 4, 6, 8,
  41 +};
  42 +
  43 +static int stepsizeTable[89] = {
  44 + 7, 8, 9, 10, 11, 12, 13, 14, 16, 17,
  45 + 19, 21, 23, 25, 28, 31, 34, 37, 41, 45,
  46 + 50, 55, 60, 66, 73, 80, 88, 97, 107, 118,
  47 + 130, 143, 157, 173, 190, 209, 230, 253, 279, 307,
  48 + 337, 371, 408, 449, 494, 544, 598, 658, 724, 796,
  49 + 876, 963, 1060, 1166, 1282, 1411, 1552, 1707, 1878, 2066,
  50 + 2272, 2499, 2749, 3024, 3327, 3660, 4026, 4428, 4871, 5358,
  51 + 5894, 6484, 7132, 7845, 8630, 9493, 10442, 11487, 12635, 13899,
  52 + 15289, 16818, 18500, 20350, 22385, 24623, 27086, 29794, 32767
  53 +};
  54 +
  55 +
  56 +void S_AdpcmEncode( short indata[], char outdata[], int len, struct adpcm_state *state ) {
  57 + short *inp; /* Input buffer pointer */
  58 + signed char *outp; /* output buffer pointer */
  59 + int val; /* Current input sample value */
  60 + int sign; /* Current adpcm sign bit */
  61 + int delta; /* Current adpcm output value */
  62 + int diff; /* Difference between val and sample */
  63 + int step; /* Stepsize */
  64 + int valpred; /* Predicted output value */
  65 + int vpdiff; /* Current change to valpred */
  66 + int index; /* Current step change index */
  67 + int outputbuffer; /* place to keep previous 4-bit value */
  68 + int bufferstep; /* toggle between outputbuffer/output */
  69 +
  70 + outp = (signed char *)outdata;
  71 + inp = indata;
  72 +
  73 + valpred = state->sample;
  74 + index = state->index;
  75 + step = stepsizeTable[index];
  76 +
  77 + outputbuffer = 0; // quiet a compiler warning
  78 + bufferstep = 1;
  79 +
  80 + for ( ; len > 0 ; len-- ) {
  81 + val = *inp++;
  82 +
  83 + /* Step 1 - compute difference with previous value */
  84 + diff = val - valpred;
  85 + sign = (diff < 0) ? 8 : 0;
  86 + if ( sign ) diff = (-diff);
  87 +
  88 + /* Step 2 - Divide and clamp */
  89 + /* Note:
  90 + ** This code *approximately* computes:
  91 + ** delta = diff*4/step;
  92 + ** vpdiff = (delta+0.5)*step/4;
  93 + ** but in shift step bits are dropped. The net result of this is
  94 + ** that even if you have fast mul/div hardware you cannot put it to
  95 + ** good use since the fixup would be too expensive.
  96 + */
  97 + delta = 0;
  98 + vpdiff = (step >> 3);
  99 +
  100 + if ( diff >= step ) {
  101 + delta = 4;
  102 + diff -= step;
  103 + vpdiff += step;
  104 + }
  105 + step >>= 1;
  106 + if ( diff >= step ) {
  107 + delta |= 2;
  108 + diff -= step;
  109 + vpdiff += step;
  110 + }
  111 + step >>= 1;
  112 + if ( diff >= step ) {
  113 + delta |= 1;
  114 + vpdiff += step;
  115 + }
  116 +
  117 + /* Step 3 - Update previous value */
  118 + if ( sign )
  119 + valpred -= vpdiff;
  120 + else
  121 + valpred += vpdiff;
  122 +
  123 + /* Step 4 - Clamp previous value to 16 bits */
  124 + if ( valpred > 32767 )
  125 + valpred = 32767;
  126 + else if ( valpred < -32768 )
  127 + valpred = -32768;
  128 +
  129 + /* Step 5 - Assemble value, update index and step values */
  130 + delta |= sign;
  131 +
  132 + index += indexTable[delta];
  133 + if ( index < 0 ) index = 0;
  134 + if ( index > 88 ) index = 88;
  135 + step = stepsizeTable[index];
  136 +
  137 + /* Step 6 - Output value */
  138 + if ( bufferstep ) {
  139 + outputbuffer = (delta << 4) & 0xf0;
  140 + } else {
  141 + *outp++ = (delta & 0x0f) | outputbuffer;
  142 + }
  143 + bufferstep = !bufferstep;
  144 + }
  145 +
  146 + /* Output last step, if needed */
  147 + if ( !bufferstep )
  148 + *outp++ = outputbuffer;
  149 +
  150 + state->sample = valpred;
  151 + state->index = index;
  152 +}
  153 +
  154 +
  155 +/* static */ void S_AdpcmDecode( const char indata[], short *outdata, int len, struct adpcm_state *state ) {
  156 + signed char *inp; /* Input buffer pointer */
  157 + int outp; /* output buffer pointer */
  158 + int sign; /* Current adpcm sign bit */
  159 + int delta; /* Current adpcm output value */
  160 + int step; /* Stepsize */
  161 + int valpred; /* Predicted value */
  162 + int vpdiff; /* Current change to valpred */
  163 + int index; /* Current step change index */
  164 + int inputbuffer; /* place to keep next 4-bit value */
  165 + int bufferstep; /* toggle between inputbuffer/input */
  166 +
  167 + outp = 0;
  168 + inp = (signed char *)indata;
  169 +
  170 + valpred = state->sample;
  171 + index = state->index;
  172 + step = stepsizeTable[index];
  173 +
  174 + bufferstep = 0;
  175 + inputbuffer = 0; // quiet a compiler warning
  176 + for ( ; len > 0 ; len-- ) {
  177 +
  178 + /* Step 1 - get the delta value */
  179 + if ( bufferstep ) {
  180 + delta = inputbuffer & 0xf;
  181 + } else {
  182 + inputbuffer = *inp++;
  183 + delta = (inputbuffer >> 4) & 0xf;
  184 + }
  185 + bufferstep = !bufferstep;
  186 +
  187 + /* Step 2 - Find new index value (for later) */
  188 + index += indexTable[delta];
  189 + if ( index < 0 ) index = 0;
  190 + if ( index > 88 ) index = 88;
  191 +
  192 + /* Step 3 - Separate sign and magnitude */
  193 + sign = delta & 8;
  194 + delta = delta & 7;
  195 +
  196 + /* Step 4 - Compute difference and new predicted value */
  197 + /*
  198 + ** Computes 'vpdiff = (delta+0.5)*step/4', but see comment
  199 + ** in adpcm_coder.
  200 + */
  201 + vpdiff = step >> 3;
  202 + if ( delta & 4 ) vpdiff += step;
  203 + if ( delta & 2 ) vpdiff += step>>1;
  204 + if ( delta & 1 ) vpdiff += step>>2;
  205 +
  206 + if ( sign )
  207 + valpred -= vpdiff;
  208 + else
  209 + valpred += vpdiff;
  210 +
  211 + /* Step 5 - clamp output value */
  212 + if ( valpred > 32767 )
  213 + valpred = 32767;
  214 + else if ( valpred < -32768 )
  215 + valpred = -32768;
  216 +
  217 + /* Step 6 - Update step value */
  218 + step = stepsizeTable[index];
  219 +
  220 + /* Step 7 - Output value */
  221 + outdata[outp] = valpred;
  222 + outp++;
  223 + }
  224 +
  225 + state->sample = valpred;
  226 + state->index = index;
  227 +}
  228 +
  229 +
  230 +/*
  231 +====================
  232 +S_AdpcmMemoryNeeded
  233 +
  234 +Returns the amount of memory (in bytes) needed to store the samples in out internal adpcm format
  235 +====================
  236 +*/
  237 +int S_AdpcmMemoryNeeded( const wavinfo_t *info ) {
  238 + float scale;
  239 + int scaledSampleCount;
  240 + int sampleMemory;
  241 + int blockCount;
  242 + int headerMemory;
  243 +
  244 + // determine scale to convert from input sampling rate to desired sampling rate
  245 + scale = (float)info->rate / dma.speed;
  246 +
  247 + // calc number of samples at playback sampling rate
  248 + scaledSampleCount = info->samples / scale;
  249 +
  250 + // calc memory need to store those samples using ADPCM at 4 bits per sample
  251 + sampleMemory = scaledSampleCount / 2;
  252 +
  253 + // calc number of sample blocks needed of PAINTBUFFER_SIZE
  254 + blockCount = scaledSampleCount / PAINTBUFFER_SIZE;
  255 + if( scaledSampleCount % PAINTBUFFER_SIZE ) {
  256 + blockCount++;
  257 + }
  258 +
  259 + // calc memory needed to store the block headers
  260 + headerMemory = blockCount * sizeof(adpcm_state_t);
  261 +
  262 + return sampleMemory + headerMemory;
  263 +}
  264 +
  265 +
  266 +/*
  267 +====================
  268 +S_AdpcmGetSamples
  269 +====================
  270 +*/
  271 +void S_AdpcmGetSamples(sndBuffer *chunk, short *to) {
  272 + adpcm_state_t state;
  273 + byte *out;
  274 +
  275 + // get the starting state from the block header
  276 + state.index = chunk->adpcm.index;
  277 + state.sample = chunk->adpcm.sample;
  278 +
  279 + out = (byte *)chunk->sndChunk;
  280 + // get samples
  281 + S_AdpcmDecode((char *) out, to, SND_CHUNK_SIZE_BYTE*2, &state );
  282 +}
  283 +
  284 +
  285 +/*
  286 +====================
  287 +S_AdpcmEncodeSound
  288 +====================
  289 +*/
  290 +void S_AdpcmEncodeSound( sfx_t *sfx, short *samples ) {
  291 + adpcm_state_t state;
  292 + int inOffset;
  293 + int count;
  294 + int n;
  295 + sndBuffer *newchunk, *chunk;
  296 + byte *out;
  297 +
  298 + inOffset = 0;
  299 + count = sfx->soundLength;
  300 + state.index = 0;
  301 + state.sample = samples[0];
  302 +
  303 + chunk = NULL;
  304 + while( count ) {
  305 + n = count;
  306 + if( n > SND_CHUNK_SIZE_BYTE*2 ) {
  307 + n = SND_CHUNK_SIZE_BYTE*2;
  308 + }
  309 +
  310 + newchunk = SND_malloc();
  311 + if (sfx->soundData == NULL) {
  312 + sfx->soundData = newchunk;
  313 + } else {
  314 + chunk->next = newchunk;
  315 + }
  316 + chunk = newchunk;
  317 +
  318 + // output the header
  319 + chunk->adpcm.index = state.index;
  320 + chunk->adpcm.sample = state.sample;
  321 +
  322 + out = (byte *)chunk->sndChunk;
  323 +
  324 + // encode the samples
  325 + S_AdpcmEncode( samples + inOffset, (char *) out, n, &state );
  326 +
  327 + inOffset += n;
  328 + count -= n;
  329 + }
  330 +}
259 src/engine/snd_system/snd_codec.cpp
... ... @@ -0,0 +1,259 @@
  1 +/*
  2 +===========================================================================
  3 +Copyright (C) 1999-2005 Id Software, Inc.
  4 +Copyright (C) 2005 Stuart Dalton (badcdev@gmail.com)
  5 +
  6 +This file is part of OpenWolf source code.
  7 +
  8 +OpenWolf source code is free software; you can redistribute it
  9 +and/or modify it under the terms of the GNU General Public License as
  10 +published by the Free Software Foundation; either version 2 of the License,
  11 +or (at your option) any later version.
  12 +
  13 +OpenWolf source code is distributed in the hope that it will be
  14