Make the SDL sounddriver selectable via s_sdldriver

This is necessary since the default "waveout" driver on windows is
incompatible to Quake II (due to too big output buffers) and "dsound"
can't be forced since it's not available on some installations. The
default driver is choosen by platform:

Windows -> dsound
FreeBSD -> dsp
Linux   -> alsa
This commit is contained in:
Yamagi Burmeister 2012-06-05 09:03:46 +02:00
parent 2629f908ae
commit 4021087a38

View file

@ -40,10 +40,11 @@
#include "../client/sound/header/local.h"
/* Global stuff */
int snd_inited = 0;
int snd_inited = 0;
static int dmapos = 0;
static int dmasize = 0;
static dma_t *dmabackend;
cvar_t *s_sdldriver;
/* The callback */
static void
@ -101,6 +102,7 @@ qboolean
SNDDMA_Init(void)
{
char drivername[128];
char reqdriver[128];
SDL_AudioSpec desired;
SDL_AudioSpec obtained;
int tmp, val;
@ -116,6 +118,17 @@ SNDDMA_Init(void)
int sndfreq = (Cvar_Get("s_khz", "44", CVAR_ARCHIVE))->value;
int sndchans = (Cvar_Get("sndchannels", "2", CVAR_ARCHIVE))->value;
#ifdef _WIN32
s_sdldriver = (Cvar_Get("s_sdldriver", "dsound", CVAR_ARCHIVE));
#elif __linux__
s_sdldriver = (Cvar_Get("s_sdldriver", "alsa", CVAR_ARCHIVE));
#else
s_sdldriver = (Cvar_Get("s_sdldriver", "dsp", CVAR_ARCHIVE));
#endif
snprintf(reqdriver, sizeof(drivername), "%s=%s", "SDL_AUDIODRIVER", s_sdldriver->string);
putenv(reqdriver);
Com_Printf("Starting SDL audio callback.\n");
if (!SDL_WasInit(SDL_INIT_AUDIO))